From: sjsobol@wariat.org (Steven J. Sobol)
Subject: Re: TPW 1.5 Controls and MDI Windows
Followup-To: comp.lang.c,comp.lang.pascal
Organization: APK Public Access Unix * Cleveland, OH
X-Newsreader: TIN [version 1.1 PL7]
Date: Wed, 6 Jan 1993 06:07:34 GMT

Carl Fago (CDF1@psuvm.psu.edu) wrote:
: Another TPW question...
: 
: Is there a method to put controls (Buttons and Icons) in the MDI client
: window?
: 
: I tried putting a simple pushbutton using the New (PButton...) function
: in the Init for the TMDIWindow but all I get is a button in its own
: MDI child window.
: 
: Any ideas?

Yes. I had a toolbar full of buttons and a status line that I wanted
to put in an MDI program that I was working on, and what I found out was
that the MDI window's client area must be adjusted so that it doesn't include
the area where your controls are. The client area is where all the MDI child
windows will show up.

I have source code for this, listed below. The Toolbar sits at the top of
the window and the status line is at the bottom.

This code is implemented in a response to the wm_Size message:

--------------------------
 
procedure TMDIFileWindow.WMSize(var Msg: TMessage);
var
	rcUpdate : TRect;
begin
  getUpdateRect(Hwindow,rcUpdate,False); {Save Update Rectangle for later}
 
  sendmessage(HWindow,wm_setredraw,0,0); {Disable Redrawing of window}
 
  TMDIWindow.WMSize(Msg);
 
  { Always check for nil window pointers and invalid HWindow handles.  Windows can
    send your main window WMSize messages while the child windows are being destroyed,
    which can produce some hard to track down UAEs.  }
 
 
 {This line adjusts the size of the client window so that the bottom
 of the client window touches the top of the status line, and the top of
 the client window touches the bottom of the toolbar. }
 
    if (ClientWnd <> nil) and (ClientWnd^.HWindow <> 0) then
      MoveWindow(ClientWnd^.HWindow, 0, ToolBarSize, Msg.LParamLo,
        Msg.LParamHi - ToolBarSize-StatusLineHeight, True);
 
 {These next two lines ensure that the toolbar and status line are
  in their correct position on the screen. }
 
    if (TheToolBar <> nil) and (TheToolBar^.HWindow <> 0) then
		MoveWindow(TheToolBar^.HWindow, -1, -1, Msg.LParamLo + 2,
                  ToolBarSize, True);
 
    if (StatusLine <> nil) and (StatusLine^.HWindow <> 0) then
    if Msg.LParamHi > 20 then
      MoveWindow(StatusLine^.HWindow, - 1, Msg.LParamHi - StatusLineHeight,
        Msg.LParamLo + 2, Msg.LParamHi, True);
 
  sendmessage(HWindow,wm_setredraw,1,0); {enable Redrawing of window}
  sendmessage(TheToolBar^.HWindow,wm_setredraw,1,0); {enable Redrawing of window}
  sendmessage(StatusLine^.HWindow,wm_setredraw,1,0); {enable Redrawing of window}
 
  InvalidateRect(HWindow,nil,True);
  InvalidateRect(TheToolBar^.HWindow,nil,True); {redraw Toolbar}
 
end;
 

Hope this helps. Feel free to e-mail me with any questions.
-- 
Steve Sobol   Head Cheerleader, APK Public Access *nix/Internet
(216) 481-9436 <2400 baud>     (216) 481-9425 <v.32bis, TurboPEP>
Telnet: wariat.org   To register: send e-mail to info@wariat.org, or
log in to BBS and download file 'user.new' from file area 2.

Also President of The Tiny Software Co.   E-Mail Address: sjsobol@tiny.com
Xref: sparky comp.lang.c:19553 comp.lang.c++:18968