📄 createmdiwindowu.pas
字号:
unit CreateMDIWindowU;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Menus;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
CreateChild1: TMenuItem;
procedure CreateChild1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
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.CreateChild1Click(Sender: TObject);
var
hWindow: HWND;
begin
{register our new class first}
if not RegisterClass then
begin
ShowMessage('RegisterClass failed');
Exit;
end;
{now, create a window based on our new class}
hWindow := CreateMDIWindow('TestClass', {the registered class name}
'API Window', {the title bar text}
WS_VISIBLE OR {the MDI child window is visible,}
WS_CAPTION OR {has a caption bar,}
WS_SYSMENU OR {a system menu,}
WS_MINIMIZEBOX OR {and minimize and}
WS_MAXIMIZEBOX, {maximize boxes}
CW_USEDEFAULT, {default horizontal position}
CW_USEDEFAULT, {default vertical position}
CW_USEDEFAULT, {default width}
CW_USEDEFAULT, {default height}
Form1.ClientHandle, {handle of the MDI client window}
hInstance, {the application instance}
0 {no additional information}
);
{if our window was created successfully, show it}
if hWindow <> 0 then
begin
ShowWindow(hWindow, SW_SHOWNORMAL);
UpdateWindow(hWindow);
end
else
begin
ShowMessage('CreateWindow failed');
Exit;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -