コード例 #1
0
ファイル: common_windows.c プロジェクト: sjn1978/ui
void paintControlBackground(HWND hwnd, HDC dc)
{
    HWND parent;
    RECT r;
    POINT p, pOrig;

    parent = hwnd;
    for (;;) {
        parent = GetParent(parent);
        if (parent == NULL)
            xpanic("error getting parent control of control in paintControlBackground()", GetLastError());
        // wine sends these messages early, yay...
        if (parent == msgwin)
            return;
        // skip groupboxes; they're (supposed to be) transparent
        if (windowClassOf(parent, L"button", NULL) != 0)
            break;
    }
    if (GetWindowRect(hwnd, &r) == 0)
        xpanic("error getting control's window rect in paintControlBackground()", GetLastError());
    // the above is a window rect; convert to client rect
    p.x = r.left;
    p.y = r.top;
    if (ScreenToClient(parent, &p) == 0)
        xpanic("error getting client origin of control in paintControlBackground()", GetLastError());
    if (SetWindowOrgEx(dc, p.x, p.y, &pOrig) == 0)
        xpanic("error moving window origin in paintControlBackground()", GetLastError());
    SendMessageW(parent, WM_PRINTCLIENT, (WPARAM) dc, PRF_CLIENT);
    if (SetWindowOrgEx(dc, pOrig.x, pOrig.y, NULL) == 0)
        xpanic("error resetting window origin in paintControlBackground()", GetLastError());
}
コード例 #2
0
ファイル: main.c プロジェクト: mantyr/libui
void uiMain(void)
{
	MSG msg;
	int res;
	HWND active, focus;

	for (;;) {
		SetLastError(0);
		res = GetMessageW(&msg, NULL, 0, 0);
		if (res < 0)
			logLastError("error calling GetMessage() in uiMain()");
		if (res == 0)		// WM_QUIT
			break;
		active = GetActiveWindow();
		if (active == NULL) {
			msgloop_else(&msg);
			continue;
		}

		// bit of logic involved here:
		// we don't want dialog messages passed into Areas, so we don't call IsDialogMessageW() there
		// as for Tabs, we can't have both WS_TABSTOP and WS_EX_CONTROLPARENT set at the same time, so we hotswap the two styles to get the behavior we want
		focus = GetFocus();
		if (focus != NULL) {
			switch (windowClassOf(focus, L"TODO Area not yet implemented", NULL)) {
			case 0:		// uiArea
//				msgloop_area(active, focus, &msg);
				continue;
			}
			// else fall through
		}

		if (IsDialogMessage(active, &msg) != 0)
			continue;
		msgloop_else(&msg);
	}
}
コード例 #3
0
ファイル: common_windows.c プロジェクト: sjn1978/ui
BOOL sharedWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
{
    switch (uMsg) {
    case WM_COMMAND:
        *lResult = forwardCommand(hwnd, uMsg, wParam, lParam);
        return TRUE;
    case WM_NOTIFY:
        *lResult = forwardNotify(hwnd, uMsg, wParam, lParam);
        return TRUE;
    case WM_CTLCOLORSTATIC:
    case WM_CTLCOLORBTN:
        // read-only TextFields and Textboxes are exempt
        // this is because read-only edit controls count under WM_CTLCOLORSTATIC
        if (windowClassOf((HWND) lParam, L"edit", NULL) == 0)
            if (textfieldReadOnly((HWND) lParam))
                return FALSE;
        if (SetBkMode((HDC) wParam, TRANSPARENT) == 0)
            xpanic("error setting transparent background mode to Labels", GetLastError());
        paintControlBackground((HWND) lParam, (HDC) wParam);
        *lResult = (LRESULT) hollowBrush;
        return TRUE;
    }
    return FALSE;
}