Painting a frame around a window..

forcedutopy
01-05-2005, 08:58 AM
Hi, im doing this program where the user can "select" windows and add them to a memory buffer, what i want is a way to trace a black or any color frame around the window so the user can see what has been selected!! any idea of how this could be done (the frame painting).

Im using GetAncestor to assure that there will always be a Window (form) that is selected, i guess i can check also to avoid getting the Desktop window. (its crazy but I can minimize all the windows, try minimize a EDIT, the TaskBar, even the Clock in the task bar) :D

GavinO
01-05-2005, 04:05 PM
Will the windows be moved during the selection process? If they might, it substantially complicates the techniques I can think of to 'highlight' windows as you suggest.

As for the actual framing, I would either create a borderless form filled with the frame color, and position it behind the form to highlight, sticking out a set distance around the edges, or draw directly to the desktop window with LineTo. The problem with either method is detecting when the windows are moved, and moving/redrawing your frame in the appropriate place.

One other option that I thought of, that might be simpler to implement, would be to use SetWindowText to add something to the titlebar of the selected forms.

forcedutopy
01-12-2005, 01:02 PM
well, doing highlight during the moving is better, but is not there a way to test whenever the mouse moves and if the mouse left button is pressed over the NonClient Area.

zelg37
01-12-2005, 08:15 PM
...is not there a way to test whenever the mouse moves and if the mouse left button is pressed over the NonClient Area.
Are you looking to access windows messages like:
WM_NCLBUTTONDOWN
WM_NCLBUTTONUP
WM_NCLBUTTONDBLCLK
WM_NCRBUTTONDOWN
WM_NCRBUTTONUP
WM_NCRBUTTONDBLCLK
WM_NCMBUTTONDOWN
WM_NCMBUTTONUP
WM_NCMBUTTONDBLCLK
WM_NCMOUSEMOVE

Have you tried searching for these terms?

Even though VB doesn't have in-built way to access non-client area mouse events, there are a number of ways to get access to these low level messages...

You can try subclassing:
http://www.vb-helper.com/howto_detect_border_click.html

Or use a spy control:
http://www.freevbcode.com/ShowCode.asp?ID=2546

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum