home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 December / PCWKCD1296.iso / vjplusb / activex / inetsdk / samples / msconf / cnftest / sbar.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-03  |  3.5 KB  |  142 lines

  1. /* ----------------------------------------------------------------------
  2.  
  3.     CNFTEST sample for Microsoft ActiveX Conferencing
  4.  
  5.     Unpublished work.
  6.     Copyright (c) 1996, Microsoft Corporation
  7.     All rights reserved.
  8.  
  9.     sbar.c - Status bar routines
  10.  
  11.  
  12. ---------------------------------------------------------------------- */
  13.  
  14. #include "main.h"
  15.  
  16.  
  17. /* M S G  N O T I F Y */
  18. /*----------------------------------------------------------------------------
  19.     %%Function: MsgNotify
  20.  
  21. ----------------------------------------------------------------------------*/
  22. LRESULT MsgNotify(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
  23. {
  24.     LPTOOLTIPTEXT lpToolTipText;
  25.     static char szBuffer[MAX_PATH];
  26.  
  27.     lpToolTipText = (LPTOOLTIPTEXT)lparam;
  28.     switch (lpToolTipText->hdr.code)
  29.         {
  30.     case TTN_NEEDTEXT:
  31.     {
  32.         int cb;
  33.  
  34.         // Try special toolbar version first
  35.         cb = LoadString(ghInst, lpToolTipText->hdr.idFrom - 10000,
  36.             szBuffer, sizeof(szBuffer));
  37.         if (cb == 0)
  38.         {
  39.             cb = LoadString(ghInst, lpToolTipText->hdr.idFrom,   // string ID == command ID
  40.                 szBuffer, sizeof(szBuffer));
  41.         }
  42.         if (cb == 0)
  43.         {
  44.             szBuffer[0] = '\0';
  45.         }
  46.  
  47.         lpToolTipText->lpszText = szBuffer;
  48.         break;
  49.     }
  50.     case TBN_QUERYINSERT:
  51.     case TBN_QUERYDELETE:
  52.         return 1;
  53.     case PSM_SETCURSEL:
  54.         return 1;
  55.     default:
  56.         break;
  57.         }
  58.  
  59.     return 0;
  60. }
  61.  
  62.  
  63.  
  64. /* F  C R E A T E  S B A R */
  65. /*----------------------------------------------------------------------------
  66.     %%Function: FCreateSbar
  67.  
  68.     Create the status bar.
  69.  
  70. ----------------------------------------------------------------------------*/
  71. BOOL FCreateSbar(void)
  72. {
  73.     ghwndSbar = CreateWindow(STATUSCLASSNAME, NULL,
  74.         WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP,
  75.         0, 0, 0, 0,
  76.         ghwndMain, (HMENU) IDW_SBAR, ghInst, NULL);
  77.  
  78.     return (ghwndSbar != NULL);
  79. }
  80.  
  81.  
  82.  
  83. /* U P D A T E  S T A T U S  B A R */
  84. /*----------------------------------------------------------------------------
  85.     %%Function: UpdateStatusBar
  86.  
  87.     Update the text for part of the status bar
  88.  
  89. ----------------------------------------------------------------------------*/
  90. void UpdateStatusBar(LPSTR lpsz, WORD wPart, WORD wFlags)
  91. {
  92.     SendMessage(ghwndSbar, SB_SETTEXT, wPart | wFlags, (LPARAM) lpsz);
  93. }
  94.  
  95.  
  96.  
  97. /* M S G  M E N U  S E L E C T */
  98. /*----------------------------------------------------------------------------
  99.     %%Function: MsgMenuSelect
  100.  
  101.     Change the status bar text to display the menu help.
  102.  
  103. ----------------------------------------------------------------------------*/
  104. LRESULT MsgMenuSelect(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
  105. {
  106.     static char szBuffer[MAX_PATH];
  107.     UINT   nStringID;
  108.     UINT   fuFlags = GET_WM_MENUSELECT_FLAGS(wparam, lparam) & 0xffff;
  109.     UINT   uCmd    = GET_WM_MENUSELECT_CMD(wparam, lparam);
  110.     HMENU  hMenu   = GET_WM_MENUSELECT_HMENU(wparam, lparam);
  111.  
  112.     szBuffer[0] = 0;
  113.     nStringID = 0;
  114.  
  115.     if (fuFlags == 0xffff && hMenu == NULL)     // Menu has been closed
  116.     {
  117.         return 0;
  118.     }
  119.     else if (fuFlags & MFT_SEPARATOR)           // Ignore separators
  120.     {
  121.         nStringID = 0;
  122.     }
  123.     else if (fuFlags & MF_POPUP)                // Popup menu
  124.     {
  125.         if (fuFlags & MF_SYSMENU)               // System menu
  126.             nStringID = IDS_SYSMENU;
  127.     }
  128.     else                                        // Must be a command item
  129.     {
  130.         nStringID = uCmd;               // String ID == Command ID
  131.     }
  132.  
  133.     // Load the string if we have an ID
  134.     if (nStringID != 0)
  135.         LoadString(ghInst, nStringID, szBuffer, sizeof(szBuffer));
  136.  
  137.     // Finally... send the string to the status bar
  138.     UpdateStatusBar(szBuffer, 0, 0);
  139.  
  140.     return 0;
  141. }
  142.