Re: How to Inherit a Keypress?
From: Bruce Roberts (ber_at_bounceitattcanada.xnet)
Date: 06/18/04
- Next message: Dave: "Restore previous app instance from system tray?"
- Previous message: Metal Dave: "Re: Do you have D8 ? Please help. Import Type Library Fails with .NET DLL "Invalid Name" (Strong Names?)"
- In reply to: Alistair George: "How to Inherit a Keypress?"
- Next in thread: Alistair George: "Re: How to Inherit a Keypress?"
- Reply: Alistair George: "Re: How to Inherit a Keypress?"
- Reply: Alistair George: "Re: How to Inherit a Keypress?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 18 Jun 2004 10:18:33 -0400
"Alistair George" <noemailadds@xtra.co.nz> wrote in message
news:40d238a3@news.orcon.net.nz...
> In the following code, if the user presses the Right-Mouse down, the
> mousedown
> re-enters despite putting variable:MBdownmsg (which is not a very
> satisfactory
> method.)
I have some difficulty with the logic in the routine.
Using Application.ProcessMessages is not something one wants to do in a
message handler. It really isn't. The call is likely at the root of your
reentrancy problem.
I also wonder why the routine uses GetCursorPos instead of the
MouseHookStruct pointed to by lParam.
IMO, Exit is overused in the routine and contributes somewhat to its poor
construction. You might want to consider a construction similar to that
shown below. IMO it more clearly expresses what is supposed to happen. (I'm
reasonably sure that this alternate construction accurately reflects the
logic you posted but I won't swear to it.)
function Balloon_Mouse_HookProc . . .
function doCommonCode : lResult;
begin
if Assigned (BalloonForm.OnClose)
then BalloonForm.Close
else BalloonForm.Release;
if not BalloonForm.tmrExit.Enabled
then begin
if Assigned (zBalloonControl.OnClick) and
(zBalloonControl.fShowMode = smDefault) and
(BalloonForm.lblClickHere.Visible) and
(PtInRect (BalloonForm.lblClickHere.BoundsRect,
BalloonForm.ScreenToClient (Mouse.CursorPos))
then begin
result := 0;
zBalloonControl.OnClick (zBalloonControl);
end
else result := 1;
end;
end;
. . .
begin
result := 0;
case wParam of
wm_RButtonDown : begin
if not MBDownMsg
then begin
MBDownMsg := True;
GetCursorPos (Pt); // why not lParam structure?
zBalloon.zBalloonControl.MouseDown (mbLeft, Shift, Pt.x, Pt.y);
end;
end;
wm_LButtonUp : begin
if BalloonForm.tmrExit.Enabled
then begin
MBDownMsg := False;
end
else result := doCommonCode;
end;
wm_LButtonDblClk,
wm_RButtonUp,
wm_RButtonDblClk,
wm_MButtonUp,
wm_MButtonDown : begin
result := doCommonCode;
end;
wm_MouseWheel,
wm_MouseMove : begin
if not BalloonForm.tmrExit.Enabled
then result := doCommonCode
else begin
if not (zBalloonControl.fShowMode in [smMessage, smError,
smWorning {sic}])
then result := CallNextHookEx (BalloonMouseHookHandle, Code,
wParam, lParam);
end;
end;
else begin
if (zBalloonControl.fShowMode in [smMessage, smError, smWorning
{sic}])
then result := doCommonCode
else result := CallNextHookEx (BalloonMouseHookHandle, Code, wParam,
lParam);
end;
end;
end;
- Next message: Dave: "Restore previous app instance from system tray?"
- Previous message: Metal Dave: "Re: Do you have D8 ? Please help. Import Type Library Fails with .NET DLL "Invalid Name" (Strong Names?)"
- In reply to: Alistair George: "How to Inherit a Keypress?"
- Next in thread: Alistair George: "Re: How to Inherit a Keypress?"
- Reply: Alistair George: "Re: How to Inherit a Keypress?"
- Reply: Alistair George: "Re: How to Inherit a Keypress?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|