From: carlos on
Hello. Please someone can help me with the next code:
I try to put in console the bitmap IMAGE.bmp
It do this, but when I minimize the console window or move the
scrollbar, the image is clear.
How I can fix this ?

//Code:
#include <windows.h>
#include <stdio.h>

int main()
{
HWND parent;
HWND panel;
HBITMAP img;
long style;

parent = FindWindowA("ConsoleWindowClass", NULL);
style = SS_BITMAP|WS_VISIBLE|WS_CHILD;


panel = CreateWindowEx(
0
,"STATIC"
,NULL
,style
,1
,1
,0
,0
,parent
,(HMENU)-1
,GetModuleHandle(0),NULL
);

img = (HBITMAP)LoadImage(
NULL
,"IMAGE.bmp"
,IMAGE_BITMAP
,0
,0
,LR_LOADFROMFILE
);

img = (HBITMAP)CopyImage(
img
,IMAGE_BITMAP
,300
,300
,LR_COPYRETURNORG
);

SendMessage(
panel
,STM_SETIMAGE
,(WPARAM)IMAGE_BITMAP
,(LPARAM)img
);

getchar();
return 0;
}
From: Leo Davidson on
On Apr 16, 3:30 am, carlos <cmonti...(a)gmail.com> wrote:
> It do this, but when I minimize the console window or move the
> scrollbar, the image is clear.

Your process is creating a window and then exiting.

When a process exits all its windows are destroyed.

I'm surprised the bitmap even stays until it is minimized. I guess the
console window doesn't repaint itself until then as it isn't expecting
to have child windows opening and closing over it.
From: Leo Davidson on
On Apr 16, 8:51 am, Leo Davidson <leonudeldavid...(a)googlemail.com>
wrote:
> Your process is creating a window and then exiting.

Sorry, I missed the getchar call at the end of your program.

Your program won't be exiting, but it also won't be running a message
loop which means it will not paint any of its windows while waiting
for a character.

You need to run a GetMessage/DispatchMessage loop at the end of your
program.