Solved

SetWindowsHookEx() question

Posted on 1997-10-12
11
530 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
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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 2

Accepted Solution

by:
mnguyen021997 earned 100 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now