📄 subclasswnd.h-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta name="robots" content="noindex"><title>subclasswnd.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body bgcolor="#ffffff"><!-- Generated by Doxygen 1.1.1 on Wed Jun 7 18:30:35 2000 --><center><a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> </center><hr><h1>subclasswnd.h</h1><div class="fragment"><pre>00001 #if !defined(_SUBCLASSWND_H_199B246E_AE5D_11D3_A459_000629B2F85_INCLUDED_)00002 #define _SUBCLASSWND_H_199B246E_AE5D_11D3_A459_000629B2F85_INCLUDED_00003 00004 #if _MSC_VER >= 100000005 #pragma once00006 #endif // _MSC_VER >= 100000007 00008 #if _MSC_VER >= 100000009 #pragma once00010 #endif // _MSC_VER >= 100000011 00017 <a name="l00018"><a class="code" href="class_csubclasswnd.html">00018</a></a> class <a class="code" href="class_csubclasswnd.html">CSubclassWnd</a>00019 {00020 private:00021 class WndProcThunk00022 {00023 public:00024 #if defined(_M_IX86)00025 #pragma pack(push,1)00026 struct Thunk00027 {00028 DWORD m_mov; // mov dword ptr [esp+0x4], pThis (esp+0x4 is hWnd)
00029 DWORD m_this; //
00030 BYTE m_jmp; // jmp WndProc
00031 DWORD m_relproc; // relative jmp
00032 };00033 #pragma pack(pop)00034 #elif defined (_M_ALPHA)00035 // For ALPHA we will stick the this pointer into a0, which is where
00036 // the HWND is. However, we don't actually need the HWND so this is OK.
00037 #pragma pack(push,4)00038 struct Thunk //this should come out to 20 bytes
00039 {00040 DWORD ldah_at; // ldah at, HIWORD(func)
00041 DWORD ldah_a0; // ldah a0, HIWORD(this)
00042 DWORD lda_at; // lda at, LOWORD(func)(at)
00043 DWORD lda_a0; // lda a0, LOWORD(this)(a0)
00044 DWORD jmp; // jmp zero,(at),0
00045 };00046 #pragma pack(pop)00047 #else00048 #error Only Alpha and X86 supported00049 #endif00050 00051 Thunk thunk;00052 00053 void Init(WNDPROC proc, void* pThis)00054 {00055 #if defined (_M_IX86)00056 thunk.m_mov = 0x042444C7; //C7 44 24 0C
00057 thunk.m_this = (DWORD)pThis;00058 thunk.m_jmp = 0xe9;00059 thunk.m_relproc = (int)proc - ((int)this+sizeof(Thunk));00060 #elif defined (_M_ALPHA)00061 thunk.ldah_at = (0x279f0000 | HIWORD(proc)) + (LOWORD(proc)>>15);00062 thunk.ldah_a0 = (0x261f0000 | HIWORD(pThis)) + (LOWORD(pThis)>>15);00063 thunk.lda_at = 0x239c0000 | LOWORD(proc);00064 thunk.lda_a0 = 0x22100000 | LOWORD(pThis);00065 thunk.jmp = 0x6bfc0000;00066 #endif00067 // write block from data cache and
00068 // flush from instruction cache
00069 FlushInstructionCache(GetCurrentProcess(), &thunk, sizeof(thunk));00070 }00071 };00072 00073 public:00074 CSubclassWnd();00075 virtual ~CSubclassWnd();00076 00077 const MSG* GetCurrentMessage() const;00078 00079 virtual BOOL ProcessWindowMessage(UINT uMsg, WPARAM wParam, LPARAM lParam,00080 LRESULT& lResult);00081 BOOL ProcessReflectedMessage(UINT uMsg, WPARAM wParam, LPARAM lParam,00082 LRESULT& lResult);00083 virtual void OnFinalMessage();00084 00085 LRESULT DefWindowProc();00086 LRESULT DefWindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);00087 00088 #ifdef _MFC_VER00089 BOOL SubclassWindow(CWnd* pWnd, BOOL bReflect=FALSE);00090 #endif00091 BOOL SubclassWindow(HWND hWnd, BOOL bReflect=FALSE);00092 HWND UnsubclassWindow();00093 00094 HWND GetHandle() const;00095 00096 LRESULT SendMessage(UINT uMsg, WPARAM wParam=0, LPARAM lParam=0);00097 BOOL PostMessage(UINT uMsg, WPARAM wParam=0, LPARAM lParam=0);00098 void SendMessageToDescendants(UINT message, WPARAM wParam, LPARAM lParam,00099 BOOL bDeep=TRUE);00100 00101 private:00102 static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam,00103 LPARAM lParam);00104 00105 private:00106 WndProcThunk m_thunk;00107 WNDPROC m_pfnSuperWindowProc;00108 const MSG* m_pCurrentMsg;00109 HWND m_hWnd;00110 };00111 00112 #ifdef _MFC_VER00124 00125 inline BOOL <a class="code" href="class_csubclasswnd.html#a8">CSubclassWnd::SubclassWindow</a>(CWnd* pWnd, BOOL bReflect)00126 {00127 return SubclassWindow(pWnd->GetSafeHwnd(), bReflect);00128 }00129 #endif00130 <a name="l00136"><a class="code" href="class_csubclasswnd.html#a2">00136</a></a> inline const MSG* <a class="code" href="class_csubclasswnd.html#a2">CSubclassWnd::GetCurrentMessage</a>() const00137 {00138 return m_pCurrentMsg;00139 }00140 00149 <a name="l00150"><a class="code" href="class_csubclasswnd.html#a6">00150</a></a> inline LRESULT <a class="code" href="class_csubclasswnd.html#a6">CSubclassWnd::DefWindowProc</a>()00151 {00152 const MSG* pMsg = m_pCurrentMsg;00153 LRESULT lRes = 0;00154 if (pMsg != NULL)00155 lRes = DefWindowProc(pMsg->message, pMsg->wParam, pMsg->lParam);00156 return lRes;00157 }00158 <a name="l00171"><a class="code" href="class_csubclasswnd.html#a7">00171</a></a> inline LRESULT <a class="code" href="class_csubclasswnd.html#a6">CSubclassWnd::DefWindowProc</a>(UINT uMsg, WPARAM wParam, LPARAM lParam)00172 {00173 #ifdef STRICT00174 return ::CallWindowProc(m_pfnSuperWindowProc, m_hWnd, uMsg, wParam, lParam);00175 #else00176 return ::CallWindowProc((FARPROC)m_pfnSuperWindowProc, m_hWnd, uMsg, wParam, lParam);00177 #endif00178 }00179 00185 <a name="l00186"><a class="code" href="class_csubclasswnd.html#a10">00186</a></a> inline HWND <a class="code" href="class_csubclasswnd.html#a10">CSubclassWnd::GetHandle</a>() const00187 {00188 return m_hWnd;00189 }00190 00201 <a name="l00202"><a class="code" href="class_csubclasswnd.html#a11">00202</a></a> inline LRESULT <a class="code" href="class_csubclasswnd.html#a11">CSubclassWnd::SendMessage</a>(UINT message, WPARAM wParam, LPARAM lParam)00203 {00204 return ::SendMessage(GetHandle(), message, wParam, lParam);00205 }00206 00218 <a name="l00219"><a class="code" href="class_csubclasswnd.html#a12">00219</a></a> inline BOOL <a class="code" href="class_csubclasswnd.html#a12">CSubclassWnd::PostMessage</a>(UINT message, WPARAM wParam, LPARAM lParam)00220 {00221 return ::PostMessage(GetHandle(), message, wParam, lParam);00222 }00223 00224 template <typename T>00225 struct DISPATCH_TRAITS00226 {00227 typedef T type;00228 };00229 00234 #define BEGIN_MSG_DISPATCH(className, rootClass) \00235 virtual BOOL ProcessWindowMessage(UINT uMsg, WPARAM wParam, \00236 LPARAM lParam, LRESULT& lResult) { \00237 typedef DISPATCH_TRAITS<##rootClass>::type root_type; \00238 if (ProcessReflectedMessage(uMsg, wParam, lParam, lResult)) \00239 return TRUE;00240 00244 #define END_MSG_DISPATCH() \00245 return root_type::ProcessWindowMessage(uMsg, wParam, lParam, lResult); }00246 00253 #define DISPATCH_MSG(message, mfn) \00254 else if (uMsg == message) { lResult = DISPATCH_##message((wParam), (lParam), (mfn)); return TRUE; }00255 00256 /* void Class::OnCompacting(UINT compactRatio) */00257 #define DISPATCH_WM_COMPACTING(wParam, lParam, fn) \00258 ((fn)((UINT)(wParam)), 0L)00259 00260 /* void Class::OnWinIniChange(LPCTSTR lpszSectionName) */00261 #define DISPATCH_WM_WININICHANGE(wParam, lParam, fn) \00262 ((fn)((LPCTSTR)(lParam)), 0L)00263 00264 /* void Class::OnSysColorChange() */00265 #define DISPATCH_WM_SYSCOLORCHANGE(wParam, lParam, fn) \00266 ((fn)(), 0L)00267 00268 /* BOOL Class::OnQueryNewPalette() */00269 #define DISPATCH_WM_QUERYNEWPALETTE(wParam, lParam, fn) \00270 MAKELRESULT((BOOL)(fn)(), 0L)00271 00272 /* void Class::OnPaletteIsChanging(HWND hwndPaletteChange) */00273 #define DISPATCH_WM_PALETTEISCHANGING(wParam, lParam, fn) \00274 ((fn)((HWND)(wParam)), 0L)00275 00276 /* void Class::OnPaletteChanged(HWND hwndPaletteChange) */00277 #define DISPATCH_WM_PALETTECHANGED(wParam, lParam, fn) \00278 ((fn)((HWND)(wParam)), 0L)00279 00280 /* void Class::OnFontChange() */00281 #define DISPATCH_WM_FONTCHANGE(wParam, lParam, fn) \00282 ((fn)(), 0L)00283 00284 /* void Class::OnSpoolerStatus(UINT status, int cJobInQueue) */00285 #define DISPATCH_WM_SPOOLERSTATUS(wParam, lParam, fn) \00286 ((fn)((UINT)(wParam), (int)(short)LOWORD(lParam)), 0L)00287 00288 /* void Class::OnDevModeChange(LPCTSTR lpszDeviceName) */00289 #define DISPATCH_WM_DEVMODECHANGE(wParam, lParam, fn) \00290 ((fn)((LPCTSTR)(lParam)), 0L)00291 00292 /* void Class::OnTimeChange() */00293 #define DISPATCH_WM_TIMECHANGE(wParam, lParam, fn) \00294 ((fn)(), 0L)00295 00296 /* void Class::OnPower(int code) */00297 #define DISPATCH_WM_POWER(wParam, lParam, fn) \00298 ((fn)((int)(wParam)), 0L)00299 00300 /* BOOL Class::OnQueryEndSession() */00301 #define DISPATCH_WM_QUERYENDSESSION(wParam, lParam, fn) \00302 MAKELRESULT((BOOL)(fn)(), 0L)00303 00304 /* void Class::OnEndSession(BOOL fEnding) */00305 #define DISPATCH_WM_ENDSESSION(wParam, lParam, fn) \00306 ((fn)((BOOL)(wParam)), 0L)00307 00308 /* void Class::OnQuit(int exitCode) */00309 #define DISPATCH_WM_QUIT(wParam, lParam, fn) \00310 ((fn)((int)(wParam)), 0L)00311 00312 /* This message is in Windows 3.1 only */00313 /* void Class::OnSystemError(int errCode) */00314 #define DISPATCH_WM_SYSTEMERROR(wParam, lParam, fn) 0L00315 00316 /* BOOL Class::OnCreate(LPCREATESTRUCT lpCreateStruct) */00317 #define DISPATCH_WM_CREATE(wParam, lParam, fn) \00318 ((fn)((LPCREATESTRUCT)(lParam)) ? 0L : (LRESULT)-1L)00319 00320 /* BOOL Class::OnNCCreate(LPCREATESTRUCT lpCreateStruct) */00321 #define DISPATCH_WM_NCCREATE(wParam, lParam, fn) \00322 (LRESULT)(DWORD)(BOOL)(fn)((LPCREATESTRUCT)(lParam))00323 00324 /* void Class::OnDestroy() */00325 #define DISPATCH_WM_DESTROY(wParam, lParam, fn) \00326 ((fn)(), 0L)00327 00328 /* void Class::OnNCDestroy() */00329 #define DISPATCH_WM_NCDESTROY(wParam, lParam, fn) \00330 ((fn)(), 0L)00331 00332 /* void Class::OnShowWindow(BOOL fShow, UINT status) */00333 #define DISPATCH_WM_SHOWWINDOW(wParam, lParam, fn) \00334 ((fn)((BOOL)(wParam), (UINT)(lParam)), 0L)00335 00336 /* void Class::OnSetRedraw(BOOL fRedraw) */00337 #define DISPATCH_WM_SETREDRAW(wParam, lParam, fn) \00338 ((fn)((BOOL)(wParam)), 0L)00339 00340 /* void Class::OnEnable(BOOL fEnable) */00341 #define DISPATCH_WM_ENABLE(wParam, lParam, fn) \00342 ((fn)((BOOL)(wParam)), 0L)00343
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -