Beispiel #1
0
//窗口创建,实际上还是调用了windows api函数CreateWindowEx 
HWND CWindowWnd::Create(HWND hwndParent, LPCTSTR pstrName, DWORD dwStyle, DWORD dwExStyle, int x, int y, int cx, int cy, HMENU hMenu)
{
    if( GetSuperClassName() != NULL && !RegisterSuperclass() ) 
		return NULL;
    if( GetSuperClassName() == NULL && !RegisterWindowClass() ) 
		return NULL;
    m_hWnd = ::CreateWindowEx(dwExStyle, GetWindowClassName(), pstrName, dwStyle, x, y, cx, cy, hwndParent, hMenu, CPaintManagerUI::GetInstance(), this);
    ASSERT(m_hWnd!=NULL);
    return m_hWnd;
}
Beispiel #2
0
BOOL	NativeWindow::Create(HWND hwndParent, LPCTSTR pstrName, DWORD dwStyle, DWORD dwExStyle, int x /* = CW_USEDEFAULT */, int y /* = CW_USEDEFAULT */, int cx /* = CW_USEDEFAULT */, int cy /* = CW_USEDEFAULT */, HMENU hMenu /* = NULL */)
{
	BOOL created = FALSE;
	if (GetSuperClassName() != NULL)
	{
		if (!RegisterSuperClass())
		{
			return FALSE;
		}
	}
	else
	{
		if(!RegisterWindowClass())
		{
			return FALSE;
		}
	}

	hwnd_ = ::CreateWindowEx(dwExStyle, GetWindowClassName(), pstrName, dwStyle, x, y, cx, cy, hwndParent, hMenu, NULL, this);
	if (hwnd_ != NULL)
	{
		created = AfterCreated();
	}
	return created;
}
Beispiel #3
0
    void WindowWnd::RegisterSuperClass()
    {
        //!!目前还不知道有什么用
        //功能是如下
        // Get the class information from an existing
        // window so we can subclass it later on...
        //为什么是ControlProc不明白
        WNDCLASSEX wc;
        ZeroMemory(&wc, sizeof(wc));
        wc.cbSize = sizeof(wc);
        if( !::GetClassInfoEx( NULL, GetSuperClassName() , &wc) )
        {
          /*  if( !::GetClassInfoEx(PaintManagerUI::GetInstance(),GetSuperClassName(),&wc))
            {
                THROW_EXCEPTION(YYUIException()<< UIErrorStr(_T("找不到Register Class Name"))); 
            }*/
        }
        m_OldWndProc = wc.lpfnWndProc;
        wc.lpfnWndProc = WindowWnd::ControlProc;
        wc.hInstance = SystemInfo::GetInstance()->GetProcessInstance();;
        wc.lpszClassName = GetWindowClassName();

        ATOM hr = ::RegisterClassEx(&wc);
        assert( hr !=0  || hr == ERROR_CLASS_ALREADY_EXISTS );

        if( hr == 0  && hr != ERROR_CLASS_ALREADY_EXISTS)
        {
            THROW_EXCEPTION(YYUIException()<<UIErrorStr(_T("Call RegisterClassEx Failed! :")+FormatGetLastError(hr)));
        }
    }
Beispiel #4
0
BOOL	NativeWindow::RegisterSuperClass()
{
	WNDCLASSEX wc = {0};
	wc.cbSize = sizeof(WNDCLASSEX);
	if(!::GetClassInfoEx(NULL, GetSuperClassName(), &wc))
	{
		if( !::GetClassInfoEx(NULL, GetSuperClassName(), &wc) ) 
		{
			return FALSE;
		}
	}
	old_window_proc_ = wc.lpfnWndProc;
	wc.lpfnWndProc = NativeWindow::StaticHandleMessages;
	wc.hInstance = NULL;
	wc.lpszClassName = GetWindowClassName();
	ATOM result = ::RegisterClassEx(&wc);
	return result != NULL || ::GetLastError() == ERROR_CLASS_ALREADY_EXISTS;
}
Beispiel #5
0
bool CWindowWnd::RegisterSuperclass()
{
    // Get the class information from an existing
    // window so we can subclass it later on...
    WNDCLASSEX wc = { 0 };
    wc.cbSize = sizeof(WNDCLASSEX);
    if( !::GetClassInfoEx(NULL, GetSuperClassName(), &wc) ) {
        if( !::GetClassInfoEx(CPaintManagerUI::GetInstance(), GetSuperClassName(), &wc) ) {
            ASSERT(!"Unable to locate window class");
            return NULL;
        }
    }
    m_OldWndProc = wc.lpfnWndProc;
    wc.lpfnWndProc = CWindowWnd::__ControlProc;
    wc.hInstance = CPaintManagerUI::GetInstance();
    wc.lpszClassName = GetWindowClassName();
    ATOM ret = ::RegisterClassEx(&wc);
    ASSERT(ret!=NULL || ::GetLastError()==ERROR_CLASS_ALREADY_EXISTS);
    return ret != NULL || ::GetLastError() == ERROR_CLASS_ALREADY_EXISTS;
}
bool CWindowWnd::RegisterSuperclass()
{
	// Get the class information from an existing
	// window so we can subclass it later on...
#if defined(UI_BUILD_FOR_WIN32) && !defined(UI_BUILD_FOR_WINCE)
	WNDCLASSEX wc = { 0 };
	wc.cbSize = sizeof(WNDCLASSEX);
	if( !::GetClassInfoEx(NULL, GetSuperClassName(), &wc) ) {
		if( !::GetClassInfoEx(CPaintManagerUI::GetInstance(), GetSuperClassName(), &wc) ) {
			ASSERT(!"Unable to locate window class");
			return NULL;
		}
	}
	m_OldWndProc = wc.lpfnWndProc;
	wc.lpfnWndProc = CWindowWnd::__ControlProc;
	wc.hInstance = CPaintManagerUI::GetInstance();
	wc.lpszClassName = GetWindowClassName();
	ATOM ret = ::RegisterClassEx(&wc);
#else
	WNDCLASS wc = { 0 };

	if( !::GetClassInfo(NULL, GetSuperClassName(), &wc) ) {
		if( !::GetClassInfo(CPaintManagerUI::GetInstance(), GetSuperClassName(), &wc) ) {
			ASSERT(!"Unable to locate window class");
			return NULL;
		}
	}

	wc.hbrBackground = (HBRUSH)::GetStockObject(WHITE_BRUSH);
	wc.hCursor		 = ::LoadCursor(NULL, IDC_ARROW);
	m_OldWndProc = wc.lpfnWndProc;
	wc.lpfnWndProc = CWindowWnd::__ControlProc;
	wc.hInstance = CPaintManagerUI::GetInstance();
	wc.lpszClassName = GetWindowClassName();
	ATOM ret = ::RegisterClass(&wc);
#endif
	ASSERT(ret!=NULL || ::GetLastError()==ERROR_CLASS_ALREADY_EXISTS);
	return ret != NULL || ::GetLastError() == ERROR_CLASS_ALREADY_EXISTS;
}
Beispiel #7
0
    HWND WindowWnd::Create(HWND hWndParent, LPCTSTR pstrName, DWORD dwStyple, DWORD dwExStyle, int x /*= CW_USEDEFAULT*/, int y /*= CW_USEDEFAULT*/, int cx /*= CW_USEDEFAULT*/, int cy /*= CW_USEDEFAULT*/, HMENU hMenu /*= NULL*/)
    {
        try
        {

            if( GetSuperClassName() != nullptr )
                RegisterSuperClass();   //如果SuperClassName存在的话就创建SuperClass
            else
                RegisterWindowClass();
            m_hWnd = CreateWindowEx( dwExStyle, GetWindowClassName(), pstrName, dwStyple, x, y, cx, cy, hWndParent, hMenu, SystemInfo::GetInstance()->GetProcessInstance(),this);
            
            assert( m_hWnd != NULL );
            return m_hWnd;
        }
        catch( ... )
        {
            throw;
        }
    }