掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
フォーム無しのコンソール・アプリで FormCloseQuery の処理をするには? (ID:21714)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
ぬぅー。Halbowさんの1章ですよー。 サンプル: F1で終了 終了時に終了するか聞く これで15,360Bです。 まだVCLを二個使ってますが、ここらがDelphiの限界値でしょうか? C++のほかのコンパイラを使えばもう少し小さくなるかもしれません。 てかDelphiの意味無いッスね。 program Project1; uses windows, messages; procedure WMCLOSE(hWindow:HWND); var i:Integer; begin if MessageBox(hWindow,'終わるよ','ミニ',MB_YESNO)= IDYES then DestroyWindow(hWindow); end; procedure WMHOTKEY(hWindow:HWND; WParam: WPARAM; LParam: LPARAM); begin if WParam=1 then SendMessage(hWindow,WM_CLOSE,0,0); end; procedure MainDestroy(hWindow: HWND); begin UnregisterHotKey(hWindow, 1); PostQuitMessage(0); end; //------------------------------------------------------------ // Main Window Procedure //------------------------------------------------------------ function MainWndProc(hWindow: HWND; Msg: UINT; WParam: WPARAM; LParam: LPARAM): LRESULT; stdcall; export; var ps: TPaintStruct; begin Result := 0; case Msg of WM_CLOSE : WMCLOSE(hWindow); WM_Hotkey : WMHOTKEY(hWindow,WParam,LParam); WM_DESTROY: MainDestroy(hWindow); else begin result := DefWindowProc( hWindow, Msg, wParam, lParam ); exit; end; end; end; //------------------------------------------------------------ // Main Procedure //------------------------------------------------------------ var wc: TWndClass; hWindow: HWND; Msg: TMsg; begin wc.lpszClassName := 'AppClass'; wc.lpfnWndProc := @MainWndProc; wc.style := CS_VREDRAW or CS_HREDRAW; wc.hInstance := hInstance; wc.hIcon := LoadIcon(0,IDI_APPLICATION); wc.hCursor := LoadCursor(0,IDC_ARROW); wc.hbrBackground := (COLOR_WINDOW+1); wc.lpszMenuName := nil; wc.cbClsExtra := 0; wc.cbWndExtra := 0; RegisterClass(wc); hWindow := CreateWindowEx(0,'AppClass','',0,0,0,0,0,0,0,hInstance,nil); RegisterHotKey(hWindow, 1, 0, VK_F1); //ShowWindow(hWindow,CmdShow); //UpDateWindow(hWindow); //---- Message Loop --------------------- while GetMessage(Msg, 0, 0, 0) do begin TranslateMessage(Msg); DispatchMessage(Msg); end; Halt(Msg.wParam); end.
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.