Documente Academic
Documente Profesional
Documente Cultură
#include <windows.h>
#include "resource.h"
#include<fstream.h>
hmenu hmenu;
hwnd hwnd;
fstream file;
int winapi winmain(hinstance hinst,hinstance hpinst, pstr szcmdline,int
icmdshow)
{
static char appname[] = text ("hello");
msg msg;
wndclass wndcls;
if(!registerclass(&wndcls))
{
messagebox(null,text("not ok"),appname,mb_iconerror);
return 0;
}
file.open("a.txt",ios::in|ios::out, filebuf::openprot);
//load menu created through resources
hmenu = loadmenu(hinst,makeintresource(idr_menu1));
hwnd = createwindow(
appname //application name
,text("title of the window") // title of window
,ws_overlappedwindow | ws_hscroll | ws_vscroll// style of window
,0 // horizontal position of window
,0 // vertical position of window
,cw_usedefault // width
,cw_usedefault // height
,null // handle to parent or owner window
,hmenu // handle to menu or child-window identifier
,hinst // handle to application instance
,null); // pointer to window-creation data
showwindow(hwnd,icmdshow);
updatewindow(hwnd);
//modeless dialogbox
// hdlgmodeless =
createdialog(hinst,makeintresource(idd_student),hwnd,dlgproc);
while (getmessage(&msg,null,0,0))
{
if (hdlgmodeless == 0 || !isdialogmessage(hdlgmodeless,&msg))
{
translatemessage(&msg);//required in case of keyboard handling
dispatchmessage(&msg);
}
}
return msg.wparam;
}
switch(message)
{
hdc hdc;
hmenu hmenu,hmenupopup;
case wm_create:
hinstance = ((lpcreatestruct)lparam)->hinstance;
hwnd1 = createwindow(text("editbox"),null,ws_child |
ws_visible |
ws_border
,100,0,20,0,hwnd
,(hmenu)1,hinstance,null);
hwnd2 = createwindow(text("button"),"ok",ws_child |
ws_visible
|bs_pushbutton
,200,10,20,0,hwnd
,(hmenu)2,hinstance,null);
return 0;
//sendmessage(hwnd1,wm_gettext,20,(lparam)buff);
case wm_command:
//modal dialog box
switch(loword(wparam))
{
case idm_student:
dialogbox(hinstance,makeintresource(idd_student),hwnd,dlgproc);
//dialogbox(hinstance,text("idd_student"),hwnd,dlgproc);
break;
case idm_staff:
dialogbox(hinstance,makeintresource(idd_staff),hwnd,dlgproc1);
break;
}
return 0;
case wm_destroy:
postquitmessage(0);
return 0;
}
return defwindowproc(hwnd,message,wparam,lparam);
}
case wm_initdialog:
return true;
case wm_command:
switch(loword(wparam))
{
case idc_save:
getdlgitemtext(
hdlg, // handle of dialog box
idc_edit1, // identifier of control
szbuffer, // address of buffer for text
20 // maximum size of string
);
textout(hdc,200,200,szbuffer,lstrlen(szbuffer));
file<<szbuffer;
break;
case idc_add_to_list:
break;
case idc_ok:
messagebox(null,buff,"dialog box",mb_iconerror);
break;
case idc_cancel:
enddialog(hdlg,0);
return true;
}
break;
}
return false;
}
bool callback dlgproc1(hwnd hdlg,uint message,wparam wparam,lparam
lparam)
{
char buff[10];
switch(message)
{
case wm_initdialog:
return true;
case wm_command:
switch(loword(wparam))
{
case idc_ok:
messagebox(null,buff,"dialog box",mb_iconerror);
break;
case idc_cancel:
enddialog(hdlg,0);
return true;
}
break;
}
return false;
)