home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19292 < prev    next >
Encoding:
Internet Message Format  |  1993-01-12  |  3.4 KB

  1. Xref: sparky comp.lang.c:19292 comp.lang.pascal:7889
  2. Newsgroups: comp.lang.c,comp.lang.pascal
  3. Path: sparky!uunet!gatech!usenet.ins.cwru.edu!wariat!sjsobol
  4. From: sjsobol@wariat.org (Steven J. Sobol)
  5. Subject: Re: TPW 1.5 Controls and MDI Windows
  6. Message-ID: <1993Jan6.060734.15959@wariat.org>
  7. Followup-To: comp.lang.c,comp.lang.pascal
  8. Organization: APK Public Access Unix * Cleveland, OH
  9. X-Newsreader: TIN [version 1.1 PL7]
  10. References: <93004.212753CDF1@psuvm.psu.edu>
  11. Date: Wed, 6 Jan 1993 06:07:34 GMT
  12. Lines: 78
  13.  
  14. Carl Fago (CDF1@psuvm.psu.edu) wrote:
  15. : Another TPW question...
  16. : Is there a method to put controls (Buttons and Icons) in the MDI client
  17. : window?
  18. : I tried putting a simple pushbutton using the New (PButton...) function
  19. : in the Init for the TMDIWindow but all I get is a button in its own
  20. : MDI child window.
  21. : Any ideas?
  22.  
  23. Yes. I had a toolbar full of buttons and a status line that I wanted
  24. to put in an MDI program that I was working on, and what I found out was
  25. that the MDI window's client area must be adjusted so that it doesn't include
  26. the area where your controls are. The client area is where all the MDI child
  27. windows will show up.
  28.  
  29. I have source code for this, listed below. The Toolbar sits at the top of
  30. the window and the status line is at the bottom.
  31.  
  32. This code is implemented in a response to the wm_Size message:
  33.  
  34. --------------------------
  35.  
  36. procedure TMDIFileWindow.WMSize(var Msg: TMessage);
  37. var
  38.     rcUpdate : TRect;
  39. begin
  40.   getUpdateRect(Hwindow,rcUpdate,False); {Save Update Rectangle for later}
  41.  
  42.   sendmessage(HWindow,wm_setredraw,0,0); {Disable Redrawing of window}
  43.  
  44.   TMDIWindow.WMSize(Msg);
  45.  
  46.   { Always check for nil window pointers and invalid HWindow handles.  Windows can
  47.     send your main window WMSize messages while the child windows are being destroyed,
  48.     which can produce some hard to track down UAEs.  }
  49.  
  50.  
  51.  {This line adjusts the size of the client window so that the bottom
  52.  of the client window touches the top of the status line, and the top of
  53.  the client window touches the bottom of the toolbar. }
  54.  
  55.     if (ClientWnd <> nil) and (ClientWnd^.HWindow <> 0) then
  56.       MoveWindow(ClientWnd^.HWindow, 0, ToolBarSize, Msg.LParamLo,
  57.         Msg.LParamHi - ToolBarSize-StatusLineHeight, True);
  58.  
  59.  {These next two lines ensure that the toolbar and status line are
  60.   in their correct position on the screen. }
  61.  
  62.     if (TheToolBar <> nil) and (TheToolBar^.HWindow <> 0) then
  63.         MoveWindow(TheToolBar^.HWindow, -1, -1, Msg.LParamLo + 2,
  64.                   ToolBarSize, True);
  65.  
  66.     if (StatusLine <> nil) and (StatusLine^.HWindow <> 0) then
  67.     if Msg.LParamHi > 20 then
  68.       MoveWindow(StatusLine^.HWindow, - 1, Msg.LParamHi - StatusLineHeight,
  69.         Msg.LParamLo + 2, Msg.LParamHi, True);
  70.  
  71.   sendmessage(HWindow,wm_setredraw,1,0); {enable Redrawing of window}
  72.   sendmessage(TheToolBar^.HWindow,wm_setredraw,1,0); {enable Redrawing of window}
  73.   sendmessage(StatusLine^.HWindow,wm_setredraw,1,0); {enable Redrawing of window}
  74.  
  75.   InvalidateRect(HWindow,nil,True);
  76.   InvalidateRect(TheToolBar^.HWindow,nil,True); {redraw Toolbar}
  77.  
  78. end;
  79.  
  80.  
  81. Hope this helps. Feel free to e-mail me with any questions.
  82. -- 
  83. Steve Sobol   Head Cheerleader, APK Public Access *nix/Internet
  84. (216) 481-9436 <2400 baud>     (216) 481-9425 <v.32bis, TurboPEP>
  85. Telnet: wariat.org   To register: send e-mail to info@wariat.org, or
  86. log in to BBS and download file 'user.new' from file area 2.
  87.  
  88. Also President of The Tiny Software Co.   E-Mail Address: sjsobol@tiny.com
  89.