[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Button stay down

Posted on 2001-07-04
5
Medium Priority
?
645 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:SkyHook
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
TheNeil earned 800 total points
ID: 6253038
This is more of a nuance than a bug but I've come across it in the past (and it sent me half mad too before I solved it). The problem isn't the code that you're calling but the point that you're calling it from. When you call it on the MouseDown then I'm thinking that creating the popup menu somehow gets Windows confused and it fails to send a mouseup message to the button. As the button never gets the 'mouseup' message it stays down BUT (and this is the killer) it's Down property remains FALSE as it's only down due to the mouse click. Well that's how I see it anyway.

The solution (at last) is simply to move the code into the MouseUp event (simple ehh?)

The Neil =:)
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6253047
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.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6253051
Ha, The Neil was faster than me...   (-:
0
 

Author Comment

by:SkyHook
ID: 6253053
TheNeil,

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

Del
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 6253070
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 =:)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question