controls:static [proof of concept]

Oleg Prokhorov xolegpro at rbcmail.ru
Mon May 3 02:36:42 CDT 2004


Hello wine-patches,

Some styles of static control improperly have DT_NOCLIP format flag.
This is not like windows does it. The problem appears when size of control is too small.

This problem was showed by wxwidgets controls sample.

This message includes simple testing program for this bug,
and also Windows'2000 screenshot.

Btw: SS_SIMPLE in wine has another bug - wrong colour, but that's
another story.



-- 
Best regards,
 Oleg                          mailto:xolegpro at rbcmail.ru
-------------- next part --------------
A non-text attachment was scrubbed...
Name: static.diff
Type: application/octet-stream
Size: 857 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20040503/d64279ad/static.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Clipboard.png
Type: image/png
Size: 4937 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20040503/d64279ad/Clipboard.png
-------------- next part --------------
#include <windows.h>

HINSTANCE hInst;

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
	static HWND hLeftLabel, hCenterLabel, hRightLabel, hSimpleLabel;
	static HWND hLeftText, hCenterText, hRightText, hSimpleText;;
	static int cxChar, cyChar;
	int width;

    switch (msg) {
    case WM_CREATE:
        hLeftLabel = CreateWindowEx(0, "STATIC", "Left aligned",
		WS_CHILD | WS_VISIBLE | SS_LEFT,
		0, 0, 0, 0, hwnd, (HMENU) -1, hInst, NULL);

        hCenterLabel = CreateWindowEx(0, "STATIC", "Center aligned",
		WS_CHILD | WS_VISIBLE | SS_LEFT,
		0, 0, 0, 0, hwnd, (HMENU) -1, hInst, NULL);

        hRightLabel = CreateWindowEx(0, "STATIC", "Right aligned",
		WS_CHILD | WS_VISIBLE | SS_LEFT,
		0, 0, 0, 0, hwnd, (HMENU) -1, hInst, NULL);

        hSimpleLabel = CreateWindowEx(0, "STATIC", "Simple aligned",
		WS_CHILD | WS_VISIBLE | SS_SIMPLE,
		0, 0, 0, 0, hwnd, (HMENU) -1, hInst, NULL);

        hLeftText = CreateWindowEx(0, "STATIC", "Left aligned",
		WS_CHILD | WS_VISIBLE | SS_LEFT,
		0, 0, 0, 0, hwnd, (HMENU) -1, hInst, NULL);

        hCenterText = CreateWindowEx(0, "STATIC", "Center aligned",
		WS_CHILD | WS_VISIBLE | SS_CENTER,
		0, 0, 0, 0, hwnd, (HMENU) -1, hInst, NULL);

        hRightText = CreateWindowEx(0, "STATIC", "Right aligned",
		WS_CHILD | WS_VISIBLE | SS_RIGHT,
		0, 0, 0, 0, hwnd, (HMENU) -1, hInst, NULL);

        hSimpleText = CreateWindowEx(0, "STATIC", "Simple aligned",
		WS_CHILD | WS_VISIBLE | SS_SIMPLE,
		0, 0, 0, 0, hwnd, (HMENU) -1, hInst, NULL);

	cxChar = cyChar = -1;

	break;
    case WM_SIZE:
	width = LOWORD(lparam);
	if (cxChar == -1) {
		HDC hdc = GetDC(hwnd);
		TEXTMETRIC tm;
		GetTextMetrics(hdc, &tm);
		cxChar = tm.tmAveCharWidth;
		cyChar = tm.tmHeight + tm.tmExternalLeading;
		ReleaseDC(hwnd, hdc);
	}
	MoveWindow(hLeftLabel, cxChar, 0, cxChar*20, cyChar, TRUE);
	MoveWindow(hCenterLabel, cxChar, cyChar*4, cxChar*20, cyChar, TRUE);
	MoveWindow(hRightLabel, cxChar, cyChar*8, cxChar*20, cyChar, TRUE);
	MoveWindow(hSimpleLabel, cxChar, cyChar*12, cxChar*20, cyChar, TRUE);
	MoveWindow(hLeftText, width/2, 0, cxChar*8, cyChar, TRUE);
	MoveWindow(hCenterText, width/2, cyChar*4, cxChar*8, cyChar, TRUE);
	MoveWindow(hRightText, width/2, cyChar*8, cxChar*8, cyChar, TRUE);
	MoveWindow(hSimpleText, width/2, cyChar*12, cxChar*8, cyChar, TRUE);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    }
    return DefWindowProc(hwnd, msg, wparam, lparam);
}

int WINAPI WinMain(HINSTANCE instance, HINSTANCE prev, LPSTR cmdLine, int cmdShow)
{
    WNDCLASSEX class;
    MSG msg;
    HWND window;

    /* this stuff is just boilerplate */
    memset(&class, 0, sizeof(WNDCLASSEX));
    class.cbSize = sizeof(WNDCLASSEX);
    class.hInstance = instance;
    class.lpszClassName = "MainWnd";
    class.lpfnWndProc = WndProc;
    class.hbrBackground = (HBRUSH) COLOR_WINDOW ;

    if (!RegisterClassEx(&class)) {
        MessageBox(NULL, "Could not register window class", "", MB_OK | MB_ICONERROR);
        return 1;
    }

    window = CreateWindowEx(0, "MainWnd", "Main Window", WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX,
                            CW_USEDEFAULT, CW_USEDEFAULT, 400, 400, NULL, NULL, instance, NULL);
    ShowWindow(window, cmdShow);

    /* Every thread that creates a window must pump the message loop */
    while (GetMessage(&msg, NULL, 0, 0)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    
    return 0;
}


More information about the wine-devel mailing list