掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
フォームのサイズを変更するには? (ID:19501)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
お恥ずかしい まったく動きません。 >WM_MOUSEHOVER じゃなくて、TrackMouseEventのほうかな? これを参考に検索して、サンプルみたいなのがあったので 作ってみたのですが、(すみません。理解せず作ってます) やはり、まったく動きません。 どうすればよいのでしょうか? ちなみに以下ソースです。 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) private public end; var Form1: TForm1; LPTRACKMOUSEEVENT: tagTRACKMOUSEEVENT; implementation {$R *.dfm} procedure TrackMouseTimerProc(hWnd: HWND; uMsg: UINT; idEvent: UINT; dwTime: DWORD); var rect: TRect; pt: TPoint; begin GetClientRect(hWnd, rect); MapWindowPoints(hWnd, NULL, rect, 2); GetCursorPos(pt); if (not PtInRect(rect, pt) or (WindowFromPoint(pt) <> hWnd)) then begin if ( not KillTimer(hWnd,idEvent)) then begin // エラーのためタイマー停止 end; PostMessage(hWnd,WM_MOUSELEAVE,0,0); end; end; function TrackMouseEvent(ptme: PTRACKMOUSEEVENT): Boolean; begin if ( (ptme <> Nil) or (ptme.cbSize < sizeof(tagTRACKMOUSEEVENT)) ) then begin Result := False; Exit; end; if ( not IsWindow(ptme.hwndTrack) ) then begin Result := False; Exit; end; if ( (ptme.dwFlags and TME_LEAVE) = 0 ) then begin Result := False; Exit; end; Result := (SetTimer(ptme.hwndTrack, ptme.dwFlags, 100, @TrackMouseTimerProc) <> 0); end; var fInWindow: Boolean; fInMenu: Boolean; function MainWndProc(hWnd: HWND; uMsg: UINT; WParam: WPARAM; LParam: LPARAM): LRESULT; var tme: tagTRACKMOUSEEVENT; begin case uMsg of WM_CREATE: begin fInWindow := FALSE; fInMenu := FALSE; Result := 0; Exit; end; WM_MOUSEMOVE: begin if not fInWindow then begin fInWindow := TRUE; tme.cbSize := sizeof(tagTRACKMOUSEEVENT); tme.dwFlags := TME_LEAVE; tme.hwndTrack := hWnd; if TrackMouseEvent(@tme) then begin MessageBox(hWnd, 'TrackMouseEvent Failed', 'Mouse Leave', MB_OK); end; end; end; WM_MOUSELEAVE: begin fInWindow := FALSE; if not fInMenu then begin MessageBox(hWnd, 'Elvis has left the building', 'Mouse Leave', MB_OK); end; end; WM_ENTERMENULOOP: begin fInMenu := TRUE; end; WM_EXITMENULOOP: fInMenu := FALSE; else Result := DefWindowProc( hWnd, uMsg, wParam, lParam); Exit; end; Result := 0; end; end.
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.