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
Solved

Button stay down

Posted on 2001-07-04
5
631 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
  • 2
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
TheNeil earned 200 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 321
Multiple image collision 13 80
Dynamically Created Query 3 62
MS Access from Delphi 31 59
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

791 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