Board index » cppbuilder » Detect double click on open desktop

Detect double click on open desktop


2005-08-24 09:05:53 PM
cppbuilder3
Is it possible to detect where on the open desktop a user double
clicks and if there is NO Icon under it?
I think there is some sort of list of desktop items, but I also need
to know their parameters (Top Left, Bottom Right of associated Icon
AREA) To make sure I am in the clear when I double click.
I wish to do something when the user double clicks on a clear area of
the desktop, but do nothing when they activate a valid icon.
I know this is a relatively simple one for all you experienced
windows programmers, but any kind of example would be appreciated.
Thanks
Dekaya
 
 

Re:Detect double click on open desktop

Desktop has a handle of 0 (GetDC() == 0). You can install hooks to capture
events.
 

Re:Detect double click on open desktop

"tinyabs" < XXXX@XXXXX.COM >wrote in message
Quote
Desktop has a handle of 0
No, it does not. It has its own handle like any other window. The Win32
API has a GetDesktopWindow() function to retreive that handle.
Quote
(GetDC() == 0).
That is a Device Context (aka canvas), not a window handle.
Gambit
 

{smallsort}

Re:Detect double click on open desktop

< XXXX@XXXXX.COM >wrote in message
Quote
Is it possible to detect where on the open desktop a
user double clicks and if there is NO Icon under it?
You need to use a global mouse hook via SetWindowsHookEx() in order to do
that. Global hooks must be placed in a DLL. The hook can use
WindowFromPoint() to detect when the mouse is not over any window other than
the Desktop. Using the GetDestktopWindow() function to get the Desktop's
window handle, you can then issue standard ListView messages to it in order
to get the hit-test and icon information as needed.
Gambit
 

Re:Detect double click on open desktop

Sorry my mistake. What window has handle (0)?
 

Re:Detect double click on open desktop

"tinyabs" < XXXX@XXXXX.COM >wrote in message
Quote
What window has handle (0)?
None. 0 is the same as a NULL handle, ie no window at all.
Gambit
 

Re:Detect double click on open desktop

Found this in MSDN. GetDC(0) is a special case.
HDC GetDC(HWND hWnd );
hWnd
[in] Handle to the window whose DC is to be retrieved. If this value is
NULL, GetDC retrieves the DC for the entire screen.
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"tinyabs" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>What window has handle (0)?

None. 0 is the same as a NULL handle, ie no window at all.


Gambit