Solved

Image on MDI parent form

Posted on 2000-04-19
2
297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

631 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