Spy++原理初探
2010-07-20 20:46:04 来源:WEB开发网其余各项详见源代码。这个列表框的作用不仅仅是显示窗口的状态,还要在发生勾选改动时即时改变窗口状态或激发其行为。勾选状态改变的消息是LBN_SELCHANGE。另外,为了不使一个勾选的改变就引起所有列表项都激发一遍,我们采用switch结构,以使哪个列表项被选中就激发哪个列表项。代码如下:
void CPage4::OnSelchangeListstatus()
{
// TODO: Add your control notification handler code here
int n=m_listStatus.GetCurSel();
switch(n)
{
case 0:
if(m_listStatus.GetCheck(0)== 1 )
::ShowWindow(g_hWnd, SW_SHOW);
else
::ShowWindow(g_hWnd, SW_HIDE);
break;
case 1:
if(m_listStatus.GetCheck(1) == 1)
::EnableWindow(g_hWnd, TRUE);
else
::EnableWindow(g_hWnd,FALSE);
break;
case 2:
if(m_listStatus.GetCheck(2) == 1)
::SetWindowPos(g_hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
else
::SetWindowPos(g_hWnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
break;
case 3:
if(m_listStatus.GetCheck(3) == 1)
::SendMessage(g_hWnd, EM_SETREADONLY, TRUE, 0);
else
::SendMessage(g_hWnd, EM_SETREADONLY, FALSE, 0);
break;
case 4:
if(m_listStatus.GetCheck(4) ==1)
{
::ShowWindow(g_hWnd, SW_MAXIMIZE);
m_listStatus.SetCheck(5,0);
}
else
::ShowWindow (g_hWnd, SW_RESTORE);
break;
case 5:
if (m_listStatus.GetCheck(5) == 1)
{
::ShowWindow(g_hWnd, SW_MINIMIZE);
m_listStatus.SetCheck(4,0);
}
else
::ShowWindow(g_hWnd, SW_RESTORE);
break;
case 6:
if(m_listStatus.GetCheck(6) ==1)
{
::ShowWindow (g_hWnd, SW_RESTORE);
m_listStatus.SetCheck(6,0);
m_listStatus.SetCheck(5,0);
m_listStatus.SetCheck(4,0);
}
break;
case 7:
if(m_listStatus.GetCheck(7) ==1)
{
::SendMessage (g_hWnd, WM_CLOSE, 0, 0);
m_listStatus.SetCheck(7,0);
}
break;
case 8:
if(m_listStatus.GetCheck(8) ==1)
{
::BringWindowToTop(g_hWnd);
m_listStatus.SetCheck(8,0);
}
break;
default:
;
}
}
Spy++打造完毕。回顾其过程,难点不多,细细碎碎问题不少。也难免啊,不仅要形似,咱还要神似。文中一定还有很多地方不够周全,希望同行朋友们不吝赐教。代码在Window XP + VC6.0中调试通过。Spy++源码同时放在这里。
本文配套源码
更多精彩
赞助商链接