AxibugEmuOnline/References/virtuanessrc097-master/Wnd.cpp

136 lines
5.7 KiB
C++
Raw Permalink Normal View History

<EFBFBD><EFBFBD>//
// x0j0a0<EFBFBD>0S0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
//
#include "DebugOut.h"
#include "Wnd.h"
// Instance
CWndList WndList;
list<CWnd*> CWndList::m_WndPtrList;
// <EFBFBD>l<EFBFBD><EFBFBD>D0&
CWndList::CWndList()
{
// m_WndPtrList.clear();
}
CWndList::~CWndList()
{
// if( !m_WndPtrList.empty() )
// m_WndPtrList.clear();
}
void CWndList::Add( CWnd* pWnd )
{
m_WndPtrList.push_back( pWnd );
}
void CWndList::Del( CWnd* pWnd )
{
for( list<CWnd*>::iterator it=m_WndPtrList.begin(); it!=m_WndPtrList.end(); ) {
if( *it == pWnd ) {
m_WndPtrList.erase(it);
break;
} else {
++it;
}
}
}
BOOL CWndList::IsDialogMessage( LPMSG msg )
{
if( m_WndPtrList.empty() )
return FALSE;
list<CWnd*>::iterator it=m_WndPtrList.begin();
while( it != m_WndPtrList.end() ) {
if( ::IsDialogMessage( (*it)->m_hWnd, msg ) )
return TRUE;
++it;
}
return FALSE;
}
CWnd::CWnd()
{
m_hWnd = NULL;
m_hMenu = NULL;
}
CWnd::~CWnd()
{
}
void CWnd::SetThis()
{
// Dispatch<EFBFBD>Qeg<EFBFBD>0<EFBFBD>0F0k0CWnd*<EFBFBD>0<EFBFBD>W<EFBFBD>0<EFBFBD><EFBFBD><EFBFBD>0
if( m_hWnd ) {
::SetWindowLong( m_hWnd, GWL_USERDATA, (LONG)this );
}
}
LRESULT CALLBACK CWnd::g_WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
// <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0L0<EFBFBD><EFBFBD>O0MRk0S0c0]0<EFBFBD>0<EFBFBD>QtY0<EFBFBD>0
if( msg == WM_CREATE ) {
LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
CWnd* pWnd = (CWnd*)::GetWindowLong( hWnd, GWL_USERDATA );
if( !pWnd ) {
// CWnd* this<EFBFBD>0<EFBFBD>W<EFBFBD>0<EFBFBD><EFBFBD><EFBFBD>0
::SetWindowLong( hWnd, GWL_USERDATA, (LONG)lpcs->lpCreateParams );
// <EFBFBD><EFBFBD>Rn0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
pWnd = (CWnd*)lpcs->lpCreateParams;
pWnd->m_hWnd = hWnd;
}
}
// CWnd* this<EFBFBD>0<EFBFBD>W<EFBFBD>0<EFBFBD><EFBFBD><EFBFBD>0g0B0<EFBFBD>0
CWnd* pWnd = (CWnd*)::GetWindowLong( hWnd, GWL_USERDATA );
if( pWnd ) {
return pWnd->DispatchWnd( hWnd, msg, wParam, lParam );
} else {
return ::DefWindowProc( hWnd, msg, wParam, lParam );
}
}
BOOL CALLBACK CWnd::g_DlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
// <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0MRk0S0c0]0<EFBFBD>0<EFBFBD>QtY0<EFBFBD>0
if( msg == WM_INITDIALOG ) {
// Dispatch<EFBFBD>Qeg<EFBFBD>0<EFBFBD>0F0k0CWnd*<EFBFBD>0<EFBFBD>W<EFBFBD>0<EFBFBD><EFBFBD><EFBFBD>0(<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0o0<EFBFBD>_Z0DialogBoxParamg0w<EFBFBD><EFBFBD>RY0<EFBFBD>0<EFBFBD>N)
// CWnd* this<EFBFBD>0<EFBFBD>W<EFBFBD>0<EFBFBD><EFBFBD><EFBFBD>0g0B0<EFBFBD>0L0 <EFBFBD><EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0g0o0eQc0f0D0j0D0
CWnd* pWnd = (CWnd*)::GetWindowLong( hWnd, GWL_USERDATA );
if( !pWnd ) {
::SetWindowLong( hWnd, GWL_USERDATA, (LONG)lParam );
pWnd = (CWnd*)lParam;
}
// <EFBFBD><EFBFBD>Rn0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
pWnd->m_hWnd = hWnd;
// <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0-N.Yk0<EFBFBD>y<EFBFBD>RY0<EFBFBD>0:)
HWND hWndParent = ::GetParent( hWnd );
if( hWndParent ) {
RECT rcParent, rc;
::GetWindowRect( hWndParent, &rcParent );
::GetWindowRect( hWnd, &rc );
INT x = rcParent.left+(rcParent.right-rcParent.left)/2-(rc.right-rc.left)/2;
INT y = rcParent.top +(rcParent.bottom-rcParent.top)/2-(rc.bottom-rc.top)/2;
// DEBUGOUT( "X=%d Y=%d\n", x, y );
::SetWindowPos( hWnd, NULL, x, y, -1, -1, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
}
}
// CWnd* this<EFBFBD>0<EFBFBD>W<EFBFBD>0<EFBFBD><EFBFBD><EFBFBD>0g0B0<EFBFBD>0
CWnd* pWnd = (CWnd*)::GetWindowLong( hWnd, GWL_USERDATA );
if( pWnd ) {
return pWnd->DispatchDlg( hWnd, msg, wParam, lParam );
} else {
return FALSE;
}
}