Beispiel #1
0
/* operations */
BOOL GenericWindow::Create (int x, int y, int cx, int cy, LPCTSTR title) {
	WINGUI_ASSERT (m_hWnd == NULL);

	WNDCLASSEX wcex;
	memset (&wcex, 0, sizeof(wcex));

	// Fill in window class attributes that usually won't change	
	wcex.lpfnWndProc = _wndProc;
	wcex.hInstance = _hAppInstance;

	// get additional window class attributes
	GetClassStyle (wcex);

	// register the window class only onece	
	WNDCLASSEX dummyClassInfo;
	if (!::GetClassInfoEx (_hAppInstance, wcex.lpszClassName, &dummyClassInfo))
	{
		RegisterClassEx (&wcex);
	}

	// get window creation styles
	DWORD dwStyle, dwExStyle;
	GetCreateStyle (dwStyle, dwExStyle);

	// create the window
	m_hWnd = ::CreateWindowEx ( dwExStyle, wcex.lpszClassName, title, dwStyle, 
								x, y, cx, cy, NULL, NULL, 
								wcex.hInstance, this );
	if (m_hWnd == NULL)
		return FALSE;

	OnCreate ();

	return TRUE;
}
Beispiel #2
0
    void WindowWnd::RegisterWindowClass()
    {
        WNDCLASS wc;
        ZeroMemory(&wc,sizeof(wc));
        wc.style = GetClassStyle();
        wc.lpfnWndProc =WindowManger::WndProc; //用自己的WndProc
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = SystemInfo::GetInstance()->GetProcessInstance();
        wc.hIcon = NULL;
        wc.hCursor = ::LoadCursor(NULL, IDC_ARROW);
        wc.hbrBackground = NULL;
        wc.lpszMenuName = NULL;
        wc.lpszClassName = GetWindowClassName();

        ATOM ret = ::RegisterClass( &wc );

        DWORD err = ::GetLastError();
        assert( ret !=0  || err == ERROR_CLASS_ALREADY_EXISTS );

        if( ret == 0  && err != ERROR_CLASS_ALREADY_EXISTS)
        {
            THROW_EXCEPTION(YYUIException()<<UIErrorStr(_T("Call RegisterClassEx Failed! :")+FormatGetLastError(err)));
        }

    }
Beispiel #3
0
bool CWindowWnd::RegisterWindowClass()
{
    WNDCLASS wc = { 0 };
    wc.style = GetClassStyle();
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hIcon = NULL;
    wc.lpfnWndProc = CWindowWnd::__WndProc;
    wc.hInstance = CPaintManagerUI::GetInstance();
    wc.hCursor = ::LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = NULL;
    wc.lpszMenuName  = NULL;
    wc.lpszClassName = GetWindowClassName();
    ATOM ret = ::RegisterClass(&wc);
    ASSERT(ret!=NULL || ::GetLastError()==ERROR_CLASS_ALREADY_EXISTS);
    return ret != NULL || ::GetLastError() == ERROR_CLASS_ALREADY_EXISTS;
}
Beispiel #4
0
bool CAWnd::RegisterWindowClass(LPCTSTR pstrClassName, HINSTANCE hInstance)
{
	WNDCLASS wc = { 0 };
	wc.style = GetClassStyle();
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hIcon = NULL;
	wc.lpfnWndProc = CAWnd::__WndProc;
	wc.hInstance = hInstance;
	wc.hCursor = ::LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = NULL;
	wc.lpszMenuName  = NULL;
	wc.lpszClassName = pstrClassName;
	ATOM ret = ::RegisterClass(&wc);
	assert(ret!=NULL || ::GetLastError()==ERROR_CLASS_ALREADY_EXISTS);
	return ret != NULL || ::GetLastError() == ERROR_CLASS_ALREADY_EXISTS;
}
bool CWindowWnd::RegisterWindowClass()
{
	WNDCLASS wc = { 0 };
	wc.style = GetClassStyle();
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hIcon = NULL;
	wc.lpfnWndProc = CWindowWnd::__WndProc;
	wc.hInstance = CPaintManagerUI::GetInstance();
#if defined(UI_BUILD_FOR_WIN32) && !defined(UI_BUILD_FOR_WINCE)
	wc.hCursor = ::LoadCursor(NULL, IDC_ARROW);
#else
	wc.hCursor = NULL;
#endif
	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
	wc.lpszMenuName  = NULL;
	wc.lpszClassName = GetWindowClassName();
	ATOM ret = ::RegisterClass(&wc);
	ASSERT(ret!=NULL || ::GetLastError()==ERROR_CLASS_ALREADY_EXISTS);
	return ret != NULL || ::GetLastError() == ERROR_CLASS_ALREADY_EXISTS;
}
Beispiel #6
0
static void
FreeWindow(HWND hWnd)
{
    HWND hWndFree,hWndFreeNext;
    HWND32 hWnd32;
    DWORD dwClassStyle;

    if (!(hWnd32 = GETHWND32(hWnd)))
	return;

    hWndFree = hWnd32->hWndChild;
    while (hWndFree) {
	hWndFreeNext = GetWindow(hWndFree,GW_HWNDNEXTSIB);
	FreeWindow(hWndFree);
	hWndFree = hWndFreeNext;
    }

    if (hWnd == GetActiveWindow()) {
	if (hWnd32->hWndOwner)
	    SetActiveWindow(hWnd32->hWndOwner);
	else
	    SetActiveWindow(TWIN_FindAnotherOverlapped(hWnd));
    }

    if (hWnd == GetFocus())
	SetFocus(0);
    if (hWnd == GetCapture())
	ReleaseCapture();

    if (!(hWnd32->dwStyle & WS_CHILD))
	if (hWnd32->hMenu) {
	    if (IsMenu(hWnd32->hMenu))
		DestroyMenu(hWnd32->hMenu);
	}
    if (hWnd32->hSysMenu) {
	if (IsMenu(hWnd32->hSysMenu))
	    DestroyMenu(hWnd32->hSysMenu);
    }

    /* NOTE: this used to be after releasing OWN/CLASS DC, but */
    /* at least one app does a GetDC(hWnd) during the NCDESTROY*/
    /* so, don't release it until after. The GetDC code needs  */
    /* the DC to maintain the hardware DC, (read gc for X11)   */

    /* send the last message to this window */
    SendMessage(hWnd,WM_NCDESTROY,0,0);

    /* get rid of DCs that may still be gotten */
    dwClassStyle = GetClassStyle(hWnd);
    if ((dwClassStyle & CS_OWNDC) && hWnd32->hDC)
	TWIN_GdiDestroyDC(hWnd32->hDC);

    if (!(hWnd32->dwStyle & WS_CHILD))
	/* physically destroy the window */
	DRVCALL_WINDOWS(PWSH_DESTROYWINDOW,0L,0L,
			WIN_GETDRVDATA(Get32WindowFrame(hWnd32)));

    if (hWnd32->UpdateRegion)
	DRVCALL_REGIONS(PRH_DESTROYREGION,hWnd32->UpdateRegion,0,0);

    LockClass(hWnd32->hWindowClass32,FALSE);

    SendMessage(Get32WindowFrame(hWnd32),WM_NCDESTROY,0,0L);
    FREEHWND(Get32WindowFrame(hWnd32));

    if (hWnd32->hWndHZScroll) {
	SendMessage(hWnd32->hWndHZScroll,WM_DESTROY,0,0L);
	FREEHWND(hWnd32->hWndHZScroll);
    }
    if (hWnd32->hWndVTScroll) {
	SendMessage(hWnd32->hWndVTScroll,WM_DESTROY,0,0L);
	FREEHWND(hWnd32->hWndVTScroll);
    }

    RELEASEWININFO(hWnd32);
    TWIN_FlushWindowMessages(hWnd);
    FREEHWND(hWnd);
}