64,654
社区成员
发帖
与我相关
我的任务
分享
CreateDialog (
hInst,
MAKEINTRESOURCE(IDD_DIALOG_MSG),
GetDesktopWindow(),//hWnd,
(DLGPROC) Test
);
LRESULT CALLBACK GoToMsg (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
RECT rrect;
switch (message)
{
case CREATE_ITEM:
{
HWND hEdit1, hEdit2, hButton1, hButton2;
usetmp = (_DMSUSER *)lParam;
GetWindowRect (hDlg, &rrect);
hButton2 = CreateWindow (TEXT("BUTTON"),
TEXT(""),
WS_CHILD | WS_VISIBLE,
10,
2 *(rrect.bottom - rrect.top) / 3 + 10,
20,
20,
hDlg,
(HMENU)1004,
NULL,
NULL);
usetmp->hmsgedit = hEdit1;
usetmp->hsendedit = hEdit2;
usetmp->hsendbutton = hButton1;
usetmp->hfilebutton = hButton2;
RegisterHotKey (usetmp->hwnd, 1003, MOD_CONTROL, 13);//MOD_CONTROL
SetWindowText (usetmp->hwnd, usetmp->sessoin->name);
break;
}
case WM_SIZE:
{
usetmp = clsdmsuser.stGetUser (hDlg);
GetWindowRect (hDlg, &rrect);
SetWindowPos (usetmp->hmsgedit, HWND_NOTOPMOST, 0, 10, rrect.right - rrect.left - 10,
2 * (rrect.bottom - rrect.top) / 3, SWP_NOMOVE | SWP_NOZORDER );
SetWindowPos (usetmp->hsendedit, HWND_NOTOPMOST, 0, 2 * (rrect.bottom - rrect.top) / 3 + 30,
rrect.right - rrect.left - 70, (rrect.bottom - rrect.top) / 3 - 70,
SWP_NOZORDER );
SetWindowPos (usetmp->hsendbutton, HWND_NOTOPMOST, rrect.right - rrect.left - 60,
2 * (rrect.bottom - rrect.top) / 3 + 40,
50,
(rrect.bottom - rrect.top) / 3 - 90,
SWP_NOZORDER );
SetWindowPos (usetmp->hfilebutton, HWND_NOTOPMOST, 10,
2 * (rrect.bottom - rrect.top) / 3 + 10,
20,
20,
SWP_NOZORDER );
break;
}
case WM_INITDIALOG:
{
return TRUE;
}
case WM_HOTKEY:
{
wmId = LOWORD(wParam);
if (wmId == 1003)
{
usetmp = clsdmsuser.stGetUser (GetActiveWindow ());
if (usetmp)
{
SendMessage (usetmp->hwnd, WM_COMMAND, 1003, 0);
}
}
break;
}
case WM_SYSCOMMAND:
{
if (wParam == SC_MINIMIZE)
{
ShowWindow (hDlg, SW_SHOWMINIMIZED);
}
else if (wParam == SC_RESTORE)
{
usetmp = clsdmsuser.stGetUser (hDlg);
if (usetmp)
{
ShowWindow (usetmp->hwnd, SW_RESTORE);
SetFocus (usetmp->hsendedit);
}
}
break;
}
case WM_COMMAND:
{
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
switch (wmId)
{
case IDCANCEL:
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
case 1004:
{
usetmp = clsdmsuser.stGetUser (hDlg);
if (!usetmp) break;
OPENFILENAME ofn ;
TCHAR szFilter[] = TEXT ("Text Files (*.TXT)\0*.txt\0") \
TEXT ("ASCII Files (*.ASC)\0*.asc\0") \
TEXT ("All Files (*.*)\0*.*\0\0") ;
ofn.lStructSize = sizeof (OPENFILENAME) ;
ofn.hwndOwner = hDlg ;
ofn.hInstance = NULL ;
ofn.lpstrFilter = szFilter ;
ofn.lpstrCustomFilter = NULL ;
ofn.nMaxCustFilter = 0 ;
ofn.nFilterIndex = 1 ;
ofn.nMaxFile = MAX_PATH ;
ofn.lpstrFileTitle = NULL ; // Set in Open and Close functions
ofn.nMaxFileTitle = MAX_PATH ;
ofn.lpstrInitialDir = NULL ;
ofn.lpstrTitle = NULL ;
ofn.nFileOffset = 0 ;
ofn.nFileExtension = 0 ;
ofn.lpstrDefExt = TEXT ("txt") ;
ofn.lCustData = 0L ;
ofn.lpfnHook = NULL ;
ofn.lpTemplateName = NULL ;
ofn.lpstrFile = usetmp->filepath;
ofn.lpstrFile[0] = '\0';
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST ;
if (GetOpenFileName (&ofn))
{
}
break;
}
}
break;
}
}
return FALSE;
}