Discussion:
Programmatically Click Button On ToolbarWindow32
(too old to reply)
aron bock
2005-06-20 06:10:57 UTC
Permalink
Hello,

Using C#, WinXP, I'm trying to programmatically click a toolbar button (if
that's what it's called) in a ToolbarWindow32 control. Specifically, in
Internet Explorer 6, I want to issue a SendMessage call that would click
File/Open.

I've been able to do this with plain menu items as in Notepad. For this I:
--get the applications menu, using GetMenu
--get the File menuitem, using GetSubMenu
--get the "Open" menuitem's ID, using GetMenuItemID
--issue SendMessage to the app, using the menu item ID from above

Thus far, here's what I have with ToolbarButton32:
--get IE's hWnd
--find the ToolbarWindow32 of interest, using EnumChildWindows
--get the "File" toolbutton, using SendMessage with TB_GETBUTTON; this gives
me its "command ID"

Now I don't see a function/message to get the "Open" toolbutton, which is a
sub-button of File.

Would somebody point out what I should be doing?

Thanx

--A
Christian ASTOR
2005-06-20 18:43:53 UTC
Permalink
Post by aron bock
Now I don't see a function/message to get the "Open" toolbutton, which is a
sub-button of File.
"Open" is a menu item (0x100)
aron bock
2005-06-21 01:38:25 UTC
Permalink
Christian,

Yes, I did realize that the "dropdown menu" displayed by ToolbarWindow32 is
actually just a popup menu. However, it doesn't seem to have a parent, and
I've no idea how to retrieve its hWnd.

Based on your response below, and using 0x100 as Open's menu item ID, I
issued SendMessage( hwndToolbar, WM_COMMAND, 0x100, 0), but that did
nothing. I repeated this using hwndIE in the above, and it still did
nothing. In all this I'm just thankful I haven't crashed IE or my OS!

(BTW, what is the 0x100 hex number you mention, and how did you find it?)

I wonder if you could point out the sequence of steps I should take in case
of ToolbarWindow32.

Thank you

--A
Post by Christian ASTOR
Post by aron bock
Now I don't see a function/message to get the "Open" toolbutton, which is
a sub-button of File.
"Open" is a menu item (0x100)
Christian ASTOR
2005-06-21 15:42:01 UTC
Permalink
Post by aron bock
I repeated this using hwndIE in the above, and it still did
nothing.

If I post it (PostMessage()), on "IEFrame" window class, it works for
me (IE 6, XP SP1)
aron bock
2005-06-22 06:14:59 UTC
Permalink
Christian,

This is the most promising thing I've heard yet ... but I'm unable to get it
to work (XPHome, IE6). Here's what I did:

--get IE handle
--post message PostMessage(hwndIE, WM_COMMAND, 0x100, 0);

I've confirmed that the IE handle is to IEFrame, and is correct, by checking
with Spy++.

I'm using C# (yes, kinda late in the day to mention this!), and have
declared PostMessage as

[DllImport("user32.dll")]
public static extern int PostMessage(IntPtr hWnd, uint wMsg, uint wParam,
uint lParam);

Do you see any obvious errors?

Also, how did you get the constant 0x100? And could you tell me how to get
IDs of other menuitems as well?

--A
Post by aron bock
Post by aron bock
I repeated this using hwndIE in the above, and it still did
nothing.
If I post it (PostMessage()), on "IEFrame" window class, it works for
me (IE 6, XP SP1)
Loading...