CreateWindow and apply a bitmap

Started by ml1969, May 17, 2009, 07:56:59 PM

Previous topic - Next topic

ml1969

Hello,

I have a problem.
I wrote an application for a WinCe Device (PNA).

I create a window with this lines:


HWND hWnd;
hWnd = CreateWindow(L"someClass", L"Dialog", WS_VISIBLE, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
ShowWindow (hWnd, nCmdShow);
UpdateWindow (hWnd);


It shows me a blanc window, I fill it with text like this:

CreateWindow( _T("STATIC"), _T("my text"), WS_CHILD | WS_VISIBLE | SS_CENTER, 10, 220 , 460, 15, hWnd, NULL, NULL, NULL);
UpdateWindow (hWnd);


it works very well,
now I will show a logo (bitmap) at the top, but it doesnt work.
I tried several things, bit it doesnt show me the resource


CreateWindow(_T("BITMAP"),MAKEINTRESOURCE(ID_BMP), WS_CHILD | WS_VISIBLE , 0,0,480,100, NULL, NULL, NULL, NULL);
UpdateWindow (hWnd);


Does anyone know what Im doing wrong?


Michael

Stefan Pendl

Have you tried to use the STATIC class and add the SS_BITMAP style to display the bitmap.
See Static Control Styles
---
Stefan

Proud member of the UltraDefrag Development Team

ml1969

Hello,

yes I tried severall things, also
CreateWindow(_T("STATIC"),MAKEINTRESOURCE(ID_BMP), WS_CHILD | WS_VISIBLE | SS_BITMAP, 0,0,480,100, NULL, NULL, NULL, NULL);
UpdateWindow (hWnd);


but i cannot see the image.
In case of the filesize, the bitmap is included as a resource, perhaps the way I call it is wrong....
I dont know.


Michael

DMac

Here's a small demo project that loads and displays a bitmap.

DMac
No one cares how much you know,
until they know how much you care.

ml1969

Hi,

thanks all of you :-)

I found a similar solution that works also :-)

HWND imgCtrl = CreateWindow( _T("STATIC"), NULL, SS_CENTERIMAGE | SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0 , 480, 90, hWnd, NULL, NULL, NULL);
SendMessage(imgCtrl,STM_SETIMAGE, (WPARAM)IMAGE_BITMAP,(LPARAM)hbit);

UpdateWindow (hWnd);


So I can continue with the next probs :-)


Michael