Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.7 KiB

4 years ago
  1. //��������������������������������������������������������������������������Ŀ
  2. //� Includes �
  3. //����������������������������������������������������������������������������
  4. #include "setedit.h"
  5. #include "commctrl.h"
  6. #include "toolbar.h"
  7. #include "status.h" // for StatusLine & StatusLineReady
  8. TBBUTTON tbButtons[] = {
  9. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
  10. { 4, IDM_TOOLBARADD, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
  11. { 5, IDM_TOOLBARMODIFY, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
  12. { 6, IDM_TOOLBARDELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
  13. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
  14. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
  15. { 9, IDM_TOOLBAROPTIONS, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
  16. } ;
  17. #define TB_ENTRIES sizeof(tbButtons)/sizeof(tbButtons[0])
  18. BOOL CreateToolbarWnd (HWND hWnd)
  19. {
  20. hWndToolbar = CreateToolbarEx (hWnd,
  21. WS_CHILD | WS_BORDER | WS_VISIBLE,
  22. IDM_TOOLBARID,
  23. 10, // number of tools inside the bitmap
  24. hInstance,
  25. idBitmapToolbar, // bitmap resource ID (can't use MAKEINTRESOURCE)
  26. tbButtons,
  27. TB_ENTRIES,0,0,0,0,sizeof(TBBUTTON)) ;
  28. return (hWndToolbar ? TRUE : FALSE) ;
  29. } // ToolbarInitializeApplication
  30. void ToolbarEnableButton (HWND hWndTB, int iButtonNum, BOOL bEnable)
  31. {
  32. SendMessage (hWndTB, TB_ENABLEBUTTON, iButtonNum, (LONG)bEnable) ;
  33. } // ToolbarEnableButton
  34. void ToolbarDepressButton (HWND hWndTB, int iButtonNum, BOOL bDepress)
  35. {
  36. if (iButtonNum >= IDM_TOOLBARADD && iButtonNum <= IDM_TOOLBARBOOKMARK)
  37. {
  38. // these buttons are push button and will not stay down after
  39. // each hit
  40. SendMessage (hWndTB, TB_PRESSBUTTON, iButtonNum, (LONG)bDepress) ;
  41. }
  42. else
  43. {
  44. // for the four view buttons, have to use CHECKBUTTON so they
  45. // will stay down after selected.
  46. SendMessage (hWndTB, TB_CHECKBUTTON, iButtonNum, (LONG)bDepress) ;
  47. }
  48. } // ToolbarDepressButton
  49. void OnToolbarHit (WPARAM wParam, LPARAM lParam)
  50. {
  51. WORD ToolbarHit ;
  52. if (HIWORD(wParam) == TBN_ENDDRAG)
  53. {
  54. StatusLineReady (hWndStatus) ;
  55. }
  56. else if (HIWORD(wParam) == TBN_BEGINDRAG)
  57. {
  58. ToolbarHit = LOWORD (lParam) ;
  59. if (ToolbarHit >= IDM_TOOLBARADD &&
  60. ToolbarHit <= IDM_TOOLBARDELETE)
  61. {
  62. ToolbarHit -= IDM_TOOLBARADD ;
  63. ToolbarHit += IDM_EDITADDCHART ;
  64. }
  65. else if (ToolbarHit == IDM_TOOLBAROPTIONS)
  66. {
  67. ToolbarHit = IDM_OPTIONSCHART ;
  68. }
  69. StatusLine (hWndStatus, ToolbarHit) ;
  70. }
  71. } // OnToolBarHit