1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
//IDD_TEST DIALOGEX 0, 0, 174, 195
//STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
//CAPTION "Test Dialog"
//FONT 8, "MS Shell Dlg", 400, 0, 0x1
//BEGIN
// DEFPUSHBUTTON "Close",IDCLOSE,103,170,50,14
// PUSHBUTTON "Test",IDC_TEST,43,170,50,14
// CTEXT "RichEdit Control",IDC_STATIC,16,5,201,8
// CONTROL "",IDC_RICHEDIT,"RichEdit50W", ES_MULTILINE | ES_WANTRETURN
// | WS_BORDER | WS_TABSTOP,16,24,138,134
//END
HWND CreateTestDialog(HINSTANCE hinst)
{
HGLOBAL hgbl = GlobalAlloc(GMEM_ZEROINIT, 1024);
if (!hgbl)
return NULL;
HWND hwnd = NULL;
LPWORD lpw = NULL;
// Define a dialog box
{
LPDLGTEMPLATE lpdt = (LPDLGTEMPLATE)GlobalLock(hgbl);
lpdt->style = DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU;
lpdt->dwExtendedStyle = 0;
lpdt->cdit = 4; // Number of controls
lpdt->x = 0; lpdt->y = 0;
lpdt->cx = 174; lpdt->cy = 195;
lpw = (LPWORD)(lpdt + 1);
*lpw++ = 0; // No menu
*lpw++ = 0; // Predefined dialog box class (by default)
LPWSTR lpwsz1 = (LPWSTR)lpw;
int nchar1 = MultiByteToWideChar(CP_ACP, 0, "Test Dialog", -1, lpwsz1, 50);
lpw += nchar1;
*lpw++ = 8; // font size
LPWSTR lpwsz2 = (LPWSTR)lpw;
int nchar2 = MultiByteToWideChar(CP_ACP, 0, "MS Shell Dlg", -1, lpwsz2, 50);
lpw += nchar2;
}
// Define a Close button
{
lpw = lpwAlign(lpw); // Align DLGITEMTEMPLATE on DWORD boundary
LPDLGITEMTEMPLATE lpdit = (LPDLGITEMTEMPLATE)lpw;
lpdit->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON;
lpdit->dwExtendedStyle = 0;
lpdit->x = 103; lpdit->y = 170;
lpdit->cx = 50; lpdit->cy = 14;
lpdit->id = IDCLOSE; // Close button identifier
lpw = (LPWORD)(lpdit + 1);
*lpw++ = 0xFFFF;
*lpw++ = 0x0080; // Button class
LPWSTR lpwsz = (LPWSTR)lpw;
int nchar = MultiByteToWideChar(CP_ACP, 0, "Close", -1, lpwsz, 50);
lpw += nchar;
*lpw++ = 0; // No creation data
}
// Define a test button (displays Bold (to start with) or Normal
{
lpw = lpwAlign(lpw); // Align DLGITEMTEMPLATE on DWORD boundary
LPDLGITEMTEMPLATE lpdit = (LPDLGITEMTEMPLATE)lpw;
lpdit->style = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON;
lpdit->dwExtendedStyle = 0;
lpdit->x = 43; lpdit->y = 170;
lpdit->cx = 50; lpdit->cy = 14;
lpdit->id = IDC_TEST; // Test button identifier
lpw = (LPWORD)(lpdit + 1);
*lpw++ = 0xFFFF;
*lpw++ = 0x0080; // Button class
LPWSTR lpwsz = (LPWSTR)lpw;
int nchar = MultiByteToWideChar(CP_ACP, 0, "Bold", -1, lpwsz, 50);
lpw += nchar;
*lpw++ = 0; // No creation data
}
// Define a static text control.
{
lpw = lpwAlign(lpw); // Align DLGITEMTEMPLATE on DWORD boundary
LPDLGITEMTEMPLATE lpdit = (LPDLGITEMTEMPLATE)lpw;
lpdit->style = WS_CHILD | WS_VISIBLE | SS_LEFT;
lpdit->dwExtendedStyle = 0;
lpdit->x = 16; lpdit->y = 5;
lpdit->cx = 101; lpdit->cy = 8;
lpdit->id = IDC_STATIC;
lpw = (LPWORD)(lpdit + 1);
*lpw++ = 0xFFFF;
*lpw++ = 0x0082; // Static class
LPWSTR lpwsz = (LPWSTR)lpw;
int nchar = MultiByteToWideChar(CP_ACP, 0, "RichEdit Control", -1, lpwsz, 50);
lpw += nchar;
*lpw++ = 0; // No creation data
}
// Define a RichEdit control.
{
lpw = lpwAlign(lpw); // Align DLGITEMTEMPLATE on DWORD boundary
LPDLGITEMTEMPLATE lpdit = (LPDLGITEMTEMPLATE)lpw;
lpdit->style = WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP
| ES_MULTILINE | ES_WANTRETURN;
lpdit->dwExtendedStyle = 0;
lpdit->x = 16; lpdit->y = 24;
lpdit->cx = 138; lpdit->cy = 134;
lpdit->id = IDC_RICHEDIT;
lpw = (LPWORD)(lpdit + 1);
LPWSTR lpwsz2 = (LPWSTR)lpw;
int nchar2 = MultiByteToWideChar(CP_ACP, 0, "RichEdit50W", -1, lpwsz2, 50);
lpw += nchar2;
LPWSTR lpwsz = (LPWSTR)lpw;
int nchar = MultiByteToWideChar(CP_ACP, 0, "RichEdit Control", -1, lpwsz, 50);
lpw += nchar;
*lpw++ = 0; // No creation data
}
GlobalUnlock(hgbl);
hwnd = CreateDialogIndirect(hinst, (LPDLGTEMPLATE)hgbl, NULL, TestDialogProc);
GlobalFree(hgbl);
return hwnd;
}
|