?
Solved

SetWindowsHookEx() question

Posted on 1997-10-12
11
Medium Priority
?
566 Views
Last Modified: 2013-12-03
Hello.

I have written a program that uses a SetWindowsHookEx(WH_CALLWNDPROC) to set a hook that watches for WM_INITDIALOG messages and subclasses a dialog of another application.

Now, to minimize system impact, I'd like to use a SetWindowsHookEx(WH_CBT) hook and watch for HCBT_CREATEWND.

The problem is that this specific dialog has no title so I identify it by it's children (controls).  However, when HCBT_CREATEWND is processed, the children are not yet created so I cannot identify the correct dialog.

Any suggestions?
0
Comment
Question by:alexo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 3

Expert Comment

by:byang
ID: 1407318
use CreateDialogParam or DialogBoxParam and pass in some unique value for each window you create.
0
 
LVL 11

Author Comment

by:alexo
ID: 1407319
The question explicitly states that I subclass a dialog created by ANOTHER APPLICATION which I have no control over.
I have no idea what parameter is passed to this dialog, whether it is guaranteed to be unique or even if there is one at all.

0
 
LVL 7

Expert Comment

by:faster
ID: 1407320
Then can you just watch for the creation of it child control?  From the handle of the child you can get the window itself, is that too late for your application?
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 11

Author Comment

by:alexo
ID: 1407321
It's difficult.

Those contols are static text and buttons which can be present on other dialogs as well.  I don't know their order of creation so checking the others when one is created won't work.

0
 
LVL 11

Author Comment

by:alexo
ID: 1407322
Time to reopen the question
0
 
LVL 2

Accepted Solution

by:
mnguyen021997 earned 300 total points
ID: 1407323
are there no unique identifying features of this dialog.  use getclassname() & getclassinfo() & getwindowlong() to find out all the registration info for a window and try to match something unique (maybe dialog id?).  if the dialog is known to fire off by some command or menu maybe you'll need to filter the WM_COMMAND message.
0
 
LVL 11

Author Comment

by:alexo
ID: 1407324
No go.

The class is the general "dialog" class used by almost any dialog on the planet.

0
 
LVL 2

Expert Comment

by:mnguyen021997
ID: 1407325
how about the dialog id? use spy to figure out the dlg id then use getwindowlong( hDlg, GWL_ID ) to get the id of the dialog.  surely this is unique enough for you..
0
 
LVL 11

Author Comment

by:alexo
ID: 1407326
I was under the impression that the GWL_ID is application unique but not system-wide unique.  So it wouldn't work.
Am I wrong about it?  Can you point me to a document that says otherwise?


0
 
LVL 2

Expert Comment

by:mnguyen021997
ID: 1407327
gwl_id is unique to the dialog to the application but not globally unique.  however if you combine it with class, id, size, title, icon, whatever you should be able to find a fairly unique combination of things to identify this object.
0
 
LVL 11

Author Comment

by:alexo
ID: 1407328
Hmmm...  Seems about jusr right.

I can traverse the GWL_HWNDPARENT until I can uniquely identify the application and then check GWL_ID to identify the dialog.
Does it sound reasonable?

0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question