home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / sysmgmt / msi / custexe1 / custexe1.cpp next >
C/C++ Source or Header  |  1997-10-13  |  2KB  |  63 lines

  1. #pragma message("Custom Action Test EXE.  Copyright (c) 1997 Microsoft Corp.")
  2. #if 0  // makefile definitions, build with "nmake -f CustExe1.cpp"
  3. DESCRIPTION = Custom Action Test EXE
  4. MODULENAME  = CustExe1
  5. FILEVERSION = 1.0,0,0
  6. SUBSYSTEM = windows
  7. !include <MsiTool.Mak>
  8. !if 0  #nmake skips the rest of this file
  9. #endif // end of makefile definitions
  10.  
  11. #define WINDOWS_LEAN_AND_MEAN  // faster compile
  12. #include <windows.h>
  13. #include <tchar.h>   // define UNICODE=1 on nmake command line to build UNICODE
  14. #define IDD_TEST 1
  15. #ifndef RC_INVOKED   // start of CPP source code
  16.  
  17. BOOL CALLBACK DialogProc(HWND  hwndDlg, UINT uMsg, WPARAM wParam, LPARAM  lParam)
  18. {
  19.     switch (uMsg)
  20.     {
  21.     case WM_INITDIALOG: return TRUE; // indicate we did not set focus to the control
  22.     case WM_COMMAND:
  23.         switch (wParam)
  24.         {
  25.         case IDOK:     PostQuitMessage(0); return TRUE;
  26.         case IDCANCEL: PostQuitMessage(1); return TRUE;
  27.         }
  28.         return FALSE;
  29.     default: return FALSE;
  30.     };
  31. }
  32.  
  33. extern "C" int __stdcall _tWinMain(HINSTANCE hInst, HINSTANCE/*hPrev*/, TCHAR* szCmdLine, int/*show*/)
  34. {
  35.     if ((szCmdLine[0]=='-' || szCmdLine[0]=='/') && (szCmdLine[1]=='Q' || szCmdLine[1]=='q'))
  36.         return 0;
  37.     HWND hWnd = ::CreateDialog(hInst, MAKEINTRESOURCE(1), 0, (DLGPROC)DialogProc);
  38.     if (hWnd == 0)
  39.         return 2;
  40.     ::SetDlgItemText(hWnd, 8, szCmdLine);
  41. //    ::ShowWindow(hWnd, SW_SHOW); //!! why do we need this?
  42.     MSG msg;
  43.     while (::GetMessage(&msg, 0, 0, 0) == TRUE)
  44.         ::IsDialogMessage(hWnd, &msg);
  45.     ::DestroyWindow(hWnd);
  46.     return msg.wParam;
  47. }
  48.  
  49. #else // RC_INVOKED, end of source code, start of resources
  50. IDD_TEST DIALOG 150, 150, 160, 75
  51. STYLE DS_MODALFRAME | DS_NOIDLEMSG | WS_POPUP | WS_CAPTION | WS_VISIBLE
  52. CAPTION "Custom Action Test EXE"
  53. FONT 12, "Arial"
  54. {
  55.  LTEXT      "",         8,         20,  7, 120, 40
  56.  PUSHBUTTON "&Succeed", IDOK,      20, 50,  40, 16
  57.  PUSHBUTTON "&Fail",    IDCANCEL, 100, 50,  40, 16
  58. }
  59. #endif // RC_INVOKED
  60. #if 0 
  61. !endif // makefile terminator
  62. #endif
  63.