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. Customize a toolbar in win32

Customize a toolbar in win32

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++tutorialquestion
9 Posts 3 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.
  • W Offline
    W Offline
    Ward 0
    wrote on last edited by
    #1

    Anyone familiar with the TB_CUSTOMIZE message? I'm looking for an example in Win32 C++ code. Thanks in advance, Ward

    O P 2 Replies Last reply
    0
    • W Ward 0

      Anyone familiar with the TB_CUSTOMIZE message? I'm looking for an example in Win32 C++ code. Thanks in advance, Ward

      O Offline
      O Offline
      Owner drawn
      wrote on last edited by
      #2

      LRESULT MsgNotify(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
      {
      static UINT i=0;
      LPNMHDR lpnmhdr;

      lpnmhdr = (LPNMHDR)lparam;
      
      // The following code allows the toolbar to be customized. 
      // If you return FALSE the Customize Toolbar dialog flashes
      // and goes away.
      
      if (lpnmhdr->code == TBN\_QUERYINSERT || lpnmhdr->code ==
          TBN\_QUERYDELETE)
      {
       return TRUE;
      }
          
      if (lpnmhdr->code == TBN\_GETBUTTONINFO)
      {
          LPTBNOTIFY lpTbNotify = (LPTBNOTIFY)lparam;
          char  szBuffer \[20\];
         
      	// 20 = total number of buttons.
      	// tbButton and tbButtonNew send information about
      	// the other 12 buttons in tbButtonNew.
      	
          if (lpTbNotify->iItem < 12)    
          {                              
           lpTbNotify->tbButton = tbButtonNew\[lpTbNotify->iItem\];
      	 LoadString(hInst,
                      4000+ lpTbNotify->iItem,  
                      szBuffer, sizeof(szBuffer)/sizeof(szBuffer\[0\]));
           hr = StringCchCopy
                    (lpTbNotify->pszText, 
                            sizeof(lpTbNotify->pszText)
                            /sizeof(lpTbNotify->pszText\[0\]),
                            szBuffer );
                          if(SUCEEDED(hr))
                            {
                            lpTbNotify->cchText =     
                                 sizeof(szBuffer)/sizeof(szBuffer\[0\]);
                            }
                          else
                            {
                            TODO: Write error handler.
                            }
           return TRUE;
          }
       else
          return 0;
      }
      return 0;
      

      }

      Love Forgives--Love Gives--Jesus is Love :)

      --Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord

      W P 2 Replies Last reply
      0
      • O Owner drawn

        LRESULT MsgNotify(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
        {
        static UINT i=0;
        LPNMHDR lpnmhdr;

        lpnmhdr = (LPNMHDR)lparam;
        
        // The following code allows the toolbar to be customized. 
        // If you return FALSE the Customize Toolbar dialog flashes
        // and goes away.
        
        if (lpnmhdr->code == TBN\_QUERYINSERT || lpnmhdr->code ==
            TBN\_QUERYDELETE)
        {
         return TRUE;
        }
            
        if (lpnmhdr->code == TBN\_GETBUTTONINFO)
        {
            LPTBNOTIFY lpTbNotify = (LPTBNOTIFY)lparam;
            char  szBuffer \[20\];
           
        	// 20 = total number of buttons.
        	// tbButton and tbButtonNew send information about
        	// the other 12 buttons in tbButtonNew.
        	
            if (lpTbNotify->iItem < 12)    
            {                              
             lpTbNotify->tbButton = tbButtonNew\[lpTbNotify->iItem\];
        	 LoadString(hInst,
                        4000+ lpTbNotify->iItem,  
                        szBuffer, sizeof(szBuffer)/sizeof(szBuffer\[0\]));
             hr = StringCchCopy
                      (lpTbNotify->pszText, 
                              sizeof(lpTbNotify->pszText)
                              /sizeof(lpTbNotify->pszText\[0\]),
                              szBuffer );
                            if(SUCEEDED(hr))
                              {
                              lpTbNotify->cchText =     
                                   sizeof(szBuffer)/sizeof(szBuffer\[0\]);
                              }
                            else
                              {
                              TODO: Write error handler.
                              }
             return TRUE;
            }
         else
            return 0;
        }
        return 0;
        

        }

        Love Forgives--Love Gives--Jesus is Love :)

        --Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord

        W Offline
        W Offline
        Ward 0
        wrote on last edited by
        #3

        This was what I already found myself on the msdn site. But it is not a very complete example, is it? It is somewhat the only example I was able to find on the Internet. But thanks anyway, Ward

        O 1 Reply Last reply
        0
        • O Owner drawn

          LRESULT MsgNotify(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
          {
          static UINT i=0;
          LPNMHDR lpnmhdr;

          lpnmhdr = (LPNMHDR)lparam;
          
          // The following code allows the toolbar to be customized. 
          // If you return FALSE the Customize Toolbar dialog flashes
          // and goes away.
          
          if (lpnmhdr->code == TBN\_QUERYINSERT || lpnmhdr->code ==
              TBN\_QUERYDELETE)
          {
           return TRUE;
          }
              
          if (lpnmhdr->code == TBN\_GETBUTTONINFO)
          {
              LPTBNOTIFY lpTbNotify = (LPTBNOTIFY)lparam;
              char  szBuffer \[20\];
             
          	// 20 = total number of buttons.
          	// tbButton and tbButtonNew send information about
          	// the other 12 buttons in tbButtonNew.
          	
              if (lpTbNotify->iItem < 12)    
              {                              
               lpTbNotify->tbButton = tbButtonNew\[lpTbNotify->iItem\];
          	 LoadString(hInst,
                          4000+ lpTbNotify->iItem,  
                          szBuffer, sizeof(szBuffer)/sizeof(szBuffer\[0\]));
               hr = StringCchCopy
                        (lpTbNotify->pszText, 
                                sizeof(lpTbNotify->pszText)
                                /sizeof(lpTbNotify->pszText\[0\]),
                                szBuffer );
                              if(SUCEEDED(hr))
                                {
                                lpTbNotify->cchText =     
                                     sizeof(szBuffer)/sizeof(szBuffer\[0\]);
                                }
                              else
                                {
                                TODO: Write error handler.
                                }
               return TRUE;
              }
           else
              return 0;
          }
          return 0;
          

          }

          Love Forgives--Love Gives--Jesus is Love :)

          --Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord

          P Offline
          P Offline
          Prakash Nadar
          wrote on last edited by
          #4

          Where is TB_CUSTOMIZE event used or processed here?


          -Prakash

          W 1 Reply Last reply
          0
          • W Ward 0

            Anyone familiar with the TB_CUSTOMIZE message? I'm looking for an example in Win32 C++ code. Thanks in advance, Ward

            P Offline
            P Offline
            Prakash Nadar
            wrote on last edited by
            #5

            This is what i got after doing a brif search in google hope its useful TB_CUSTOMIZE ------------- Display the Customize dialog for a toolbar The standard windows customization dialog for toolbars can be displayed by sending the toolbar the TB_CUSTOMIZE message. SendMessage(hwndToolbar, TB_CUSTOMIZE, 0, 0); You must remember to handle the TBN_QUERYDELETE and TBN_QUERYINSERT notifications, and return non-zero for both of these. Without them, the customize dialog will appear very briefly and then vanish.


            -Prakash

            W 1 Reply Last reply
            0
            • W Ward 0

              This was what I already found myself on the msdn site. But it is not a very complete example, is it? It is somewhat the only example I was able to find on the Internet. But thanks anyway, Ward

              O Offline
              O Offline
              Owner drawn
              wrote on last edited by
              #6

              Yeah it is complete with the one that I didn't paste. Search in MSDN documentation for the other one. The search is titled "Using toolbar controls". It has got a comprehensive coverage of what you want. I just pasted the interesting(for me) part.

              Love Forgives--Love Gives--Jesus is Love :)

              --Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord

              W 1 Reply Last reply
              0
              • P Prakash Nadar

                Where is TB_CUSTOMIZE event used or processed here?


                -Prakash

                W Offline
                W Offline
                Ward 0
                wrote on last edited by
                #7

                TB_CUSTOMIZE is to be send to the toolbar itself. The toolbar then sends notifications to the sender of TB_CUSTOMIZE. When you properly return data on these notifications, a customize dialog pops up. But this last part is the trickiest. Ward

                1 Reply Last reply
                0
                • P Prakash Nadar

                  This is what i got after doing a brif search in google hope its useful TB_CUSTOMIZE ------------- Display the Customize dialog for a toolbar The standard windows customization dialog for toolbars can be displayed by sending the toolbar the TB_CUSTOMIZE message. SendMessage(hwndToolbar, TB_CUSTOMIZE, 0, 0); You must remember to handle the TBN_QUERYDELETE and TBN_QUERYINSERT notifications, and return non-zero for both of these. Without them, the customize dialog will appear very briefly and then vanish.


                  -Prakash

                  W Offline
                  W Offline
                  Ward 0
                  wrote on last edited by
                  #8

                  This I already found by myself. But thanks anyway for doing the trouble to do the search. Ward

                  1 Reply Last reply
                  0
                  • O Owner drawn

                    Yeah it is complete with the one that I didn't paste. Search in MSDN documentation for the other one. The search is titled "Using toolbar controls". It has got a comprehensive coverage of what you want. I just pasted the interesting(for me) part.

                    Love Forgives--Love Gives--Jesus is Love :)

                    --Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord

                    W Offline
                    W Offline
                    Ward 0
                    wrote on last edited by
                    #9

                    Ok, I will give it an in depth look Ward

                    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