home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / LordLucifer / win32asm / files / win32asm.exe / Win32ASM / Win32Proto / W32PToolBar.asm < prev    next >
Encoding:
Assembly Source File  |  1997-11-10  |  5.5 KB  |  170 lines

  1.     Page 60,190
  2.     TITLE W32PToolBar - Windows 95 prototype - Toolbar handling.
  3.  
  4.                 .586
  5.                 .MODEL FLAT,STDCALL
  6.  
  7.                 .NOLISTMACRO
  8.                 .NOLIST
  9.  
  10. UniCode         = 0
  11.  
  12.                 INCLUDE INSTR32.MAC
  13.  
  14.                 INCLUDE WIN32INC.EQU
  15.                 INCLUDE WIN32RES.EQU
  16.                 INCLUDE WIN32.MAC
  17.  
  18.                 INCLUDE COMCTL32.EQU
  19.                 INCLUDE USER32.EQU
  20.  
  21.                 INCLUDE W32PROTO.EQU
  22.                 .LIST
  23.  
  24. ; External references.
  25.  
  26.                 EXTERN hInst:DWORD
  27.  
  28. ErrorBox        PROTO lpszErrorMsg:DWORD
  29.  
  30.                 PAGE
  31. ; ==================================================================
  32. ; Global Data section.
  33. ; ==================================================================
  34.  
  35.     .DATA
  36.  
  37. hWndTool DWORD 0                        ;Toolbar handle.
  38.  
  39.     .CODE
  40.  
  41. ; ==========================================================================
  42. ; Create the toolbar.
  43. ; On exit,
  44. ;   EAX undefined,
  45. ;   other registers unchanged.
  46. ; ==========================================================================
  47.  
  48.                 .CONST
  49.  
  50. ErrorToolB      BYTE 'Could not create toolbar',0
  51.                 ALIGN DWORD
  52.  
  53.                 .DATA
  54.  
  55. TB              TBBUTTON <0,ID_FILE_NEW,  TBSTATE_ENABLED,TBSTYLE_BUTTON,,0,0>
  56.                 TBBUTTON <1,ID_FILE_OPEN, TBSTATE_ENABLED,TBSTYLE_BUTTON,,0,0>
  57.                 TBBUTTON <2,ID_FILE_SAVE, TBSTATE_ENABLED,TBSTYLE_BUTTON,,0,0>
  58.                 TBBUTTON <0,0,            TBSTATE_ENABLED,TBSTYLE_SEP,   ,0,0>
  59.                 TBBUTTON <3,ID_EDIT_CUT,  TBSTATE_ENABLED,TBSTYLE_BUTTON,,0,0>
  60.                 TBBUTTON <4,ID_EDIT_COPY, TBSTATE_ENABLED,TBSTYLE_BUTTON,,0,0>
  61.                 TBBUTTON <5,ID_EDIT_PASTE,TBSTATE_ENABLED,TBSTYLE_BUTTON,,0,0>
  62.                 TBBUTTON <0,0,            TBSTATE_ENABLED,TBSTYLE_SEP,   ,0,0>
  63.                 TBBUTTON <6,ID_FILE_PRINT,TBSTATE_ENABLED,TBSTYLE_BUTTON,,0,0>
  64. TBB             TBBUTTON <7,ID_HELP_ABOUT,TBSTATE_ENABLED,TBSTYLE_BUTTON,,0,0>
  65.  
  66.                 ALIGN DWORD
  67.  
  68.     .CODE
  69.  
  70. TBCreate PROTO hWnd:DWORD
  71. TBCreate PROC PUBLIC hWnd:DWORD
  72.  
  73. ; now create the toolbar
  74.  
  75.                                         ;Window handle
  76.                                         ;toolbar style,
  77.                                         ;toolbar id,
  78.                                         ;number of bitmaps
  79.                                         ;our process handle,
  80.                                         ;resource id
  81.                                         ;address of button structures,
  82.                                         ;number of buttons (includes sep.)
  83.                                         ;button width
  84.                                         ;button height
  85.                                         ;bitmap width
  86.     INVOKE CreateToolbarEx,             ;bitmap height
  87.              hWnd,                       ;button structure size.
  88.              WS_CHILD or WS_BORDER or WS_VISIBLE or TBSTYLE_TOOLTIPS\
  89.               or CCS_ADJUSTABLE,
  90.              IDR_TOOLBAR,8,hInst,IDR_TOOLBAR,OFFSET TB,
  91.              10,16,15,16,15,(SIZEOF TBB)
  92.  
  93.     MOV hWndTool,EAX                    ;save the handle to toolbar
  94.  
  95.       .IF EAX==0                        ;CreateToolbarEx failed?
  96.       INVOKE ErrorBox,
  97.                OFFSET ErrorToolB        ;Give message.
  98.       SUB EAX,EAX                       ;Return null handle.
  99.       .ENDIF
  100.  
  101.     RET
  102.  
  103. TBCreate ENDP
  104.  
  105.  
  106. ; ==========================================================================
  107. ; Received a WM_SIZE message.
  108. ; Resize the window.
  109. ; ==========================================================================
  110.  
  111.  
  112. TBResize PROC PUBLIC
  113.  
  114.       .IF hWndTool != 0                 ;If there is a valid toolbar:
  115.         INVOKE SendMessage,             ;tell the toolbar to size itself
  116.                  hWndTool,
  117.                  TB_AUTOSIZE,
  118.                  0,
  119.                  0
  120.       .ENDIF
  121.     RET
  122.  
  123. TBResize ENDP
  124.  
  125.  
  126.  
  127. ; ==========================================================================
  128. ; Received a Notify message.
  129. ; The toolbar is asking for a tooltip message.
  130. ; We declared the help strings in the .RC file with the same ID as the menu
  131. ; commands we used for both the menu and the toolbar command messages,
  132. ; because the idFrom that Win gives us is actually the message ID that the
  133. ; tool button is associated to.
  134. ; ==========================================================================
  135.  
  136.                .CODE
  137.  
  138.  
  139. WinProc_WM_NOTIFY PROC PUBLIC,
  140.                     hWnd:DWORD,
  141.                     wMsg:DWORD,
  142.                     wParam:DWORD,
  143.                     lParam:DWORD
  144.  
  145.     MOV EBX,lParam                           ;Get pointer to NMHDR:
  146.       .IF ([EBX].NMHDR.code == TTN_NEEDTEXT) ;is Notification a TTN_NEEDTEXT
  147.                                              ;query?
  148.       MOV EAX,hInst                     ;Yes. get our proc instance,
  149.       MOV [EBX].TOOLTIPTEXT.hInst,EAX   ;get icon from our own instance.
  150.       MOV EAX,[EBX].NMHDR.idFrom        ;Get id of command requiring help,
  151.       MOV [EBX].TOOLTIPTEXT.lpszText,EAX;stuff in lpszText so Win displays it.
  152.       SUB EAX,EAX                       ;No error.
  153.  
  154.       .ELSE
  155.       INVOKE DefWindowProc,             ;Some other notify, pass to default.
  156.                hWnd,
  157.                wMsg,
  158.                wParam,
  159.                lParam
  160.       .ENDIF
  161.     RET
  162.  
  163.     UnusedParm hWnd
  164.     UnusedParm wMsg
  165.     UnusedParm wParam
  166.  
  167. WinProc_WM_NOTIFY ENDP
  168.  
  169.     END
  170.