NO

Author Topic: CreateWindow and apply a bitmap  (Read 6703 times)

ml1969

  • Guest
CreateWindow and apply a bitmap
« on: May 17, 2009, 07:56:59 PM »
Hello,

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

I create a window with this lines:

Code: [Select]
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:

Code: [Select]
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

Code: [Select]
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

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: CreateWindow and apply a bitmap
« Reply #1 on: May 18, 2009, 10:01:18 AM »
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

  • Guest
Re: CreateWindow and apply a bitmap
« Reply #2 on: May 18, 2009, 04:44:09 PM »
Hello,

yes I tried severall things, also
Code: [Select]
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

Offline DMac

  • Member
  • *
  • Posts: 272
Re: CreateWindow and apply a bitmap
« Reply #3 on: May 18, 2009, 07:20:26 PM »
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

  • Guest
Re: CreateWindow and apply a bitmap
« Reply #4 on: May 18, 2009, 07:58:31 PM »
Hi,

thanks all of you :-)

I found a similar solution that works also :-)

Code: [Select]
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