home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / sdktools / winnt / perfmon / bookmark.c < prev    next >
Text File  |  1993-05-14  |  3KB  |  114 lines

  1.  
  2. #include "perfmon.h"
  3. #include "bookmark.h"   // External declarations for this file
  4.  
  5. #include "log.h"        // for LogWriteBookmark
  6. #include "utils.h"      // for WindowCenter
  7.  
  8. #include "pmhelpid.h"   // Help IDs
  9.  
  10.  
  11.  
  12. void static OnInitDialog (HDLG hDlg)
  13.    {
  14.    dwCurrentDlgID = HC_PM_idDlgOptionBookMark ;
  15.    EditSetLimit (DialogControl (hDlg, IDD_BOOKMARKCOMMENT), 
  16.                  BookmarkCommentLen-1) ;
  17.    WindowCenter (hDlg) ;
  18.    }
  19.  
  20.  
  21. void static OnOK (HDLG hDlg)
  22.    {
  23.    TCHAR          szComment [BookmarkCommentLen + 1] ;
  24.  
  25.    DialogText (hDlg, IDD_BOOKMARKCOMMENT, szComment) ;
  26.    LogWriteBookmark (hWndLog, szComment) ;
  27.    EndDialog (hDlg, 1) ;
  28.    }
  29.  
  30.  
  31. //==========================================================================//
  32. //                             Exported Functions                           //
  33. //==========================================================================//
  34.  
  35.  
  36. int FAR WINAPI BookmarkDlgProc (HWND hDlg, 
  37.                                 unsigned iMessage, 
  38.                                 WPARAM wParam, 
  39.                                 LPARAM lParam)
  40.    {
  41.    BOOL           bHandled ;
  42.  
  43.    bHandled = TRUE ;
  44.    switch (iMessage)
  45.       {
  46.       case WM_INITDIALOG:
  47.          OnInitDialog (hDlg) ;
  48.          return  (TRUE) ;
  49.  
  50.       case WM_CLOSE:
  51.          dwCurrentDlgID = 0 ;
  52.          EndDialog (hDlg, 0) ;
  53.          break ;
  54.  
  55.       case WM_COMMAND:
  56.          switch(wParam)
  57.             {
  58.             case IDD_OK:
  59.                dwCurrentDlgID = 0 ;
  60.                OnOK (hDlg) ;
  61.                break ;
  62.  
  63.             case IDD_CANCEL:
  64.                dwCurrentDlgID = 0 ;
  65.                EndDialog (hDlg, 0) ;
  66.                break ;
  67.  
  68.             case IDD_BOOKMARKHELP:
  69.                CallWinHelp (dwCurrentDlgID) ;
  70.                break ;
  71.  
  72.             default:
  73.                bHandled = FALSE ;
  74.                break;
  75.             }
  76.          break;
  77.  
  78.  
  79.       default:
  80.             bHandled = FALSE ;
  81.          break ;            
  82.       }  // switch
  83.  
  84.    return (bHandled) ;
  85.    }  // BookmarkDlgProc
  86.  
  87.  
  88.  
  89.  
  90. BOOL AddBookmark (HWND hWndParent)
  91.    {  // AddBookmark
  92.    return (DialogBox (hInstance, idDlgAddBookmark, hWndParent,
  93.                        BookmarkDlgProc)) ;
  94.    }  // AddBookmark
  95.  
  96.  
  97. void BookmarkAppend (PPBOOKMARK ppBookmarkFirst, 
  98.                      PBOOKMARK pBookmarkNew)
  99.    {  // BookmarkAppend
  100.    PBOOKMARK      pBookmark ;
  101.  
  102.    if (!*ppBookmarkFirst)
  103.       *ppBookmarkFirst = pBookmarkNew ;
  104.    else  
  105.       {  // else
  106.       for (pBookmark = *ppBookmarkFirst ;
  107.            pBookmark->pBookmarkNext ;
  108.            pBookmark = pBookmark->pBookmarkNext)
  109.          /* nothing */ ;
  110.       pBookmark->pBookmarkNext = pBookmarkNew ;
  111.       }  // else
  112.    }  // BookmarkAppend
  113. 
  114.