Solved

Image on MDI parent form

Posted on 2000-04-19
2
291 Views
Last Modified: 2010-04-04
I wanted do display Logo on center of MDI parent form, but when I start app, image is not visible on form. How to solve that?
0
Comment
Question by:siki
2 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 100 total points
ID: 2732696
hi,
this is a quite well known problem ,try
drop a TImage( with logo added ) on your mdi forms parent form and try this method to overcome the problem:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
   FClientInstance,
   FPrevClientProc : TFarProc;
  Procedure ClientWndProc(VAR Message: TMessage);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
PROCEDURE TForm1.ClientWndProc(VAR Message: TMessage);
VAR
  MyDC : hDC;
  Ro, Co : Word;
begin
  with Message do
case Msg of
 WM_ERASEBKGND:
   begin
    MyDC := TWMEraseBkGnd(Message).DC;
    FOR Ro := 0 TO ClientHeight DIV Image1.Picture.Height DO
    FOR Co := 0 TO ClientWIDTH DIV Image1.Picture.Width DO
    BitBlt(MyDC, Co*Image1.Picture.Width,Ro*Image1.Picture.Height,
    Image1.Picture.Width, Image1.Picture.Height,
    Image1.Picture.Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
    Result := 1;
   end;
    else
     Result := CallWindowProc(FPrevClientProc, ClientHandle, Msg, wParam, lParam);
    end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 FClientInstance := MakeObjectInstance(ClientWndProc);
 FPrevClientProc := Pointer(GetWindowLong(ClientHandle,GWL_WNDPROC));
 SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FClientInstance));
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
 SetWindowLong( ClientHandle, GWL_WNDPROC, longint(FPrevClientProc));
 FreeObjectInstance( FClientInstance);
end;

end.
0
 
LVL 3

Expert Comment

by:shenqw
ID: 2733180
var
  Bitmap:TBitmap;

procedure TMainForm.FormCreate(Sender: TObject);
begin
  Bitmap:=TBitmap.Create;
  Bitmap.LoadFromFile('c:\Yield.bmp');
  Self.Brush.Bitmap:=Bitmap;
end;

procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if Assigned(Bitmap) then FreeAndNil(Bitmap);
end;
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now