📄 mdimessageu.pas
字号:
unit MDIMessageU;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
CreateChild1: TMenuItem;
procedure CreateChild1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1; tcreateparams
implementation
{$R *.DFM}
{ Register the MDI Child Window Class }
function RegisterClass: Boolean;
var
WindowClass: TWndClass;
begin
{setup our new window class}
WindowClass.Style := CS_HREDRAW or CS_VREDRAW; {set the class styles}
WindowClass.lpfnWndProc := @DefMDIChildProc; {point to the default MDI child window procedure}
WindowClass.cbClsExtra := 0; {no extra class memory}
WindowClass.cbWndExtra := 0; {no extra window memory}
WindowClass.hInstance := hInstance; {the application instance}
WindowClass.hIcon := LoadIcon(0, IDI_WINLOGO); {load a predefined logo}
WindowClass.hCursor := LoadCursor(0, IDC_APPSTARTING); {load a predefined cursor}
WindowClass.hbrBackground := COLOR_WINDOW; {use a predefined color}
WindowClass.lpszMenuName := nil; {no menu}
WindowClass.lpszClassName := 'TestClass'; {the registered class name}
{now that we have our class set up, register it with the system}
Result := Windows.RegisterClass(WindowClass) <> 0;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
{register our child window class}
if not RegisterClass then
begin
ShowMessage('RegisterClass failed');
Exit;
end;
end;
procedure TForm1.CreateChild1Click(Sender: TObject);
var
ChildWnd: HWND;
MDICreate: TMDICreateStruct;
begin
{note that the main form has the FormStyle
property set to fsMDIForm}
{fill in the members of the MDICreate structure}
with MDICreate do
begin
szClass:='TestClass'; {our registered class name}
szTitle:='MDI Child window'; {caption bar test}
hOwner:=hInstance; {the application instance handle}
X:=CW_USEDEFAULT; {default horizontal position}
Y:=CW_USEDEFAULT; {default vertical position}
CX:=CW_USEDEFAULT; {default width}
CY:=CW_USEDEFAULT; {default height}
style:=WS_OVERLAPPEDWINDOW OR WS_VISIBLE; {standard, visible window}
lParam:=0; {no extra information}
end;
{now, create the MDI child window using the WM_MDICREATE message}
ChildWnd:=SendMessage(Form1.ClientHandle, WM_MDICREATE, 0, Longint(@MDICreate));
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -