Dialog Box

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Dialog Box as PDF for free.

More details

  • Words: 448
  • Pages: 5
//dialog box #include <windows.h> #include "resource.h" #include hmenu hmenu; lresult callback wndproc(hwnd,uint,wparam,lparam); bool callback dlgproc1(hwnd ,uint ,wparam ,lparam ); // dialog box procedure bool callback dlgproc(hwnd,uint,wparam,lparam); hwnd hdlgmodeless ; char arr[20][10]; hwnd hwnd; fstream file; int winapi winmain(hinstance hinst,hinstance hpinst, pstr szcmdline,int icmdshow) { static char appname[] = text ("hello"); msg msg; wndclass wndcls; wndcls.style = cs_hredraw | cs_vredraw; // window style wndcls.lpfnwndproc = wndproc; // window procedure name wndcls.cbclsextra = 0; // no of extra bytes to allocate following the window-class structure wndcls.cbwndextra = 0; // no of extra bytes to allocate following the window instance wndcls.hinstance = hinst; // handle to the instance that the window procedure of this class is within wndcls.hicon = loadicon(hinst,makeintresource(idi_icon1)); //handle to the class icon wndcls.hcursor= loadcursor(hinst,makeintresource(idc_cursor1)); //handle to the class cursor wndcls.hbrbackground = (hbrush) getstockobject(white_brush); //background wndcls.lpszmenuname = appname; //resource name of the class menu wndcls.lpszclassname = appname; //application name 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; }

lresult callback wndproc(hwnd hwnd,uint message,wparam wparam,lparam lparam) { static hinstance hinstance; static hicon hicon; static hwnd hwnd1,hwnd2; 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);

ws_visible |bs_pushbutton

hwnd2 = createwindow(text("button"),"ok",ws_child | ,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); } bool callback dlgproc(hwnd hdlg,uint message,wparam wparam,lparam lparam) { tchar buff[10],szbuffer[20]; hdc hdc; hdc=getdc(hwnd); switch(message) { 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;

} return false;

} break;

} 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;

} return false;

} break;

)

Related Documents

Dialog Box
November 2019 42
Dialog
June 2020 37
Dialog
November 2019 65
Box
November 2019 59
Box
November 2019 56