{"id":125,"date":"2007-05-12T14:40:38","date_gmt":"2007-05-12T12:40:38","guid":{"rendered":" http:\/\/www.nsonic.de\/blog\/2007\/05\/mdi-bitmap-on-mdi-background\/"},"modified":"2007-05-12T16:06:03","modified_gmt":"2007-05-12T14:06:03","slug":"mdi-bitmap-on-mdi-background","status":"publish","type":"post","link":"https:\/\/www.nsonic.de\/blog\/2007\/05\/mdi-bitmap-on-mdi-background\/","title":{"rendered":"MDI: Bitmap on MDI Background"},"content":{"rendered":"<p>Question and Answer Database<\/p>\n<p>FAQ176D.txt   Displaying a bitmap on the client area of an MDI parent form.<br \/>\nCategory   :Windows API<br \/>\nPlatform    :All<br \/>\nProduct    :All 32 bit  <\/p>\n<p><em>Question:<br \/>\nHow do I display a bitmap to the client area of an MDI parent<br \/>\nform?<br \/>\n<\/em><br \/>\nAnswer:<br \/>\nHere are the necessary steps to add wallpaper to a MDI parent<br \/>\nform:<\/p>\n<p>1.Create a new project<br \/>\n2.Set the form&#8217;s FormStyle to fsMDIForm<br \/>\n3.Drop an image on the form and select a bitmap into it.<br \/>\n4.Find the { Private Declarations } comment in the form&#8217;s<br \/>\n   definition and add these lines right after it:<\/p>\n<p>[code lang=&#8221;delphi&#8221;]    FClientInstance : TFarProc;<br \/>\n    FPrevClientProc : TFarProc;<br \/>\n    procedure ClientWndProc(var Message: TMessage);<br \/>\n[\/code]<\/p>\n<p>5.Find the &#8220;implementation&#8221; line and the {$R *.DFM} line that<br \/>\n   follows it. After that line, enter this code:<\/p>\n<p>[code lang=&#8221;delphi&#8221;]procedure TMainForm.ClientWndProc(var Message: TMessage);<br \/>\nvar<br \/>\n  Dc : hDC;<br \/>\n  Row : Integer;<br \/>\n  Col : Integer;<br \/>\nbegin<br \/>\n  with Message do<br \/>\n    case Msg of<br \/>\n      WM_ERASEBKGND:<br \/>\n      begin<br \/>\n        Dc := TWMEraseBkGnd(Message).Dc;<br \/>\n        for Row := 0 to ClientHeight div Image1.Picture.Height do<br \/>\n          for Col := 0 to ClientWidth div Image1.Picture.Width do<br \/>\n            BitBlt(Dc,<br \/>\n               Col * Image1.Picture.Width,<br \/>\n               Row * Image1.Picture.Height,<br \/>\n               Image1.Picture.Width,<br \/>\n               Image1.Picture.Height,<br \/>\n               Image1.Picture.Bitmap.Canvas.Handle,<br \/>\n               0,<br \/>\n               0,<br \/>\n               SRCCOPY);<br \/>\n          Result := 1;<br \/>\n      end;<br \/>\n      else<br \/>\n        Result := CallWindowProc(FPrevClientProc,<br \/>\n                                 ClientHandle,<br \/>\n                                 Msg,<br \/>\n                                 wParam,<br \/>\n                                 lParam);<br \/>\n  end;<br \/>\nend;<br \/>\n[\/code]<br \/>\n6. In the OnCreate method for the form, type the following lines<br \/>\nof code:<\/p>\n<p>[code lang=&#8221;delphi&#8221;]   FClientInstance := MakeObjectInstance(ClientWndProc);<br \/>\n   FPrevClientProc := Pointer(GetWindowLong(ClientHandle,<br \/>\n                              GWL_WNDPROC));<br \/>\n   SetWindowLong(ClientHandle,<br \/>\n                 GWL_WNDPROC, LongInt(FClientInstance));<br \/>\n[\/code]<br \/>\n7. Add a new form to your project and set its FormStyle property to<br \/>\nfsMDIChild.<\/p>\n<p>Now you have a working MDI project with &#8220;wallpaper&#8221; where the image<br \/>\nbitmap is tiled to cover the MDI form&#8217;s client area.<\/p>\n<p>7\/16\/98 4:31:28 PM<\/p>\n<p>Trademarks &#038; Copyright \u00a9 1998 INPRISE Corporation. Last modified on<br \/>\n8-December-1998. <\/p>\n<p>[tags]Delphi, Forms, Graphic[\/tags]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Question and Answer Database FAQ176D.txt Displaying a bitmap on the client area of an MDI parent form. Category :Windows API Platform :All Product&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[11],"tags":[75,100,101],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p71Tml-21","_links":{"self":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/125"}],"collection":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/comments?post=125"}],"version-history":[{"count":0,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/125\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/media?parent=125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/categories?post=125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/tags?post=125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}