[Dev-C++] Problems with CreateWindow.
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: hhh h. <the...@ho...> - 2006-09-23 11:45:40
|
Hi all,
I am now learning about the WIN32 API functions, and I tryied to create an
application that listed the windows that are child to the desktop.
I got the code to work listing all the windows, and then i started to
designed a interface for my program.
Well, to make a long story short , I tryied to display a Image in my
parent window, by creating a child window ( with ws_child ) to my main one
, and LoadImage into it.
However my image never gets displayed.
Ps:
I checked the handles and they seem correct. Do keep in mind that i'm new to
windows API, if the code is too buggy.
[ the image is : 800x110 , .bmp ]
(Bellow i give a snippet of the code that I think relevant.)
--------------------------------------------------------
//Declaration of vars
HANDLE hImage;
HWND hwnd;
HWND ChildWnd5;
hThisInstance is arg to WinMain... nothing new here
Parent Window:
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
"MyClass", /* Classname */
"Window Lister", /* Title Text */
WS_CAPTION | WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, /* default
window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
900, /* The programs width */
800, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop
*/
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
--------------------------------
My Child Window :
ChildWnd5 = CreateWindowEx (
WS_EX_CLIENTEDGE ,
"Static",
"",
WS_CHILD | SS_BITMAP | WS_VISIBLE ,
0,0,800,110,
hwnd,
0,
hThisInstance,
0
);
----------------------------
Code Part :
if (ChildWnd5 = NULL)
MessageBox ( hwnd, "Child Window Handle is NULL", "Lin 131", MB_OK );
hImage = LoadImage ( hThisInstance , "banner.bmp", IMAGE_BITMAP, 800, 110,
LR_LOADFROMFILE );
if (hImage == NULL)
MessageBox ( hwnd, "The image handle is NULL.", "Lin 151", MB_OK );
SendMessage(
ChildWnd5,
STM_SETIMAGE,
IMAGE_BITMAP,
(LPARAM) hImage
);
ShowWindow(ChildWnd5,SW_SHOWNORMAL);
UpdateWindow(ChildWnd5);
_________________________________________________________________
MSN Hotmail, o maior webmail do Brasil. http://www.hotmail.com
|