Thanks for responding.
I concur with your assessment of SendKeys. I only go this way when I have no
other option.
> 1. I assume I would get the handles for the various child windows and then
> use SendMessage or PostMessage?
Right. You must first get the handles of the windows you wish
to manipulate.
> 2. If so, which function would you suggest I use to get the child window
> handles?
> 3. I imagine I would pass the window captions to this function to get the
> handles?
You seem to like enumChildWindows. I prefer either:
- FindWindowEx, where you give the handle of the parent, plus
the class and caption of the child you want.
- GetDlgItem, where you pass the handle of the parent, and the
"ID" of the child to get the child handle. The "ID" is an
identifier of each child window, and is "usually" a unique
way of identifying the child window -- although there are
a few cases of "poorly programmed" apps with duplicate
child window id's.
> I spent a lot of time just finding out how to determine if the dialog was
> open. I ended up using EnumChildWindows. Dealing with child windows can be
> surprisingly difficult. That's why I'm asking.
If you are going to "get serious" about sending messages to
windows and/or child windows, you can save yourself a lot of
trouble, if you find and use some sort of spy utility. If you
have one of microsoft's compilers, you may have one installed
already. If not, then there are a number of utilities out there
both for sale and for free that will do "spying".
Some utilities will make a listing of all windows, and provide
their handles, class and caption, and other information such as
location and size (rectangle), and window "ID". Other utilities
have a "pointer" (some use a "gunsight" icon pointer), where you
move the pointer to the window and a "tool-tip-type" window pops
up, giving the info on that window. Actually, if you have plenty
of time to spare, you could write your own (I did), but I am
assuming you want to get on with your project.
The Microsoft spy program is called spy++. You can find other
spy programs at the various vb source code sites. For starters,
try planet source code:
http://www.planet-source-code.com/vb/default.asp
and enter "spy" in the search window. You are looking for
"windows spy" apps, rather than the "api spy" apps which tend
to show the messages flowing into a window.
Also, I should mention that I prefer the "laundry list" type
which lists EVERY window (visible or not), as opposed to the
"pointer type" spy app, which isn't much good for windows which
happen to be hidden (such as those windows which are switched
on and off when you go from tab-to-tab).
cheers, jw
mr_unreliable - 28 Apr 2007 17:10 GMT
Winspector - Ultimate Programmers Window Spy Utility:
http://www.windows-spy.com/
WinID is controls & windows identification utility:
http://winid.wwwdennisbabkincom.alienpicks.com/
Window Handle Picker application is a "Spy"-like tool that
will display the window handle, id, caption, class, etc:
http://www.codeguru.com/cpp/misc/samples/article.php/c1489/
and-so-on...
cheers, jw
Greg Wilson - 29 Apr 2007 06:30 GMT
Thanks again for your assistance.
> You seem to like enumChildWindows. I prefer either:
> - FindWindowEx, where you give the handle of the parent, plus
> the class and caption of the child you want.
I ended up using EnumChildWindows by default because I couldn't get
FindWindowEx to work. I just managed to do so today. I had to use the ByVal
declaration for the 3rd and 4th args. Not sure yet why but I won't argue with
success.
I downloaded the WinSpector program and am just now trying it out. Looks
very interesting.
I plan to do as you suggest: Send the info directly to the target windows
instead of tabing to them. I think it should speed up execution as well as
reliability. My eventual target is to:
1. Open the program (can do already).
2. Open the dialog.
3. Input the job number and make the other required selection.
4. Select the correct page (tab).
5. Then transfer all the data directly to the appropriate windows (edit
boxes).
The above will probably take awhile. I'm slow at this API stuff <sigh>.
Thanks again.
Greg
mr_unreliable - 30 Apr 2007 18:00 GMT
> I'm slow at this API stuff <sigh>.
Programming with api's can be tricky business,
and even the experts will "stub-their-toe"
occasionally.
As far as the "ByVal" parameters, if you get your
declarations from a reliable source, the "ByVal"
ought to be in the api definition, allowing the
compiler to take care of the calling arguments
for you.
You might start with the win32api.txt file from
Karl E. Peterson (albeit originally from microsoft),
look here:
http://vb.mvps.org/tools/
(Very) generally speaking, api-call parameters tend
to need ByVal, whereas the default for vb is ByRef.
cheers, jw