Where are the Toolbar button events?

Started by jcmatt, February 20, 2009, 07:34:35 PM

Previous topic - Next topic

jcmatt

Hi,

Are there any examples showing how to receive the events from toolbar buttons?  I have a nice toolbar on a nice rebar on my nice form but can't find the toolbar anywhere in the code.  Pretty sure it's either wm_notify or wm_command but I haven't a clue how to implement this.

Jim

TechSupport

You're getting close....   :)

The code goes in the WM_COMMAND message handler. I catch both the Menu and the ToolBar buttons there.

Here is some sample code. Basically a Form with a Menu and a ToolBar. This example shows how the File New, and File Open menu and toolbar buttons are handled the same way.


Function FORM1_WM_COMMAND ( _
                          hWndForm     As Dword, _  ' handle of Form
                          hWndControl  As Dword, _  ' handle of Control
                          wNotifyCode  As Long,  _  ' notification code
                          wID          As Long   _  ' item, control, or accelerator identifer
                          ) As Long

   Select Case wID
   
      Case IDC_FORM1_MNUFILENEW, IDC_FORM1_TOOLBAR1_FILENEW
         MsgBox "New selected"
     
      Case IDC_FORM1_MNUFILEOPEN, IDC_FORM1_TOOLBAR1_FILEOPEN
         MsgBox "Open selected"
         
   End Select
     
End Function


jcmatt