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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suppress rectangle around control that has focus.

Status
Not open for further replies.

VuurSnikkel

Programmer
Sep 8, 2003
16
NL
Hello again...


Let's say you've got an application that contains a couple of components. Every time you click on a certain component and it gets focus, a stippled focus rectangle will appear.

Of course I want to be able to "tab" through my components and be able to select them, but I would also like to suppress the display of the focus rectangle (it looks quite ugly around sliders for example). Any ideas on how to do it?


GRTZ and thanx in advance,

VuurSnikkel.
 
That's something that Windows does for you, so I assume it would take some heavy API stuff to get rid of it. Is it really that bad?
 
You could also set the TabStop attribute to False for those components you do not want focused, (the slider for example).
 
Windows API's from Delphi are no big deal at all. Just call them like any other functions.

The following is from the Windows API help. Note the part stating that DrawFocusRect is an XOR function. Therefore you can make it dissapear:

***************************************

BOOL DrawFocusRect( HDC hDC,
// handle to device context

CONST RECT *lprc
// pointer to structure for rectangle

);



Parameters
hDC
Identifies the device context.

lprc
Points to a RECT structure that specifies the logical coordinates of the rectangle.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks
Because DrawFocusRect is an XOR function, calling it a second time with the same rectangle removes the rectangle from the screen.

This function draws a rectangle that cannot be scrolled. To scroll an area containing a rectangle drawn by this function, call DrawFocusRect to remove the rectangle from the screen, scroll the area, and then call DrawFocusRect again to draw the rectangle in the new position.
 
'lo


Thanks, I already read something about the DrawFocusRect-function and that it draws in XOR-mode, but I didn't know for sure that it was this function that is responsible for drawing the focus rectangle around Windows controls that currently have focus (and whether or not it is possible to simply call this function a second time to get rid of the original focus rectangle). I'm going to try it now, thanks again.


GRTZ,

VuurSnikkel.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top