Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stopping a 'Flat' button from raising when the mouse hovers over it?

Status
Not open for further replies.

CppDARREN

Programmer
Apr 18, 2007
3
GB
I have used a TSpeedButton on my application and set its flat property. However when the mouse hovers over it the button shows a border/raised edge to hilite itself. I have managed to draw over this rectangle with my own (background coloured) rectangle by intercepting the OnMouseMove event, but is there a better way to just turn this action off ? Or does anyone know whats responsible for creating this behaviour ?

Thanks.
 
So do you want in effect a button that doesn't behave like one ?

Can you not just use a TImage for a button and use the OnClick event. This way you should have no problem with it "popping up" etc



Hope this helps!

Regards

BuilderSpec
 
Thanks BuilderSpec that was a good point and worht considering, but the problem is that not only do I still need it to behave like a button, but I am also relying on alot of the other properties and methods of the TSpeedButton.

After further testing it is a problem that can be reproduced by lining up a lot of Speed buttons on a form and clicking away all over the place, and then sometimes a button is left with its raised (Im on!) border, even though the mouse is now over a different button or a different part of the screen. Odd eh -sounds like a MS or Borland bug at a guess. This behavior is then more frequent/noticeable when using a touchscreen display like my app will be.

Thanks again,

CppDarren
 
Would the following code have any effect :

SpeedButton1->Hide() ;
SpeedButton1->Flat = true;
SpeedButton1->Show() ;

Effectively make each button "refresh" ?


Hope this helps!

Regards

BuilderSpec
 
Thanks BuilderSpec,

-It didnt work, it would have been logical if it had, but strangely it didnt. I have ended up solving the problem by sending the last button a 'the mouse has left you' type reminder, incase its forgotten to unhighten itself. eg:

pLastSpeedButton->Perform( CM_MOUSELEAVE, 0, Longint(pLastSpeedButton));

Im sure there must be a simpler, commonsense method or a version of VCL that doesnt have the bug, but for now it seemed to fix it.

Cheers anyway,

CppDarren.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top