INDODELPHI

Blog’s Tutorial Delphi – Reference from Onez Delphi Explorer

SETTING UP THE MDI PARENT WINDOW CORRECTLY

// ******************************************************************
// SETTING UP THE MDI PARENT WINDOW CORRECTLY
// Category        : MDI
// Author          : Michael Burton
// Author Email    :
// Author Web      : http://www.rimrocksoftware.com/tips.html
// Tips Website    : Rimrock Software
// Tips Website URL: http://www.rimrocksoftware.com/tips.html
// ******************************************************************

{
Delphi does not set up the MDI parent window correctly. Use the following to set
the proper border for the MDI parent window.
}

SetWindowLong(ClientHandle, GWL_EXSTYLE, WS_EX_CLIENTEDGE);
SetWindowPos(ClientHandle, HWND_BOTTOM, 0,0,0,0,SWP_NOCOPYBITS);

// (From Russ Reese)

November 6, 2007 Posted by maulaku | Application - MDI | | No Comments Yet

CLOSE A MDICHILD FORM

// ******************************************************************
// CLOSE A MDICHILD FORM
// Category        : MDI
// Author          : Carlos Borrero
// Author Email    : cbarrer@elsitio.net.co
// Author Web      :
// Tips Website    : Swiss Delphi Center
// Tips Website URL: http://www.swissdelphicenter.ch
// ******************************************************************

unit Child;

// Have you noticed that when you try to close a MDIChild form
// the form minimizes but doesn’t disappear from your Main form
// client area?
//
// With this tip you can learn how to really close the MDI child
// form and free the memory occupied by the form

interface

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

type
TMDIChildForm = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;

var
MDIChildForm: TMDIChildForm;

implementation

{$R *.DFM}

procedure TMDIChildForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
// This line of code frees memory and closes the form
Action := caFree;
end;

end.

November 6, 2007 Posted by maulaku | Application - MDI | | No Comments Yet

CHANGE MDI PARENT BACKGROUND

// ******************************************************************
// CHANGE MDI PARENT BACKGROUND
// Category        : MDI
// Author          : Greatis Software
// Author Email    :
// Author Web      : www.greatissoftware.com
// Tips Website    : Greatis Software
// Tips Website URL: http://www.greatis.com/delphi/tips.html
// ******************************************************************

{
The decision consists in interception of the WM_ERASEBKGND, WM_VSCROLL and
WM_HSCROLL messages and is carried out draw of area with the DrawImage procedure
or InvalidateRect procedure.
In procedure CreateWnd is used SetWindowLong procedure for installation of new
procedure of a window.
Don’t forget to remove line
Application.CreateForm(TForm2, Form2) from project file and line
var Form2: TForm2 from unit2.pas file.
}

type
TForm1 = class(TForm)
//  …
private
{ Private declarations }
public
procedure ClientWndProc(var Message: TMessage);
procedure DrawImage;
{ Public declarations }
protected
procedure CreateWnd; override;
end;

var
Form1: TForm1;
NewClient, OldClient: TFarProc;
MyDC: hDC;

implementation

uses unit2;

{$R *.DFM}

procedure TForm1.CreateWnd;
begin
inherited CreateWnd;
NewClient:=MakeObjectInstance(ClientWndProc);
OldClient:=Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(NewClient));
end;

procedure TForm1.DrawImage;
{ This procedure tiles the image on the form’s client area }
var
i, j: Integer;
WndRect, ImageRect: TRect;
Rows, Cols: Integer;
begin
GetWindowRect(ClientHandle, WndRect);
ImageRect:=Image1.ClientRect;
Rows:=WndRect.Bottom div ImageRect.Bottom;
Cols:=WndRect.Right div ImageRect.Right;
with Image1 do
for i:=0 to Rows+1 do
for j:=0 to Cols+1  do
BitBlt(MyDC,j*Picture.Width,i*Picture.Height,Picture.Width,
Picture.Height,Picture.Bitmap.Canvas.Handle,0,0,SRCCOPY);
end;

procedure TForm1.ClientWndProc(var Message: TMessage);
begin
case Message.Msg of
WM_ERASEBKGND:
begin
CallWindowProc(
OldClient,
ClientHandle,
Message.Msg,
Message.wParam,
Message.lParam);
MyDC:=TWMEraseBkGnd(Message).DC;
DrawImage;
Message.Result:=1;
end;
WM_VSCROLL,WM_HSCROLL:
begin
Message.Result:=
CallWindowProc(
OldClient,
ClientHandle,
Message.Msg,
Message.wParam,
Message.lParam);
InvalidateRect(ClientHandle,nil,True);
end;
else
Message.Result:=
CallWindowProc(
OldClient,
ClientHandle,
Message.Msg,
Message.wParam,
Message.lParam);
end;
end;

October 28, 2007 Posted by maulaku | Application - MDI | | No Comments Yet