home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 December / PCWKCD1296.iso / vjplusb / activex / inetsdk / samples / wininet / asyncftp / capp.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-04  |  3.3 KB  |  139 lines

  1. // File name: capp.cpp
  2. //
  3. //    Implementation file for the CApp Class
  4. //
  5. // Functions:
  6. //    See capp.h for a list of member functions.
  7. //
  8. // Copyright (c) 1996 Microsoft Corporation. All rights reserved.
  9. //**********************************************************************
  10. #include <windows.h>
  11. #include <commctrl.h>
  12. #include <wininet.h>
  13.  
  14. #include "comctlhd.h"
  15. #include "cdlgopt.h"
  16. #include "cdlg.h"
  17. #include "capp.h"
  18. #include "resource.h"
  19.  
  20.  
  21. CApp FAR * lpCApp;
  22.  
  23.  
  24. //**********************************************************************
  25. // WinMain
  26. //
  27. // Purpose: Program entry point
  28. //
  29. // Parameters:
  30. //      HANDLE hInstance        - Instance handle for this instance
  31. //      HANDLE hPrevInstance    - Instance handle for the last instance
  32. //      LPSTR lpCmdLine         - Pointer to the command line
  33. //      int nCmdShow            - Window State
  34. //
  35. // Return Value: msg.wParam
  36. //********************************************************************
  37. int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
  38.  
  39. {
  40.     MSG msg;          
  41.  
  42.     // Create new instance of our application object
  43.     lpCApp = new CApp(hInstance,hPrevInstance,nCmdShow);
  44.  
  45.     if (lpCApp == NULL)
  46.         return FALSE;
  47.  
  48.     if (!lpCApp->InitInstance())
  49.         return FALSE;
  50.  
  51.  
  52.     // message loop
  53.     while (GetMessage(&msg, NULL, 0, 0))
  54.     {
  55.         //should the message be passed on to the dialog
  56.         if (lpCApp->GetHWND() == 0 || !IsDialogMessage(lpCApp->GetHWND(), &msg))
  57.         {
  58.         TranslateMessage(&msg);    /* Translates virtual key codes           */
  59.         DispatchMessage(&msg);     /* Dispatches message to window           */
  60.         }
  61.     }
  62.  
  63.  
  64.     // Delete our app object
  65.     delete lpCApp ;
  66.  
  67.     return (msg.wParam);           /* Returns the value from PostQuitMessage */
  68. }
  69.  
  70.  
  71.  
  72.  
  73. //**********************************************************************
  74. //
  75. //CApp::CApp
  76. //
  77. // Purpose: Destructor for CApp class
  78. //
  79. //Parameters:
  80. //  hInst           HINSTANCE from WinMain
  81. //  hPrevInst       HINSTANCE from WinMain
  82. //  nCmdShow        int from WInMain
  83. //
  84. //**********************************************************************
  85.  
  86.  
  87.  
  88. CApp::CApp(HINSTANCE hInst, HINSTANCE hPrevInst, UINT nCmdShow)
  89. {
  90.     // Initialize member variables
  91.     m_hInst = hInst;
  92.     m_hInstPrev = hPrevInst;
  93.     m_nCmdShow = nCmdShow;
  94.  
  95.     m_hWnd = NULL;
  96.     m_pCDlgOpt = new CDlgOpt();
  97.  
  98. }
  99.  
  100. //**********************************************************************
  101. // CApp::~CApp
  102. //
  103. // Purpose: Destructor for CApp class
  104. //**********************************************************************
  105.  
  106. CApp::~CApp()
  107. {
  108.     delete m_pCDlg;
  109.     delete m_pCDlgOpt;
  110.     return;
  111. }
  112.  
  113.  
  114.  
  115. //**********************************************************************
  116. // CApp::InitInstance
  117. //
  118. // Purpose: Instantiate dialog class object and call its initialization
  119. //          function
  120. // Parameters: None.
  121. // Return Value:  
  122. //    BOOL - TRUE if initialization succeeded, FALSE otherwise.
  123. //
  124. //********************************************************************
  125.  
  126. BOOL CApp::InitInstance()
  127. {
  128.     m_pCDlg = new CDlg(m_hInst); 
  129.  
  130.     // If window could not be created, return "failure"
  131.     if (!m_pCDlg->Init(m_nCmdShow))
  132.         return FALSE;
  133.     m_hWnd = m_pCDlg->GetHWND();
  134.     return TRUE;              // We succeeded...
  135.  
  136. }
  137.  
  138.  
  139.