Solved

Image on MDI parent form

Posted on 2000-04-19
2
294 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

803 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