unit Unit1;
interface
uses Windows,Messages ;
type TDialog =class(TObject)
Handle:THandle;
private
procedure WMCommand(var Message: TWMCommand); message WM_COMMAND;
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
public
procedure WndProc(var Message: TMessage);
procedure DefaultHandler(var Message); override;
end;
procedure WinMain;
var Dialog1:TDialog;
implementation
function DlgProc(hDlg: HWND; iMsg: UINT; wp: WPARAM; lp: LPARAM): LRESULT;stdcall;
var msg:TMessage;
begin
with msg do begin Msg :=iMsg; LParam:=lp ; WParam:=wp ; Result:=0 ; end;
Dialog1.WndProc(msg);
Result:=msg.Result;
end;
procedure WinMain;
var msg: TMsg;
begin
Dialog1:=TDialog.Create;
Dialog1.Handle := CreateDialog(hInstance,MAKEINTRESOURCE(1), 0, @DlgProc);
try
while GetMessage(msg, 0, 0, 0) do
begin
if (Dialog1.Handle = 0) or not IsDialogMessage(Dialog1.Handle, msg) then
begin
TranslateMessage(msg);
DispatchMessage(msg);
end;
end;
// CloseHandle(Dialog1.Handle);
finally
Dialog1.Free;
end;
end;
{ TDialog }
procedure TDialog.WndProc(var Message: TMessage);
begin
Dispatch(Message);
end;
procedure TDialog.WMCommand(var Message: TWMCommand);
begin
case Message.itemID of
101:begin end; //ここにプログラムを入れる
102:begin end;
IDCANCEL:PostMessage(Handle, WM_QUIT, 0, 0);
end;
end;
procedure TDialog.WMPaint(var Message: TWMPaint);begin end;
procedure TDialog.DefaultHandler(var Message);
begin with TMessage(Message) do Result:=0; end;
end.