205 lines
6.1 KiB
C
205 lines
6.1 KiB
C
|
//
|
|||
|
// <20>ւȂ<D682><C882>傱<EFBFBD>E<EFBFBD>C<EFBFBD><43><EFBFBD>h<EFBFBD>E<EFBFBD>N<EFBFBD><4E><EFBFBD>X
|
|||
|
//
|
|||
|
// <20>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>Ȃ<EFBFBD><C882>ƈӖ<C688><D396><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>^^;
|
|||
|
//
|
|||
|
#ifndef __CWND_INCLUDED__
|
|||
|
#define __CWND_INCLUDED__
|
|||
|
|
|||
|
#define WIN32_LEAN_AND_MEAN
|
|||
|
#include <windows.h>
|
|||
|
#include <windowsx.h>
|
|||
|
#include <commctrl.h>
|
|||
|
|
|||
|
#include <string>
|
|||
|
#include <list>
|
|||
|
using namespace std;
|
|||
|
|
|||
|
// prototype
|
|||
|
class CWnd;
|
|||
|
|
|||
|
// <20><><EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ׂ̃C<CC83><43><EFBFBD>`<60>L<EFBFBD>N<EFBFBD><4E><EFBFBD>X
|
|||
|
class CWndList
|
|||
|
{
|
|||
|
public:
|
|||
|
CWndList();
|
|||
|
~CWndList();
|
|||
|
|
|||
|
static void Add( CWnd* pWnd ); // <20><><EFBFBD>X<EFBFBD>g<EFBFBD>ɉ<EFBFBD><C989><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
static void Del( CWnd* pWnd ); // <20><><EFBFBD>X<EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>폜<EFBFBD><ED8F9C><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
static BOOL IsDialogMessage( LPMSG msg );
|
|||
|
protected:
|
|||
|
private:
|
|||
|
static list<CWnd*> m_WndPtrList;
|
|||
|
};
|
|||
|
|
|||
|
// <20><><EFBFBD>ʂ̃E<CC83>C<EFBFBD><43><EFBFBD>h<EFBFBD>E
|
|||
|
class CWnd
|
|||
|
{
|
|||
|
public:
|
|||
|
CWnd();
|
|||
|
virtual ~CWnd();
|
|||
|
|
|||
|
HWND m_hWnd;
|
|||
|
HMENU m_hMenu;
|
|||
|
|
|||
|
// Override
|
|||
|
virtual BOOL Create( HWND hWndParent ) { return FALSE; };
|
|||
|
virtual void Destroy() {};
|
|||
|
|
|||
|
// Override for ModalDialog
|
|||
|
virtual INT DoModal( HWND hWndParent ) { return 0; }
|
|||
|
|
|||
|
// For message filtering
|
|||
|
virtual BOOL PreTranslateMessage( MSG* pMsg ) { return FALSE; }
|
|||
|
protected:
|
|||
|
void SetThis();
|
|||
|
|
|||
|
// Static
|
|||
|
static LRESULT CALLBACK g_WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
|
|||
|
static BOOL CALLBACK g_DlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
|
|||
|
|
|||
|
// Override
|
|||
|
virtual LRESULT DispatchWnd( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
|||
|
{ return ::DefWindowProc( hWnd, msg, wParam, lParam ); }
|
|||
|
|
|||
|
virtual BOOL DispatchDlg( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
|||
|
{ return FALSE; }
|
|||
|
private:
|
|||
|
};
|
|||
|
|
|||
|
// <20>E<EFBFBD>C<EFBFBD><43><EFBFBD>h<EFBFBD>E<EFBFBD><45><EFBFBD>b<EFBFBD>Z<EFBFBD>[<5B>W<EFBFBD>p
|
|||
|
// <20>N<EFBFBD><4E><EFBFBD>X<EFBFBD><58><EFBFBD>`<60>}<7D>N<EFBFBD><4E>
|
|||
|
#define WND_MESSAGE_MAP() HRESULT DispatchWnd( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
|
|||
|
|
|||
|
#define WNDMSG BOOL
|
|||
|
#define WNDCMD void
|
|||
|
#define WNDNOTIFY void
|
|||
|
|
|||
|
#define WNDMSGPARAM HWND hWnd, WPARAM wParam, LPARAM lParam, HRESULT& hResult
|
|||
|
#define WNDCMDPARAM HWND hWnd, UINT uID
|
|||
|
#define WNDNOTIFYPARAM HWND hWnd, UINT uID, NMHDR* pNMHDR, LRESULT& hResult
|
|||
|
|
|||
|
// <20>C<EFBFBD><43><EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD>}<7D>N<EFBFBD><4E>
|
|||
|
#define WND_MESSAGE_BEGIN(cls) \
|
|||
|
HRESULT cls::DispatchWnd( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) {\
|
|||
|
HRESULT hResult = 0L;\
|
|||
|
switch( msg ) {
|
|||
|
#define WND_ON_MESSAGE(msg,fnc) \
|
|||
|
case (msg): {\
|
|||
|
if( fnc( hWnd, wParam, lParam, hResult ) )\
|
|||
|
return hResult;\
|
|||
|
}\
|
|||
|
break;
|
|||
|
// <20>R<EFBFBD>}<7D><><EFBFBD>h<EFBFBD><68>COMMAND_BEGIN() <20>` COMMAND_END()<29>̒<EFBFBD><CC92>ɋL<C98B>q<EFBFBD><71><EFBFBD><EFBFBD>(<28>P<EFBFBD>Ȃ<EFBFBD>if<69>Ȃ̂<C882>(^^;)
|
|||
|
#define WND_COMMAND_BEGIN() \
|
|||
|
case WM_COMMAND: {
|
|||
|
#define WND_ON_COMMAND(id,fnc) \
|
|||
|
if( LOWORD(wParam) == (id) ) \
|
|||
|
fnc( (HWND)lParam, LOWORD(wParam) );
|
|||
|
#define WND_ON_COMMAND_RANGE(id,idend,fnc) \
|
|||
|
if( LOWORD(wParam) >= (id) && LOWORD(wParam) <= (idend) ) \
|
|||
|
fnc( (HWND)lParam, LOWORD(wParam) );
|
|||
|
// Notify commands
|
|||
|
#define WND_ON_COMMAND_NOTIFY(id,nfy,fnc) \
|
|||
|
if( LOWORD(wParam) == (id) && HIWORD(wParam) == (nfy) ) \
|
|||
|
fnc( (HWND)lParam, LOWORD(wParam) );
|
|||
|
#define WND_ON_COMMAND_NOTIFY_RANGE(id,idend,nfy,fnc) \
|
|||
|
if( LOWORD(wParam) >= (id) && LOWORD(wParam) <= (idend) && HIWORD(wParam) == (nfy) ) \
|
|||
|
fnc( (HWND)lParam, LOWORD(wParam) );
|
|||
|
#define WND_COMMAND_END() \
|
|||
|
return 0L; }; break;
|
|||
|
|
|||
|
// WM_NOTIFY<46><59>NOTIFY_BEGIN() <20>` NOTIFY_END()<29>̒<EFBFBD><CC92>ɋL<C98B>q<EFBFBD><71><EFBFBD><EFBFBD>(<28>P<EFBFBD>Ȃ<EFBFBD>if<69>Ȃ̂<C882>^^;)
|
|||
|
#define WND_NOTIFY_BEGIN() \
|
|||
|
case WM_NOTIFY: { \
|
|||
|
LRESULT hResult = 0L;
|
|||
|
#define WND_ON_NOTIFY(id,msg,fnc) \
|
|||
|
if( (UINT)wParam == (id) && ((NMHDR*)lParam)->code == (msg) ) {\
|
|||
|
fnc( ((NMHDR*)lParam)->hwndFrom, (UINT)wParam, (NMHDR*)lParam, hResult );\
|
|||
|
return (BOOL)hResult; }
|
|||
|
#define WND_ON_NOTIFY_RANGE(id,idend,msg,fnc) \
|
|||
|
if( (UINT)wParam >= (id) && (UINT)wParam <= (idend) && ((NMHDR*)lParam)->code == (msg) ) {\
|
|||
|
fnc( ((NMHDR*)lParam)->hwndFrom, (UINT)wParam, (NMHDR*)lParam, hResult );\
|
|||
|
return (BOOL)hResult; }
|
|||
|
#define WND_NOTIFY_END() \
|
|||
|
return FALSE; }; break;
|
|||
|
|
|||
|
#define WND_MESSAGE_END() \
|
|||
|
default: break; }\
|
|||
|
return ::DefWindowProc( hWnd, msg, wParam, lParam );\
|
|||
|
}
|
|||
|
|
|||
|
// <20>_<EFBFBD>C<EFBFBD>A<EFBFBD><41><EFBFBD>O<EFBFBD><4F><EFBFBD>b<EFBFBD>Z<EFBFBD>[<5B>W<EFBFBD>p
|
|||
|
// <20>N<EFBFBD><4E><EFBFBD>X<EFBFBD><58><EFBFBD>`<60>}<7D>N<EFBFBD><4E>
|
|||
|
#define DLG_MESSAGE_MAP() BOOL DispatchDlg( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
|
|||
|
|
|||
|
#define DLGMSG BOOL
|
|||
|
#define DLGCMD void
|
|||
|
#define DLGNOTIFY void
|
|||
|
|
|||
|
#define DLGMSGPARAM HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL& bResult
|
|||
|
#define DLGCMDPARAM HWND hWnd, UINT uID
|
|||
|
#define DLGNOTIFYPARAM HWND hWnd, UINT uID, NMHDR* pNMHDR, LRESULT& hResult
|
|||
|
|
|||
|
// <20>C<EFBFBD><43><EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD>}<7D>N<EFBFBD><4E>
|
|||
|
#define DLG_MESSAGE_BEGIN(cls) \
|
|||
|
BOOL cls::DispatchDlg( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) {\
|
|||
|
BOOL bResult = TRUE;\
|
|||
|
switch( msg ) {
|
|||
|
#define DLG_ON_MESSAGE(msg,fnc) \
|
|||
|
case (msg): {\
|
|||
|
if( fnc( hWnd, wParam, lParam, bResult ) )\
|
|||
|
return bResult;\
|
|||
|
}\
|
|||
|
break;
|
|||
|
// <20>R<EFBFBD>}<7D><><EFBFBD>h<EFBFBD><68>COMMAND_BEGIN() <20>` COMMAND_END()<29>̒<EFBFBD><CC92>ɋL<C98B>q<EFBFBD><71><EFBFBD><EFBFBD>(<28>P<EFBFBD>Ȃ<EFBFBD>if<69>Ȃ̂<C882>^^;)
|
|||
|
#define DLG_COMMAND_BEGIN() \
|
|||
|
case WM_COMMAND: {
|
|||
|
#define DLG_ON_COMMAND(id,fnc) \
|
|||
|
if( LOWORD(wParam) == (id) ) \
|
|||
|
fnc( (HWND)lParam, LOWORD(wParam) );
|
|||
|
#define DLG_ON_COMMAND_RANGE(id,idend,fnc) \
|
|||
|
if( LOWORD(wParam) >= (id) && LOWORD(wParam) <= (idend) ) \
|
|||
|
fnc( (HWND)lParam, LOWORD(wParam) );
|
|||
|
// Notify commands
|
|||
|
#define DLG_ON_COMMAND_NOTIFY(id,nfy,fnc) \
|
|||
|
if( LOWORD(wParam) == (id) && HIWORD(wParam) == (nfy) ) \
|
|||
|
fnc( (HWND)lParam, LOWORD(wParam) );
|
|||
|
#define DLG_ON_COMMAND_NOTIFY_RANGE(id,idend,nfy,fnc) \
|
|||
|
if( LOWORD(wParam) >= (id) && LOWORD(wParam) <= (idend) && HIWORD(wParam) == (nfy) ) \
|
|||
|
fnc( (HWND)lParam, LOWORD(wParam) );
|
|||
|
#define DLG_COMMAND_END() \
|
|||
|
return FALSE; }; break;
|
|||
|
|
|||
|
// WM_NOTIFY<46><59>NOTIFY_BEGIN() <20>` NOTIFY_END()<29>̒<EFBFBD><CC92>ɋL<C98B>q<EFBFBD><71><EFBFBD><EFBFBD>(<28>P<EFBFBD>Ȃ<EFBFBD>if<69>Ȃ̂<C882>^^;)
|
|||
|
#define DLG_NOTIFY_BEGIN() \
|
|||
|
case WM_NOTIFY: { \
|
|||
|
LRESULT hResult = 0L;
|
|||
|
#define DLG_ON_NOTIFY(id,msg,fnc) \
|
|||
|
if( (UINT)wParam == (id) && ((NMHDR*)lParam)->code == (msg) ) {\
|
|||
|
fnc( ((NMHDR*)lParam)->hwndFrom, (UINT)wParam, (NMHDR*)lParam, hResult );\
|
|||
|
return (BOOL)hResult; }
|
|||
|
#define DLG_ON_NOTIFY_RANGE(id,idend,msg,fnc) \
|
|||
|
if( (UINT)wParam >= (id) && (UINT)wParam <= (idend) && ((NMHDR*)lParam)->code == (msg) ) {\
|
|||
|
fnc( ((NMHDR*)lParam)->hwndFrom, (UINT)wParam, (NMHDR*)lParam, hResult );\
|
|||
|
return (BOOL)hResult; }
|
|||
|
#define DLG_NOTIFY_END() \
|
|||
|
return FALSE; }; break;
|
|||
|
|
|||
|
#define DLG_MESSAGE_END() \
|
|||
|
default: break; }\
|
|||
|
return FALSE;\
|
|||
|
}
|
|||
|
|
|||
|
//
|
|||
|
// <20>_<EFBFBD>C<EFBFBD>A<EFBFBD><41><EFBFBD>O<EFBFBD><4F><EFBFBD>R<EFBFBD><52><EFBFBD>g<EFBFBD><67><EFBFBD>[<5B><><EFBFBD>w<EFBFBD><77><EFBFBD>p<EFBFBD>[<5B>}<7D>N<EFBFBD><4E>
|
|||
|
//
|
|||
|
#define BTNCHECK(ctrlid,check) ::CheckDlgButton(m_hWnd,(ctrlid),(check)?BST_CHECKED:BST_UNCHECKED)
|
|||
|
#define IsBTNCHECK(ctrlid) ((::IsDlgButtonChecked(m_hWnd,(ctrlid))==BST_CHECKED)?TRUE:FALSE)
|
|||
|
|
|||
|
#define CTRLENABLE(ctrlid,enable) ::EnableWindow(::GetDlgItem(m_hWnd,(ctrlid)),enable);
|
|||
|
|
|||
|
#endif // !__CWND_INCLUDED__
|