Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 Displaying a bitmap on the client area of an MDI parent form.


How do I display a bitmap to the client area of an MDI parent form?   

    Here are the necessary steps to add wallpaper to a MDI parent form:

    Create a new project
    Set the form's FormStyle to fsMDIForm
    Drop an image on the form and select a bitmap into it.
    Find the { Private Declarations } comment in the form's
       definition and add these lines right after it:
        FClientInstance : TFarProc;
        FPrevClientProc : TFarProc;
        procedure ClientWndProc(var Message: TMessage);
    Find the "implementation" line and the {$R *.DFM} line that follows it. After that line, enter this code:
    procedure TMainForm.ClientWndProc(var Message: TMessage);
    var
      Dc : hDC;
      Row : Integer;
      Col : Integer;
    begin
      with Message do
        case Msg of
          WM_ERASEBKGND:
          begin
            Dc := TWMEraseBkGnd(Message).Dc;
            for Row := 0 to ClientHeight div Image .Picture.Height do
              for Col := 0 to ClientWidth div Image .Picture.Width do
                BitBlt(Dc,
                   Col * Image .Picture.Width,
                   Row * Image .Picture.Height,
                   Image .Picture.Width,
                   Image .Picture.Height,
                   Image .Picture.Bitmap.Canvas.Handle,
                   0,
                   0,
                   SRCCOPY);
              Result :=  ;
          end;
          else
            Result := CallWindowProc(FPrevClientProc,
                                     ClientHandle,
                                     Msg,
                                     wParam,
                                     lParam);
      end;
    end;
    In the OnCreate method for the form, type the following lines of code:
       FClientInstance := MakeObjectInstance(ClientWndProc);
       FPrevClientProc := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
       SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FClientInstance));
    Add a new form to your project and set its FormStyle property to fsMDIChild.
    Now you have a working MDI project with "wallpaper" where the image bitmap is tiled to cover the MDI form's client area.
    

     



  << Previous Faq     Complete List     Next Faq >>  



 
 Hits/month  2,500,000+ 
 Downloads
 (Since May 2000)
 7,393,709 
 Total Files  6,023 
 Forum msgs  7,670 
 Articles/FAQs  70+/900+ 
Kylix
Tips n Tricks
FAQs
Knowledge Base
Bug Listings
Articles
Books
Newsgroups
Links
Submissions
Testimonials
Advertising
Contact Us
About Us
Search Amazon:
Top Selling Software at Amazon

| Home/News | Downloads | Forums | Resources | Info and Facts | Testimonials |
  Site Search:
 


Comments/Problems: Webmaster@delphi32.com
Copyright © 1998-2006, Delphi32.com. All rights reserved.
Terms of Use