⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 applicat.h

📁 windows mobile phone source code
💻 H
字号:
/*
 * applicat.h
 *
 * GUI application class.
 *
 * Portable Windows Library
 *
 * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 * the License for the specific language governing rights and limitations
 * under the License.
 *
 * The Original Code is Portable Windows Library.
 *
 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
 *
 * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
 * All Rights Reserved.
 *
 * Contributor(s): ______________________________________.
 *
 * $Log: applicat.h,v $
 * Revision 1.34  2001/05/22 12:49:33  robertj
 * Did some seriously wierd rewrite of platform headers to eliminate the
 *   stupid GNU compiler warning about braces not matching.
 *
 * Revision 1.33  2000/03/17 20:32:21  robertj
 * Fixed race conditions in mult-threaded windows (dialogs in particular)
 *
 * Revision 1.32  2000/03/04 07:47:49  robertj
 * Fixed problem with window not appearing when assert on GUI based win32 apps.
 *
 * Revision 1.31  1999/08/07 07:13:22  robertj
 * Fixed problems with "balloon help" text popup.
 *
 * Revision 1.30  1999/02/16 08:08:47  robertj
 * MSVC 6.0 compatibility changes.
 *
 * Revision 1.29  1998/12/02 03:51:41  robertj
 * Unix compatibility changes
 *
 * Revision 1.28  1998/11/30 02:59:48  robertj
 * New directory structure
 *
 * Revision 1.27  1998/09/24 03:39:28  robertj
 * Added open software license.
 *
 * Revision 1.26  1998/04/07 13:32:17  robertj
 * Changed startup code to support PApplication class.
 *
 * Revision 1.25  1998/03/29 06:20:07  robertj
 * Rearranged initialisation sequence so PProcess descendent constructors can do "things".
 *
 * Revision 1.24  1997/07/08 12:59:14  robertj
 * DLL support
 *
 * Revision 1.23  1997/04/27 05:50:28  robertj
 * DLL support.
 *
 * Revision 1.22  1996/08/17 10:00:39  robertj
 * Changes for Windows DLL support.
 *
 * Revision 1.21  1996/08/08 10:09:25  robertj
 * Directory structure changes for common files.
 *
 * Revision 1.20  1996/06/28 13:24:00  robertj
 * If WIN32 then platform has threads, removed resundent ifdef.
 *
 * Revision 1.19  1996/01/02 12:58:55  robertj
 * Mac OS compatibility changes.
 *
 * Revision 1.18  1995/12/10 11:53:10  robertj
 * Changes to main() startup mechanism to support Mac.
 *
 * Revision 1.17  1995/11/09 12:24:24  robertj
 * Moved window style bits to member variable.
 *
 * Revision 1.16  1995/08/24 12:40:23  robertj
 * Added Construct() function required by X platform.
 * Added standard colours for balloon help windows.
 *
 * Revision 1.15  1995/07/31 12:17:53  robertj
 * Split off pop up window from balloon.
 *
 * Revision 1.14  1995/04/25 11:34:09  robertj
 * Changes for DLL support.
 *
 * Revision 1.13  1995/04/03 11:27:45  robertj
 * Fixed balloon help window so doesn't flash main window.
 *
 * Revision 1.12  1995/04/02 09:27:37  robertj
 * Added "balloon" help.
 *
 * Revision 1.11  1995/03/12 05:00:11  robertj
 * Re-organisation of DOS/WIN16 and WIN32 platforms to maximise common code.
 * Used built-in equate for WIN32 API (_WIN32).
 *
 * Revision 1.10  1995/02/05  00:53:53  robertj
 * Removed incorrect inline include.
 *
 * Revision 1.9  1995/01/22  07:29:43  robertj
 * Added font & colour standard dialogs.
 *
 * Revision 1.8  1995/01/09  12:27:11  robertj
 * Moved EXPORTED definition to object.h
 *
 * Revision 1.7  1994/08/21  23:43:02  robertj
 * Made last tick an int for efficiency.
 *
 * Revision 1.6  1994/07/27  05:58:07  robertj
 * Synchronisation.
 *
 * Revision 1.5  1994/07/21  12:33:49  robertj
 * Moved cooperative threads to common.
 *
 * Revision 1.4  1994/07/02  03:03:49  robertj
 * Changes to timer processing.
 *
 * Revision 1.3  1994/06/25  11:55:15  robertj
 * Unix version synchronisation.
 *
 * Revision 1.2  1994/04/20  12:17:44  robertj
 * assert changes
 *
 * Revision 1.1  1994/04/12  08:21:52  robertj
 * Initial revision
 *
 */


#ifndef _PAPPLICATION

class PInteractorLayout;

#if defined(_MSC_VER) && !defined(_WIN32)
extern "C" int __argc;
extern "C" char ** __argv;
#endif

#ifdef __BORLANDC__
#define __argc _argc
#define __argv _argv
#endif

#undef PCREATE_PROCESS
#define PCREATE_PROCESS(cls) \
  extern "C" int PASCAL WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int) \
    { PProcess::PreInitialise(__argc, __argv, _environ); \
      static cls instance; \
      return instance._main(hInst); \
    }


///////////////////////////////////////////////////////////////////////////////
// PApplication

#define _PAPPLICATION_PLATFORM_INCLUDE
#include "../../applicat.h"

#endif
#ifdef _PAPPLICATION_PLATFORM_INCLUDE
#undef _PAPPLICATION_PLATFORM_INCLUDE

  public:
    virtual BOOL IsGUIProcess() const;

#ifndef P_PLATFORM_HAS_THREADS

    // Overrides for class PThread
    virtual void OperatingSystemYield();
      // This is here so that other MS-Windows tasks get scheduled if the
      // PApplication thread is blocked internal to PWLib.

#endif


    // New functions for class
    HINSTANCE GetInstance() const;
      // Return the MS-Windows instance handle.

    // Support for looking up C++ objects from HWNDs
    void AddWindowHandle(HWND hWnd, PInteractor * pWnd);
    void RemoveWindowHandle(HWND hWnd);
    PInteractor * GetWindowObject(HWND hWnd) const;

    // Support for non-modal dialogs
    void AddDialog(PInteractorLayout * pWnd);
    void RemoveDialog(PInteractorLayout * pWnd);


  private:
    enum WndProcTypes {
      WndProcType,
      DlgProcType,
      FileDlgProcType,
      PrintDlgProcType,
      FontDlgProcType,
      ColourDlgProcType,
      NumWndProcTypes
    };
    WNDPROC GetWndProcPtr(WndProcTypes proc) const;
      // Return the MS-Windows callback functions.

    LRESULT WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
      // Called by the static function but is now bound to the application
      // object data.

    BOOL DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
      // Called by the static function but is now bound to the application
      // object data.

    BOOL FileDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
      // Called by the static function but is now bound to the application
      // object data.

    BOOL PrintDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
      // Called by the static function but is now bound to the application
      // object data.

    BOOL FontDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
      // Called by the static function but is now bound to the application
      // object data.

    BOOL ColourDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
      // Called by the static function but is now bound to the application
      // object data.

    BOOL ProcessMessage();
      // Process a MS-Windows message.


    // Member Variables
    HINSTANCE hInstance;
      // The MS-Windows instance handle for the running image.

    WNDPROC wndProcPtr[NumWndProcTypes];
      // Pointers to the MS-Windows callback functions that bind MS-Windows
      // messages to the C++ class objects.

    class HWNDKey : public PObject
    {
      PCLASSINFO(HWNDKey, PObject)
      // This class is used in the hash table lookup for getting a PInteractor
      // pointer given a MS-Windows window handle.
      public:
        HWNDKey(HWND newKey)
          { theKey = newKey; }
        inline PObject * Clone() const
          { return new HWNDKey(theKey); }
        inline Comparison Compare(const PObject & obj) const
          { return theKey != ((const HWNDKey &)obj).theKey
                                                     ? GreaterThan : EqualTo; }
        inline PINDEX HashFunction() const
          { return ((UINT)theKey/8)%23; }

      private:
        HWND theKey;
    };
    PDICTIONARY(WindowDict, HWNDKey, PInteractor);
    WindowDict createdWindows;

    PMutex windowsMutex;
      // Mutual exclusion on threads accessing windows structures

    PLIST(NonModalDict, PInteractorLayout);
    NonModalDict nonModalDialogs;

    PInteractorList delayedCreateInteractors;
      // List of interactors that require creation at end of main loop.

    PSyncPoint delayedCreateInteractorsDone;
      // Signal for having processed delayedCreateInteractors

    BOOL receivedQuitMessage;
      // Flag that the last message WM_QUIT has been received

    HACCEL hAccelerator;
      // Current menus accelerator, needed by the ProcessMessage() loop.

    HWND mdiClient;
      // MDI client window, needed by the ProcessMessage() loop.

#ifndef P_PLATFORM_HAS_THREADS
    HWND timerWnd;
      // Internal window to receive WM_TIMER messages to assure this process
      // is scheduled for background threads and timers.

    UINT lastSetTimerTick;
      // Last GetTickCount() value for SetTimer() call to prevent the call
      // being made on every received message.
#endif


    friend LRESULT PEXPORTED WndProc(HWND, UINT, WPARAM, LPARAM);
    friend BOOL PEXPORTED DlgProc(HWND, UINT, WPARAM, LPARAM);
    friend BOOL PEXPORTED FileDlgProc(HWND, UINT, WPARAM, LPARAM);
    friend BOOL PEXPORTED PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
    friend BOOL PEXPORTED FontDlgProc(HWND, UINT, WPARAM, LPARAM);
    friend BOOL PEXPORTED ColourDlgProc(HWND, UINT, WPARAM, LPARAM);
    friend HWND PInteractor::GetHWND() const;
    friend void PInteractor::GetCreateWinInfo(WNDCLASS &);
    friend void PControl::SubClassControlWndProc();
    friend void PInteractorLayout::CreateHWND();
    friend void PTitledWindow::WndProc();
    friend int PModalDialog::RunModal();
    friend PFileDialog::PFileDialog(PInteractor *, PRESOURCE_ID);
    friend void PPrintDialog::Construct();
    friend void PFontDialog::Construct(PRESOURCE_ID);
    friend void PColourDialog::Construct(PRESOURCE_ID);
    friend PMDIFrameWindow::PMDIFrameWindow(unsigned CanDo);

#endif


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

⌨️ 快捷键说明

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