Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to simulate clicks on toolbar buttons?

How to simulate clicks on toolbar buttons?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cyrus Dang
    wrote on last edited by
    #1

    Hi, I tried both TB_PRESSBUTTON and WM_LBUTTONDOWN, but I failed. Do you have any ideas to solve this problem? Thanks in advance.

    M 1 Reply Last reply
    0
    • C Cyrus Dang

      Hi, I tried both TB_PRESSBUTTON and WM_LBUTTONDOWN, but I failed. Do you have any ideas to solve this problem? Thanks in advance.

      M Offline
      M Offline
      Maximilien
      wrote on last edited by
      #2

      do you need a visual feedback ? Toolbar buttons are COMMANDS, so , you could ( never tried it ) do a SendMessage with the appropriate command ID.


      Maximilien Lincourt Your Head A Splode - Strong Bad

      realJSOPR C 2 Replies Last reply
      0
      • M Maximilien

        do you need a visual feedback ? Toolbar buttons are COMMANDS, so , you could ( never tried it ) do a SendMessage with the appropriate command ID.


        Maximilien Lincourt Your Head A Splode - Strong Bad

        realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote on last edited by
        #3

        I would do a PostMessage myself... ------- sig starts "I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

        M 1 Reply Last reply
        0
        • M Maximilien

          do you need a visual feedback ? Toolbar buttons are COMMANDS, so , you could ( never tried it ) do a SendMessage with the appropriate command ID.


          Maximilien Lincourt Your Head A Splode - Strong Bad

          C Offline
          C Offline
          Cyrus Dang
          wrote on last edited by
          #4

          Hi, I tried to send the WM_COMMAND to my toolbar, it worked. But it failed when I sent that message to the toolbar of the Open File Dialog (CFileDialog). Here is my code: hwndToolBar = ::FindWindowEx(hwndParent, NULL, _T("ToolbarWindow32"), NULL); ::SendMessage(hwndToolBar, WM_COMMAND, MAKEWPARAM((WORD)40961, CN_COMMAND), NULL); // 40961 is the ID of the "Up One Level" button. I didn't know why it failed. Please help me. What I need is programmatically clicking on the "Up One Level" button. Thanks in advance. -- modified at 14:39 Thursday 15th December, 2005

          N 1 Reply Last reply
          0
          • C Cyrus Dang

            Hi, I tried to send the WM_COMMAND to my toolbar, it worked. But it failed when I sent that message to the toolbar of the Open File Dialog (CFileDialog). Here is my code: hwndToolBar = ::FindWindowEx(hwndParent, NULL, _T("ToolbarWindow32"), NULL); ::SendMessage(hwndToolBar, WM_COMMAND, MAKEWPARAM((WORD)40961, CN_COMMAND), NULL); // 40961 is the ID of the "Up One Level" button. I didn't know why it failed. Please help me. What I need is programmatically clicking on the "Up One Level" button. Thanks in advance. -- modified at 14:39 Thursday 15th December, 2005

            N Offline
            N Offline
            Nish Nishant
            wrote on last edited by
            #5

            Are you sure the FindWindowEx returns an HWND? Perhaps it returns NULL.

            C 1 Reply Last reply
            0
            • realJSOPR realJSOP

              I would do a PostMessage myself... ------- sig starts "I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

              M Offline
              M Offline
              Maximilien
              wrote on last edited by
              #6

              yep, thanks.


              Maximilien Lincourt Your Head A Splode - Strong Bad

              1 Reply Last reply
              0
              • N Nish Nishant

                Are you sure the FindWindowEx returns an HWND? Perhaps it returns NULL.

                C Offline
                C Offline
                Cyrus Dang
                wrote on last edited by
                #7

                It works now. The problem is that when I send the message. It wouldn't work in WM_INITDIALOG and WM_NOTIFY (code CDN_INITDONE). It worked well in WM_NOTIFY (code CDN_SELCHANGE and probably others but I've not tested yet!) Thanks for helping.

                N 1 Reply Last reply
                0
                • C Cyrus Dang

                  It works now. The problem is that when I send the message. It wouldn't work in WM_INITDIALOG and WM_NOTIFY (code CDN_INITDONE). It worked well in WM_NOTIFY (code CDN_SELCHANGE and probably others but I've not tested yet!) Thanks for helping.

                  N Offline
                  N Offline
                  Nish Nishant
                  wrote on last edited by
                  #8

                  That's cool, but to be safe, you should always check if FindWindow(Ex) succeeds before using the HWND.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups