NO

Author Topic: hbrBackground and createwindow with wince  (Read 5707 times)

ml1969

  • Guest
hbrBackground and createwindow with wince
« on: August 22, 2009, 05:14:12 PM »
Hello,

ists me again  ;D

I want to change the backgroundcolor of my window.

I tried the following code:
Code: [Select]
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpszCmdLine, int nCmdShow)
{
    WNDCLASS wc;

    ghInstance = hInstance;

    if (!GetClassInfo(NULL, L"Dialog", &wc))
        return 0;

    HBRUSH MyBrush  = CreateSolidBrush((COLORREF)  RGB (10,10,10) );

   wc.hInstance = hInstance;
   wc.style         = CS_HREDRAW | CS_VREDRAW;
   //wc.cbClsExtra    = 0;
   //wc.cbWndExtra    = 0;
   wc.hCursor       = 0;
   wc.lpszMenuName  = 0;
   wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDR_ICO_MAIN));
   wc.lpszClassName = L"Desktop";
   wc.hbrBackground = MyBrush;

    if (!RegisterClass(&wc))
        return 0;


    HWND hWnd = CreateWindow(L"Desktop",
                    L"Desktop.Class",
                    WS_CLIPCHILDREN,
    0,
                    0,
                    240,
                    136,   
                    NULL,
                    NULL,
                    hInstance,
                    NULL);


ShowWindow (hWnd, nCmdShow);
UpdateWindow (hWnd);


Sleep(10000);

    return 0;
}




nothing happens, alos I use:
wc.hbrBackground = GetStockObject(GRAY_BRUSH);
wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);

tried severall thing, only if I include this
wc.cbClsExtra    = 0;
wc.cbWndExtra    = 0;
I can se how black and white vertical lines come to the display... and I must rebott the wince device.


Whats wrong on the code? Or Perhaps does this not work with WinCe?


Michael

Kaljj

  • Guest
Re: hbrBackground and createwindow with wince
« Reply #1 on: September 21, 2009, 12:23:31 PM »
Hello Michael,

I have not a running system at the moment, but i have two
remarks for you.

1) In WindowCreate you set only the WS_CLIPCHILDREN.
I have learn, that define was Window must do when a child is visble.
So I thing you must only write WS_VISIBLE and if you like WS_SYSMENU


I have copy a the basic framework for WindowMobile from msdn if you like I send it to you.


2) It typical MS that is better to define the background in the
WM_CREATE - section. I dont know why but it works :-)


Kaljj
(Sorry for my bad english. I'm german)