|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
click on a menuHow can you click on a menu, virtually?(programatically speaking)
an API call? VB6, please... -- Rick If what way do you mean?
If its within your application than create a function that is called from the menu click event and call this from anywhere else you want the menu item code executed. -- Show quoteHide quoteChris Hanscom - Microsoft MVP (VB) Veign's Resource Center http://www.veign.com/vrc_main.asp Veign's Blog http://www.veign.com/blog -- "Rick" <R***@discussions.microsoft.com> wrote in message news:DBA44A00-BD88-48A8-AE0A-DD840A3EF513@microsoft.com... > How can you click on a menu, virtually?(programatically speaking) > an API call? > > VB6, please... > -- > Rick On Tue, 21 Mar 2006 11:13:28 -0800, Rick
<R***@discussions.microsoft.com> wrote: >How can you click on a menu, virtually?(programatically speaking) Usually by sending or posting (SendMessage, PostMessage) a WM_COMMAND>an API call? > >VB6, please... message with the menu item's ID in wParam to the menu's owner window. You can use the Spy++ tool to obtain the ID. The owner hwnd of course must be obtained at runtime. Note this assumes it's really a windows menu, for example like Notepad uses, and not some menu-like or toolbar dropdown control. Also it may or may not work with popup (context) menus depending on how the app's author chose to handle them. Ex: 'Declares... Public Const WM_COMMAND = &H111 Public Declare Function PostMessage Lib "user32" _ Alias "PostMessageA" _ (ByVal hWnd As Long, ByVal wMsg As Long, _ ByVal wParam As Long, lParam As Any) As Long Public Declare Function FindWindow Lib "user32" _ Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 'usage... 'simulate click on menu item with ID 6 Dim hwndOwner As Long 'find owner hwnd from it's caption text... hwndOwner = FindWindow(vbNullString, "caption text here") If hwndOwner <> 0 Then 'found 'post the msg... PostMessage hwndOwner, WM_COMMAND, 6, ByVal 0& End If -Tom MVP - Visual Basic (please post replies to the newsgroup) Maybe this is wierd, but I'm trying to hav e a popmenu but it shows at the
beginning but after I made a query(DAO) and the grid becomes populated (where I made the right button mouse click), it doesn't show the popupmenu. The menus are dynamically created. So, I resorted to use normal dynamic menus(not hidden) and I wanted to create a virtual click so the user could make the selection from the submenus. Weird? How can solve the first problem? any ideas? -- Show quoteHide quoteRick "Tom Esh" wrote: > On Tue, 21 Mar 2006 11:13:28 -0800, Rick > <R***@discussions.microsoft.com> wrote: > > >How can you click on a menu, virtually?(programatically speaking) > >an API call? > > > >VB6, please... > > Usually by sending or posting (SendMessage, PostMessage) a WM_COMMAND > message with the menu item's ID in wParam to the menu's owner window. > You can use the Spy++ tool to obtain the ID. The owner hwnd of course > must be obtained at runtime. > Note this assumes it's really a windows menu, for example like Notepad > uses, and not some menu-like or toolbar dropdown control. Also it may > or may not work with popup (context) menus depending on how the app's > author chose to handle them. > > Ex: > 'Declares... > Public Const WM_COMMAND = &H111 > Public Declare Function PostMessage Lib "user32" _ > Alias "PostMessageA" _ > (ByVal hWnd As Long, ByVal wMsg As Long, _ > ByVal wParam As Long, lParam As Any) As Long > Public Declare Function FindWindow Lib "user32" _ > Alias "FindWindowA" _ > (ByVal lpClassName As String, ByVal lpWindowName As String) As Long > > 'usage... > 'simulate click on menu item with ID 6 > Dim hwndOwner As Long > > 'find owner hwnd from it's caption text... > hwndOwner = FindWindow(vbNullString, "caption text here") > > If hwndOwner <> 0 Then 'found > 'post the msg... > PostMessage hwndOwner, WM_COMMAND, 6, ByVal 0& > End If > > > -Tom > MVP - Visual Basic > (please post replies to the newsgroup) > Sorry folks. I solved the problem.
For the ones interested: I created the menus right after the queries. (not on the mousedown event on the grid!). -- Show quoteHide quoteRick "Rick" wrote: > Maybe this is wierd, but I'm trying to hav e a popmenu but it shows at the > beginning > but after I made a query(DAO) and the grid becomes populated (where I made > the right button mouse click), it doesn't show the popupmenu. > > The menus are dynamically created. > So, I resorted to use normal dynamic menus(not hidden) and I wanted to > create a virtual click so the user could make the selection from the submenus. > > Weird? How can solve the first problem? any ideas? > > > > > -- > Rick > > > "Tom Esh" wrote: > > > On Tue, 21 Mar 2006 11:13:28 -0800, Rick > > <R***@discussions.microsoft.com> wrote: > > > > >How can you click on a menu, virtually?(programatically speaking) > > >an API call? > > > > > >VB6, please... > > > > Usually by sending or posting (SendMessage, PostMessage) a WM_COMMAND > > message with the menu item's ID in wParam to the menu's owner window. > > You can use the Spy++ tool to obtain the ID. The owner hwnd of course > > must be obtained at runtime. > > Note this assumes it's really a windows menu, for example like Notepad > > uses, and not some menu-like or toolbar dropdown control. Also it may > > or may not work with popup (context) menus depending on how the app's > > author chose to handle them. > > > > Ex: > > 'Declares... > > Public Const WM_COMMAND = &H111 > > Public Declare Function PostMessage Lib "user32" _ > > Alias "PostMessageA" _ > > (ByVal hWnd As Long, ByVal wMsg As Long, _ > > ByVal wParam As Long, lParam As Any) As Long > > Public Declare Function FindWindow Lib "user32" _ > > Alias "FindWindowA" _ > > (ByVal lpClassName As String, ByVal lpWindowName As String) As Long > > > > 'usage... > > 'simulate click on menu item with ID 6 > > Dim hwndOwner As Long > > > > 'find owner hwnd from it's caption text... > > hwndOwner = FindWindow(vbNullString, "caption text here") > > > > If hwndOwner <> 0 Then 'found > > 'post the msg... > > PostMessage hwndOwner, WM_COMMAND, 6, ByVal 0& > > End If > > > > > > -Tom > > MVP - Visual Basic > > (please post replies to the newsgroup) > >
Any known problems running VB6 application with Intel Centrino Duo
Windows or VB problem - Please help MMTimer, DirectSound, and For..Next Hidden treasures... vb6 and iso 8601 date format VBnet 2005? Access table grid component. error making function call with multiple parameters to dll Creating a date picker feature in VB 6 Runtime Error 339: MSWINSCK.ocx...With a Twist |
|||||||||||||||||||||||