Link to home
Start Free TrialLog in
Avatar of CindyGraves
CindyGraves

asked on

Question on Setting Focus- Urgent!

I have a project where I am using a slider control from greentree, when I click or slide the slider up and down, a ugly focus appears on the slider- (dotted lines)  I tried looking into changing when a user clicks or slides the control it would send the focus to a button- but it still blinks once when the user first slides!   how can I do away with the ugly dotted lines?  Can I shut it off directly inside the form, How-  Your help would be awesome~!
Avatar of viktornet
viktornet
Flag of United States of America image

set the TabIndex property of slider to a value greater than the value of another control that has a TabIndex property... also set the TabStop property of the slider to False... that should do it...
Avatar of BeedleGuis
BeedleGuis

that does'nt work . . it still get's focus when a user clicks it, hence displaying the focus rect.  I hav'nt found a way yet, other than setting the forms backcolor to black . . but who would want to do that?
Avatar of CindyGraves

ASKER

That did not work, I even tried setting the form to black and still no success!
Here's a quick and dirty way to do it. Draw four text boxes on the form. Remove the text, set the border style to 0-none, the backcolour to your forms backcolour and set the tabstop to false. Move and size the boxes so that they cover the outer area of the slider (where the focus rectangle would be). Cheap, but it works :o)
I was j/k about that black form thing.  jgv's answer is a pain, but may be the only way.
There is a GDI function - DrawFocusRect - This will draw the focus rectangle normally done automatically by windows (and VB)  but this draw is an XOR operation such that calling it twice will remove the rectangle.

Such that if you call this directly and VB calls it intrinsically, effectively the focus rectangle will be removed.

It may be possible to call this function in the focus event and it may be fast enough to not cause a flicker - you would have to experiment - There is some work to do (a few api calls) in terms of getting the control's window rect and the device context for it. GetWindowRect and GetWindowDC respectively.

The question really comes down to whether there would be significant flicker associated with it.

ASKER CERTIFIED SOLUTION
Avatar of viktornet
viktornet
Flag of United States of America image

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
that was pretty low viktor...
hey, Beedle shitty... didn't I tell you already that you're my problem and stop messing around with me, eh? now get a life... i can do WHATEVER i want, and you're not the one who can stop me...