Delphi7 API's MDI window creation

Source: Internet
Author: User

Continue to the previous section, we still create an MDI window with the project file. The code is as follows:

 ProgramMdiapp;usesWindows, Messages;varthemessage:tmsg; Framewindow,clientwindow,childwindow:hwnd;ConstIdchildwnd= -; //First MDI child window ID{$R *. RES}//callback functionfunctionFramewindowproc (Theframewindow:hwnd; Themessage,wparam,lparam:longint): Longint;stdcall;varclientstruct:tclientcreatestruct;begin   CaseThemessage ofwm_create:beginClientstruct.hwindowmenu:=0; Clientstruct.idfirstchild:=Idchildwnd; Clientwindow:= CreateWindowEx (0,                  'mdiclient',                  Nil, Ws_childorWs_clipchildrenorws_visible,0,                  0,                  0,                  0, Theframewindow,0, HINSTANCE, @ClientStruct); ifClientwindow =0  Then        beginMessageBox (0,'CreateWindow faild',Nil, MB_OK);        Exit; End; End; Wm_destroy:beginPostQuitMessage (0);    Exit; End; End; Result:=Defframeproc (theframewindow,clientwindow,themessage,wparam,lparam);End;//Register the main windowfunctionRegisterframeclass:boolean;varWindowclass:twndclass;beginWindowclass.style:=cs_hredraworCs_vredraw; Windowclass.lpfnwndproc:=@FrameWindowProc; Windowclass.cbclsextra:=0; Windowclass.cbwndextra:=0; Windowclass.hinstance:=hinstance; Windowclass.hicon:= LoadIcon (0, Idi_winlogo); Windowclass.hcursor:= LoadCursor (0, Idc_arrow); Windowclass.hbrbackground:=Color_window; Windowclass.lpszmenuname:=Nil; Windowclass.lpszclassname:='Frameclass'; Result:= Windows. RegisterClass (Windowclass) <>0;End;//Registering child windowsfunctionRegisterchildclass:boolean;varWindowclass:twndclass;beginWindowclass.style:= Cs_hredraworCs_vredraw; Windowclass.lpfnwndproc:=@DefMDICHildProc; Windowclass.cbclsextra:=0; Windowclass.cbwndextra:=0; Windowclass.hinstance:=hinstance; Windowclass.hicon:= LoadIcon (0, idi_application); Windowclass.hcursor:= LoadCursor (0, Idc_arrow); Windowclass.hbrbackground:=Color_window; Windowclass.lpszmenuname:=Nil; Windowclass.lpszclassname:='ChildClass'; Result:= Windows. RegisterClass (Windowclass) <>0;End;//start the main programbegin  if  notRegisterframeclass Then  beginMessageBox (0,'Registerframeclass faild',Nil, MB_OK);  Exit; End; FrameWindow:= CreateWindowEx (0,                              'Frameclass',                              'Frame Window', Ws_overlappedwindoworWs_clipchildren, Cw_usedefault,                              Cw_usedefault, Cw_usedefault, Cw_usedefault, 0,                              0, HINSTANCE,Nil); ifFrameWindow <>0  Then  beginShowWindow (Framewindow,sw_shownormal);  UpdateWindow (FrameWindow); End  Else  beginMessageBox (0,'Createframewindow failed',Nil, MB_OK);  Exit; End; if  notRegisterchildclass Then   beginMessageBox (0,'Registerchildclass failed',Nil, MB_OK);   Exit; End; ChildWindow:= Createmdiwindow ('ChildClass',                        'Child Window', Ws_visible, Cw_usedefault, Cw_usedefault,                        Cw_usedefault, Cw_usedefault, Clientwindow, HINSTANCE,0); ifChildWindow <>0  Then   beginShowWindow (Childwindow,sw_shownormal);   UpdateWindow (ChildWindow); End   Else   beginMessageBox (0,'Createchildwindow Falid',Nil, MB_OK);   Exit; End;  whileGetMessage (Themessage,0,0,0) Do   beginTranslateMessage (themessage);   DispatchMessage (themessage); End;End.

The effect is as follows:

Delphi7 API's MDI window creation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.