Professional Documents
Culture Documents
#include<windows.h>
#include"resource.h"
HWND h;
MSG m;
WNDCLASS w;
if(!j)
w.cbClsExtra=0;
w.cbWndExtra=0;
w.hbrBackground=(HBRUSH) GetStockObject(WHITE_BRUSH);
w.hCursor=LoadCursor(NULL,IDC_ARROW);
w.hInstance=i;
w.lpfnWndProc=r;
w.lpszClassName=TEXT("Class");
w.lpszMenuName=MAKEINTRESOURCE(IDR_MENU1);
return 0;
h=CreateWindow(TEXT("Class"),TEXT("Dialog
Box"),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFA
ULT,NULL,NULL,i,NULL);
ShowWindow(h,l);
while(GetMessage(&m,NULL,0,0))
TranslateMessage(&m);
DispatchMessage(&m);
return(int)( m.wParam);
switch(m)
case WM_COMMAND:
switch(w)
case IDM_DIALOG:
// lpfnDlgProc=MakeProcInstance(DialogProc,
(HINSTANCE) GetWindowLong(h,GWL_HINSTANCE));
//MakeProcInstance function is obsolete. Win32
functions can be called directly.
DialogBox((HINSTANCE)GetWindowLong(h,GWL_HINSTANCE),MAKEINTRESOURCE(FirstDialog),h,D);//Di
alogProc);
// FreeProcInstance(lpfnDlgProc);
break;
case IDM_QUIT:
DestroyWindow(h);
break;
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(h,m,w,l);
return 0;
switch(m)
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(w))
case DLI_OK:
EndDialog(h,0);
return TRUE;
case DLI_NOTOK:
PostQuitMessage(0);
//MessageBeep(0);
return TRUE;
break;
case WM_DESTROY:
EndDialog(h,0);
//PostQuitMessage(0);
break;
return FALSE;
}
Dialog box Prog 2
#include<windows.h>
#include"resource.h"
int nRadioChoice=0;
int nCheckOnOff=0;
HWND h;
MSG m;
WNDCLASS w;
if(!j)
w.cbClsExtra=0;
w.cbWndExtra=0;
w.hbrBackground=(HBRUSH) GetStockObject(WHITE_BRUSH);
w.hCursor=LoadCursor(NULL,IDC_ARROW);
w.hInstance=i;
w.lpfnWndProc=r;
w.lpszClassName=TEXT("Class");
w.lpszMenuName=MAKEINTRESOURCE(IDR_MENU1);
if(!RegisterClass(&w))
return 0;
h=CreateWindow(TEXT("Class"),TEXT("Dialog
Box"),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFA
ULT,NULL,NULL,i,NULL);
ShowWindow(h,l);
while(GetMessage(&m,NULL,0,0))
TranslateMessage(&m);
DispatchMessage(&m);
return( m.wParam);
PAINTSTRUCT ps;
TCHAR cBuf[128];
switch(m)
case WM_COMMAND:
switch(w)
case IDM_DIALOG:
nRetVal= DialogBox((HINSTANCE)
GetWindowLong(h,GWL_HINSTANCE),MAKEINTRESOURCE(PickDialog),h,D);
InvalidateRect(h,NULL,TRUE);
break;
case IDM_QUIT:
DestroyWindow(h);
break;
break;
case WM_PAINT:
BeginPaint(h,&ps);
EndPaint(h,&ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(h,m,w,l);
return 0;
switch(m)
case WM_INITDIALOG:
SetRadioButtons(h, nRadioChoice);
SendDlgItemMessage(h,DLI_CHECKBOX,BM_SETCHECK,nCheckOnOff,0);
return(TRUE);
case WM_COMMAND:
switch(w)
case DLI_PICKOK:
EndDialog(h,TRUE);
return (TRUE);
case DLI_PICKCANCEL:
EndDialog(h,FALSE);
return (TRUE);
case DLI_RADIO1:
nRadioChoice=0;
SetRadioButtons(h,nRadioChoice);
return (TRUE);
case DLI_RADIO2:
nRadioChoice=1;
SetRadioButtons(h,nRadioChoice);
return (TRUE);
case DLI_CHECKBOX:
nCheckOnOff=(nCheckOnOff?0:1);
SendDlgItemMessage(h,DLI_CHECKBOX,BM_SETCHECK,nCheckOnOff,0);
return(TRUE);
break;
return FALSE;
if(nButtonOn==1)
SendDlgItemMessage(h,DLI_RADIO1,BM_SETCHECK,0,0);
SendDlgItemMessage(h,DLI_RADIO2,BM_SETCHECK,1,0);
else {
SendDlgItemMessage(h,DLI_RADIO1,BM_SETCHECK,1,0);
SendDlgItemMessage(h,DLI_RADIO2,BM_SETCHECK,0,0);
}
Dialog Box 3
#include<windows.h>
#include"resource.h"
#define NUMMENU 7
#define ARRAYWIDE 15
typedef struct k {
int nCharWidth;
int nItemCount;
int nSelection;
TCHAR *cBuf;
}CHARARRAY;
HWND h;
MSG m;
WNDCLASS w;
if(!j)
w.cbClsExtra=0;
w.cbWndExtra=0;
w.hbrBackground=(HBRUSH) GetStockObject(WHITE_BRUSH);
w.hCursor=LoadCursor(NULL,IDC_ARROW);
w.hIcon=NULL;
w.hInstance=i;
w.lpfnWndProc=r;
w.lpszClassName=TEXT("Class");
w.lpszMenuName=MAKEINTRESOURCE(IDR_MENU1);
if(!RegisterClass(&w))
return 0;
h=CreateWindow(TEXT("Class"),TEXT("Dialog
Box"),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFA
ULT,NULL,NULL,i,NULL);
ShowWindow(h,l);
while(GetMessage(&m,NULL,0,0))
TranslateMessage(&m);
DispatchMessage(&m);
return( m.wParam);
PAINTSTRUCT ps;
int i;
TCHAR c[256];
switch(m) {
case WM_CREATE:
caMenu.nCharWidth=ARRAYWIDE;
caMenu.nItemCount=NUMMENU;
caMenu.nSelection=-1;
caMenu.cBuf=(TCHAR *)cMenuNames;
break;
case WM_COMMAND:
switch(LOWORD(w)) {
case IDM_LIST:
DialogBoxParam((HINSTANCE)
GetWindowLong(h,GWL_HINSTANCE),MAKEINTRESOURCE(LISTDIALOG),h,ListDialogProc,
(LPARAM)&caMenu);
InvalidateRect(h,NULL,TRUE);
break;
case IDM_QUIT:
DestroyWindow(h);
break;
break;
case WM_PAINT:
BeginPaint(h,&ps);
if(caMenu.nSelection==-1)
else
TextOut(ps.hdc,
0,20,cMenuNames[caMenu.nSelection],lstrlen(cMenuNames[caMenu.nSelection]));
EndPaint(h,&ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(h,m,w,l);
return 0;
int i;
LPSTR lpszItem;
TCHAR c[128];
switch(m)
case WM_INITDIALOG:
lpszItem=(LPSTR)pcaListArray->cBuf;
for(i=0;i<pcaListArray->nItemCount;i++) {
SendDlgItemMessage(h,DLI_LISTBOX, LB_ADDSTRING,0,(LPARAM)lpszItem);
lpszItem+=(pcaListArray->nCharWidth*2);
return(TRUE);
case WM_COMMAND:
switch(LOWORD(w)) {
case DLI_LISTOK:
EndDialog(h,TRUE);
return TRUE;
case DLI_LISTCANCEL:
EndDialog(h,FALSE);
return TRUE;
case DLI_LISTBOX:
if(HIWORD(w)==LBN_SELCHANGE) {
i=(int)SendDlgItemMessage(h,DLI_LISTBOX, LB_GETCURSEL,0,0);
pcaListArray->nSelection=i;
return TRUE;
break;
return FALSE;