moduse.c

来自「一本已经绝版的好书」· C语言 代码 · 共 91 行

C
91
字号
/************************************************************
Module name: ModUse.C
Notices: Copyright (c) 1995-1997 Jeffrey Richter
************************************************************/


#include "..\CmnHdr.H"                  /* See Appendix C. */
#include <windows.h>
#include <windowsx.h>
#include <tchar.h>
#include "Resource.H"
#include "..\Module\Module.H"


/////////////////////////////////////////////////////////////


UINT g_uMsgModCntChange = 0;


/////////////////////////////////////////////////////////////


BOOL Dlg_OnInitDialog (HWND hwnd, HWND hwndFocus,
   LPARAM lParam) {

   // Associate an icon with the dialog box.
   chSETDLGICONS(hwnd, IDI_MODUSE, IDI_MODUSE);

   // Force the static control to be initialized correctly.
   PostMessage(hwnd, g_uMsgModCntChange, 0, 0);
   return(TRUE);
}


/////////////////////////////////////////////////////////////


void Dlg_OnCommand (HWND hwnd, int id, HWND hwndCtl,
   UINT codeNotify) {

   switch (id) {
      case IDCANCEL:
         EndDialog(hwnd, id);
         break;
   }
}


/////////////////////////////////////////////////////////////


BOOL CALLBACK Dlg_Proc (HWND hwnd, UINT uMsg,
   WPARAM wParam, LPARAM lParam) {

   if (uMsg == g_uMsgModCntChange) {
      SetDlgItemInt(hwnd, IDC_USAGECOUNT,
         GetModuleUsage(), FALSE);
   }

   switch (uMsg) {
      chHANDLE_DLGMSG(hwnd, WM_INITDIALOG, Dlg_OnInitDialog);
      chHANDLE_DLGMSG(hwnd, WM_COMMAND, Dlg_OnCommand);
   }
   return(FALSE);
}


/////////////////////////////////////////////////////////////


int WINAPI _tWinMain (HINSTANCE hinstExe,
   HINSTANCE hinstPrev, LPTSTR pszCmdLine, int nCmdShow) {

   chWARNIFUNICODEUNDERWIN95();

   // Get the numeric value of the systemwide window message
   // used by the module to notify all top-level windows when
   // the module's usage count has changed.
   g_uMsgModCntChange =
      RegisterWindowMessage(__TEXT("MsgModUsgCntChange"));

   DialogBox(hinstExe, MAKEINTRESOURCE(IDD_MODUSE),
      NULL, Dlg_Proc);

   return(0);
}


//////////////////////// End Of File ////////////////////////

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?