Link to home
Start Free TrialLog in
Avatar of SkyHook
SkyHook

asked on

Button stay down

Hi experts. I have a speedbutton on a form and when I click it I want as popupmenu to appear. Ive got that worked out but the button stays down even though I specifically sets its down property to be false. I've tried stepping through the code with a wtach on and according to that it never gets set to down. The button is not part of a group (groupindex is 0) and the allowallup property is set to true. The code Im using is this

procedure TForm1.btnCalcStatsMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  popctatscalc.popup(mouse.cursorpos.x-x,
                     mouse.cursorpos.y-y+ btncalcctats.height);
end;

Hopefully someone will be able to solve this as its been driving me mad for days

Del
ASKER CERTIFIED SOLUTION
Avatar of TheNeil
TheNeil

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Madshi
Madshi

I have an ideas, but it's not too nice:

Add a message handler to your form like this:

type
  TYourForm = class...
    ...
  private
    procedure DoPopup(var Message: TMessage); message WM_USER + 777;
  end;

procedure TYourForm.DoPopup(var Message: TMessage);
begin
  popctatscalc.popup(mouse.cursorpos.x-Message.wParam,
                     mouse.cursorpos.y-Message.lParam+btnclcctats.height);
end;

Then in your MouseDown method do this:

procedure TForm1.btnCalcStatsMouseDown(Sender: TObject;
 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  PostMessage(handle, WM_USER + 777, x, y);
end;

Hopefully this will fix the problem. It's not nice, but I think it should work.

Regards, Madshi.
Ha, The Neil was faster than me...   (-:
Avatar of SkyHook

ASKER

TheNeil,

Well I dont know why but that seems to work. Thank you

Del
Thanks Del - Glad to be of help.

Sorry Madshi (he he he) but this is one of those annoying little bug-ettes that Windows throws up every now and then (I was guessing on the missing message but it seems to answer the problem)

The Neil =:)