📄 interact.h
字号:
/*
* interact.h
*
* Basic GUI interactor.
*
* 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: interact.h,v $
* Revision 1.18 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.17 2000/04/13 23:18:42 robertj
* Fixed problems with sizing controls with scroll bars.
*
* Revision 1.16 1998/11/30 03:00:03 robertj
* New directory structure
*
* Revision 1.15 1998/09/24 03:40:31 robertj
* Added open software license.
*
* Revision 1.14 1998/09/21 13:30:52 robertj
* Changes to support new PListView class. Different call back method.
*
* Revision 1.13 1998/09/14 13:00:46 robertj
* Fixed major problem with resource leak every time a control is painted.
*
* Revision 1.12 1996/08/08 10:09:57 robertj
* Directory structure changes for common files.
*
* Revision 1.11 1995/12/10 11:53:53 robertj
* Support for controls background colours.
*
* Revision 1.10 1995/11/09 12:25:48 robertj
* Moved window style bits to member variable.
*
* Revision 1.9 1995/04/02 09:27:47 robertj
* Added "balloon" help.
*
* Revision 1.8 1995/03/12 05:00:13 robertj
* Re-organisation of DOS/WIN16 and WIN32 platforms to maximise common code.
* Used built-in equate for WIN32 API (_WIN32).
*
* Revision 1.7 1995/01/27 11:21:24 robertj
* Underscored library variables.
* Fixed bug in nested messages.
*
* Revision 1.6 1994/11/28 12:40:28 robertj
* Fixed problem with setting fonts on individual controls in a dialog loaded from resource. This
* required better logic in deleting HFONTs on an interactor.
*
* Revision 1.5 1994/10/23 05:46:38 robertj
* Changed window messaging technique.
*
* Revision 1.4 1994/07/17 10:46:06 robertj
* Enhancements, bug fixes etc.
*
* 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 _PINTERACTOR
#define _PINTERACTOR
#define P_NULL_WINDOW ((HWND)NULL)
#define P_DEAD_WINDOW ((HWND)-1)
#if defined(_WIN32)
#define PGET_CLASS_VALUE(hWnd, name) GetClassLong(hWnd, GCL_##name)
#define PGET_WINDOW_VALUE(hWnd, name) GetWindowLong(hWnd, GWL_##name)
#define PSET_CLASS_VALUE(hWnd, name, val) \
SetClassLong(hWnd, GCL_##name, (DWORD)(val))
#define PSET_WINDOW_VALUE(hWnd,name,val) \
SetWindowLong(hWnd, GWL_##name, (DWORD)(val))
#else
#define PGET_CLASS_VALUE(hWnd, name) GetClassWord(hWnd, GCW_##name)
#define PGET_WINDOW_VALUE(hWnd, name) GetWindowWord(hWnd, GWW_##name)
#define PSET_CLASS_VALUE(hWnd, name, val) \
SetClassWord(hWnd, GCW_##name, (WORD)(val))
#define PSET_WINDOW_VALUE(hWnd, name, val) \
SetWindowWord(hWnd, GWW_##name, (WORD)(val))
#endif
///////////////////////////////////////////////////////////////////////////////
// PInteractor
#define _PINTERACTOR_PLATFORM_INCLUDE
#include "../../interact.h"
#endif
#ifdef _PINTERACTOR_PLATFORM_INCLUDE
#undef _PINTERACTOR_PLATFORM_INCLUDE
public:
// New functions for class
HWND GetHWND() const;
// Return the MS-Windows handle. If does not exist yet, create it.
virtual void CreateHWND();
// Create the MS-Windows handle for the interactor.
protected:
PInteractor(PInteractor * parent, HWND hWnd);
// Constructor for making PInteractors when already have an MS-Windows
// window handle.
void SetWndText(const PString & str,
UINT setMsg = WM_SETTEXT, WPARAM wParam = 0);
// Set the MS-Windows text via SendMessage(). Uses the message codes as
// supplied in the parameters.
PString GetWndText(UINT lenMsg = WM_GETTEXTLENGTH, UINT getMsg = WM_GETTEXT,
WPARAM wParamGet = -1, WPARAM wParamLen = 0) const;
// Get the MS-Windows text via SendMessage(). Uses the message codes as
// supplied in the parameters.
void SetWndFont() const;
// Set the windows font when it is created or changed.
void RemoveWndFont() const;
// Removes the windows font when it is destroyed or changed.
void SetWndCursor() const;
// Set the windows cursor when it is changed in this interactor.
virtual void GetCreateWinInfo(WNDCLASS & wndClass);
// Return the info required by CreateWindow() and RegisterClass().
virtual void WndProc();
// Event handler for this interactor. Translates MS-Windows messages into
// virtual member function calls.
virtual void DefWndProc();
// Default MS-Windows message handler.
virtual BOOL AdjustDimensionForScrollBar(UINT bar) const;
// Determine if the client window dimensions must allow for a scroll bar.
// Member variables
HWND _hWnd;
// MS-Windows handle
struct _WindowsMessage {
UINT event;
WPARAM wParam;
LPARAM lParam;
LRESULT lResult;
BOOL processed;
} * _msg;
// Current WndProc message parameters and return value.
BOOL _in_WM_PAINT;
// Prevent recursive errors by remembering if we are in WM_PAINT
DWORD _styleBits, _exStyleBits;
// Style that was used to create the interactor.
HBRUSH hBackgroundBrush;
// Background brush
private:
void Construct(PInteractor * par, HWND hWnd, BOOL hiddenChild);
// Common construction code.
BOOL HandleScrollBar(HWND scrWnd, WPARAM code, int trackVal);
BOOL HandleCommand(NMHDR & msg);
BOOL HandleDrawItem(const DRAWITEMSTRUCT FAR * dis);
BOOL HandleMeasureItem(MEASUREITEMSTRUCT FAR * mis);
BOOL HandleCompareItem(const COMPAREITEMSTRUCT FAR * cis);
BOOL HandleDeleteItem(const DELETEITEMSTRUCT FAR * dis);
BOOL HandleCtlColour(HWND ctlWnd, HDC hDC,
const PColour & defFg, const PColour & defBk);
// Helper functions for WndProc()
friend class PApplication;
#endif
// End Of File ///////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -