![](image/doc.gif)
_weiming_:以前从没想过这么用结构。太强了,受益匪浅!!!
(发表于2005-9-12 14:04:00)
![](image/doc.gif)
say2old:"现在ZWindow又有了一个虚函数ProcessWindowMessage"
这个“又”字用得不好!事实上有了这个虚函数以后,其他的OnPaint,OnCreate就都不需要再是虚函数了!
(发表于2006-2-6 19:28:00)
![](image/doc.gif)
say2old:void Init(WNDPROC proc, void* pThis)
{
thunk.m_mov = 0x042444C7; //C7 44 24 04
thunk.m_this = (DWORD)pThis;
thunk.m_jmp = 0xe9;
thunk.m_relproc = (int)proc - ((int)this+sizeof(_WndProcThunk));
下面这句话应该去掉,Thunk初始化后不应该马上调用,应该用SetWindowLong设为WNDPROC,以后每次响应事件时才真正调用。
FlushInstructionCache(GetCurrentProcess(), &thunk, sizeof(thunk));
}
(发表于2006-2-6 20:15:00)
![](image/doc.gif)
Daview:好文章。
在这篇代码中,我有个疑问:
BOOL Create(LPCTSTR szClassName, LPCTSTR szTitle, HINSTANCE hInstance, HWND hWndParent = 0,
DWORD dwStyle = WS_OVERLAPPEDWINDOW, DWORD dwExStyle = 0, HMENU hMenu = 0,
int x = CW_USEDEFAULT, int y = CW_USEDEFAULT, int nWidth = CW_USEDEFAULT, int nHeight = CW_USEDEFAULT)
{
m_hWnd = ::CreateWindowEx(dwExStyle, szClassName, szTitle, dwStyle, x, y,
nWidth, nHeight, hWndParent, hMenu, hInstance, NULL);
return m_hWnd != NULL;
}
结果的m_hWnd的值应该是由API分配的,但在:
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
ZWindow* pThis = (ZWindow*)hWnd;
if (uMsg == WM_NCDESTROY)
::PostQuitMessage(0);
if (!pThis->ProcessWindowMessage(pThis->m_hWnd, uMsg, wParam, lParam))
return ::DefWindowProc(pThis->m_hWnd, uMsg, wParam, lParam);
else
return 0;
}
中,hWnd怎么就跟ZWindow的实例对象联系上了?
能解释下吗?
(发表于2006-9-27 8:53:00)
..........................................................................
--------------------next---------------------