UltraVNC 里怎么给下面这个控件添加快捷键
vncListDlg::vncListDlg()
{
m_dlgvisible = FALSE;
}
//
//
//
vncListDlg::~vncListDlg()
{
}
//
//
//
BOOL vncListDlg::Init(vncServer* pServer)
{
m_pServer = pServer;
return TRUE;
}
//
//
//
void vncListDlg::Display()
{
if (!m_dlgvisible)
{
// [v1.0.2-jp1 fix] Load resouce from dll
//DialogBoxParam( hAppInstance,
DialogBoxParam( hInstResDLL,
MAKEINTRESOURCE(IDD_LIST_DLG),
NULL,
(DLGPROC) DialogProc,
(LONG) this
);
}
}
//
//
//
BOOL CALLBACK vncListDlg::DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
vncListDlg *_this = helper::SafeGetWindowUserData<vncListDlg>(hwnd);
switch (uMsg)
{
case WM_INITDIALOG:
{
helper::SafeSetWindowUserData(hwnd, lParam);
_this = (vncListDlg *) lParam;
vncClientList::iterator i;
HWND hList = GetDlgItem(hwnd, IDC_VIEWERS_LISTBOX);
_this->m_pServer->ListAuthClients(hList);
SendMessage(hList, LB_SETCURSEL, -1, 0);
// adzm 2009-07-05
HWND hPendingList = GetDlgItem(hwnd, IDC_PENDING_LISTBOX);
_this->m_pServer->ListUnauthClients(hPendingList);
SetForegroundWindow(hwnd);
_this->m_dlgvisible = TRUE;
if (!_this->m_pServer->GetAllowEditClients())
{
EnableWindow(GetDlgItem(hwnd, IDC_KILL_B), false);
}
else EnableWindow(GetDlgItem(hwnd, IDC_KILL_B), true);
// Allow TextChat if one client only
/*
EnableWindow(GetDlgItem(hwnd, IDC_TEXTCHAT_B),
_this->m_pServer->AuthClientCount() == 1 ? TRUE : FALSE);
*/
return TRUE;
}
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDCANCEL:
case IDOK:
EndDialog(hwnd, TRUE);
_this->m_dlgvisible = FALSE;
return TRUE;
case IDC_KILL_B:
{
HWND hList = GetDlgItem(hwnd, IDC_VIEWERS_LISTBOX);
DWORD nSelected = SendMessage(hList, LB_GETCURSEL, 0, 0);
if (nSelected != LB_ERR)
{
char szClient[128];
if (SendMessage(hList, LB_GETTEXT, nSelected, (LPARAM)szClient) > 0)
_this->m_pServer->KillClient(szClient);
}
EndDialog(hwnd, TRUE);
_this->m_dlgvisible = FALSE;
return TRUE;
}
break;
case IDC_TEXTCHAT_B:
{
HWND hList = GetDlgItem(hwnd, IDC_VIEWERS_LISTBOX);//LISTBOX 控件
DWORD nSelected = SendMessage(hList, LB_GETCURSEL, 0, 0);
if (nSelected != LB_ERR)
{
char szClient[128];
if (SendMessage(hList, LB_GETTEXT, nSelected, (LPARAM)szClient) > 0)
_this->m_pServer->TextChatClient(szClient);
}
EndDialog(hwnd, TRUE);
_this->m_dlgvisible = FALSE;
return TRUE;
}
break;
}
break;
case WM_DESTROY:
EndDialog(hwnd, FALSE);
_this->m_dlgvisible = FALSE;
return TRUE;
}
return 0;
}
我想给IDC_TEXTCHAT_B 这个控件添加快捷键 这个控件是个按钮控件,大致就是获取列表里被选择的项目,然后发送消息,
BOOL vncListDlg::PreTranslateMessage(MSG* pMsg) {
if(pMsg->message == WM_KEYDOWN && IsSHIFTPressed()&& IsCTRLPressed())
{
switch(pMsg->wParam)
{
case '1' :
::SendMessage(hWnd,WM_COMMAND,IDC_TEXTCHAT_B,(LPARAM)GetDlgItem(hWnd,IDC_TEXTCHAT_B));
break;
}
return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}
自己是这么加的,但是编译后提示找不到hwnd和CDialog
请各位帮忙