#include <windows.h> #define ID_HELP 150 #define ID_EDIT 180 #define ID_TEXT 200 char nEditTwo[128]= "Input String Here." ; BOOL CALLBACK DialogProc (HWND, UINT, WPARAM, LPARAM) ; LPWORD lpwAlign ( LPWORD lpIn) { ULONG ul; ul = (ULONG) lpIn; ul +=3; ul >>=2; ul <<=2; return (LPWORD) ul; } int main() { HGLOBAL hgbl; LPDLGTEMPLATE lpdt; LPDLGITEMTEMPLATE lpdit; LPWORD lpw; LPWSTR lpwsz; LRESULT ret; int nchar; hgbl = GlobalAlloc(GMEM_ZEROINIT, 1024); if (!hgbl) return -1; lpdt = (LPDLGTEMPLATE)GlobalLock(hgbl); // Define a dialog box. lpdt->style = WS_POPUP | WS_BORDER | WS_SYSMENU | DS_MODALFRAME | WS_CAPTION; lpdt->cdit = 3; // number of controls lpdt->x = 10; lpdt->y = 10; lpdt->cx = 100; lpdt->cy = 70; lpw = (LPWORD) (lpdt + 1); *lpw++ = 0; // no menu *lpw++ = 0; // predefined dialog box class (by default) lpwsz = (LPWSTR) lpw; nchar = 1+ MultiByteToWideChar (CP_ACP, 0, "DialogBox", -1, lpwsz, 50); lpw += nchar; //----------------------- // Define an OK button. //----------------------- lpw = lpwAlign (lpw); lpdit = (LPDLGITEMTEMPLATE) lpw; lpdit->x = 10; lpdit->y = 50; lpdit->cx = 80; lpdit->cy = 15; lpdit->id = IDOK; // OK button identifier lpdit->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON; lpw = (LPWORD) (lpdit + 1); *lpw++ = 0xFFFF; *lpw++ = 0x0080; // button class lpwsz = (LPWSTR) lpw; nchar = 1+MultiByteToWideChar (CP_ACP, 0, "Exit", -1, lpwsz, 50); lpw += nchar; *lpw++ = 0; // no creation data //----------------------- // Define a Help button. //----------------------- lpw = lpwAlign (lpw); lpdit = (LPDLGITEMTEMPLATE) lpw; lpdit->x = 10; lpdit->y = 30; lpdit->cx = 80; lpdit->cy = 15; lpdit->id = ID_HELP; // Help button identifier lpdit->style = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON; lpw = (LPWORD) (lpdit + 1); *lpw++ = 0xFFFF; *lpw++ = 0x0080; // button class atom lpwsz = (LPWSTR) lpw; nchar = 1+MultiByteToWideChar (CP_ACP, 0, "DisplayInput", -1, lpwsz, 50); lpw += nchar; *lpw++ = 0; // no creation data //----------------------- // Define a EDIT. //----------------------- lpw = lpwAlign (lpw); lpdit = (LPDLGITEMTEMPLATE) lpw; lpdit->x = 10; lpdit->y = 10; lpdit->cx = 80; lpdit->cy = 12; lpdit->id = ID_EDIT; // Help button identifier lpdit->style = ES_LEFT | WS_BORDER | WS_TABSTOP | WS_CHILD | WS_VISIBLE; lpw = (LPWORD) (lpdit + 1); *lpw++ = 0xFFFF; *lpw++ = 0x0081; // edit class atom /*lpwsz = (LPWSTR) lpw; lstrcpyW(lpwsz, L"Edit"); // button label (Unicode) lpw = (LPWORD) (lpwsz + lstrlenW(lpwsz) + 1);*/ *lpw++ = 0; // no creation data //----------------------- // Define a static text control. //----------------------- /*lpw = lpwAlign (lpw); lpdit = (LPDLGITEMTEMPLATE) lpw; lpdit->x = 10; lpdit->y = 10; lpdit->cx = 40; lpdit->cy = 20; lpdit->id = 200; //ID_TEXT; // text identifier lpdit->style = WS_CHILD | WS_VISIBLE | SS_LEFT; lpw = (LPWORD) (lpdit + 1); *lpw++ = 0xFFFF; *lpw++ = 0x0082; // static class for (lpwsz = (LPWSTR)lpw; *lpwsz++ = (WCHAR) *lpszMessage++; ); lpw = (LPWORD)lpwsz; *lpw++ = 0;*/ // no creation data GlobalUnlock(hgbl); ret = DialogBoxIndirect(NULL, (LPDLGTEMPLATE) hgbl, NULL, (DLGPROC) DialogProc); GlobalFree(hgbl); return ret; } BOOL CALLBACK DialogProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam) { switch (iMsg) { case WM_INITDIALOG : SetDlgItemText ( hDlg, ID_EDIT, nEditTwo ); return TRUE ; case WM_COMMAND : switch (LOWORD (wParam)) { case ID_EDIT : GetDlgItemText (hDlg, ID_EDIT, nEditTwo, 127); return TRUE; case ID_HELP : MessageBox( NULL, nEditTwo, "Input Data", MB_OK | MB_SYSTEMMODAL | MB_NOFOCUS); return TRUE; case IDOK : EndDialog (hDlg, 0) ; return TRUE ; } break ; } return FALSE ; }
'API' 카테고리의 다른 글
레지스트리 쓰기, 삭제 함수 (1) | 2008.08.13 |
---|---|
#if defined(_UNICODE) || defined(UNICODE) 디파인 or 연결시 (0) | 2008.08.08 |
DialogBoxIndirect 샘플 수정 및 코딩 최적화 작업 (1) | 2008.08.06 |
대화상자와 등록 정보 시트 소프트웨어 (0) | 2008.08.06 |
DialogBoxIndirect 사용 예제 (3) | 2008.08.06 |
cbWndExtra 이용 윈도우 인스턴스 별로 개별적인 메모리 할당... (1) | 2008.08.06 |
DLL 에 대해서 알아보자. (0) | 2008.08.04 |