Board index » off-topic » Bitmap not shown

Bitmap not shown


2007-01-24 07:28:00 AM
off-topic11
Hi All,
I try to display a bitmap on the main window. It is shown well when I place
the following commands BEFORE creating main window but not AFTER its
creating. I must change the image during execution but I cannot :-(
All calls seem to be successful, they return "normal" results, not zero.
Thanks for any suggestion.
Ivan
;CALL BeginPaint,hWin,OFFSET Ps ; Ps: PAINTSTRUCT ; called if placed in
WM_PAINT event routine.
INT 3
CALL GetDC,hMainWindow
mov hDC, eax
CALL CreateCompatibleDC,EAX ; hDC
MOV hMemDC,EAX
;CALL DeleteObject,hMainBitmap ; deleting and new creation does not help
;CALL CreateBitmapIndirect,OFFSET BitmapStru
;MOV hMainBitmap,EAX
CALL SelectObject,hMemDC,hMainBitmap
CALL BitBlt,hDC,10,220,BitmapStru.bmWidth,BitmapStru.bmHeight,hMemDC, 0,
0,SRCCOPY
CALL DeleteDC,hMemDC
;CALL EndPaint,hWin,OFFSET Ps
;CALL UpdateWindow,hMainWindow ; DOES NOT HELP
 
 

Re:Bitmap not shown

Ivan Kossey wrote:
Quote
I try to display a bitmap on the main window. It is shown well when I place
the following commands BEFORE creating main window but not AFTER its
creating. I must change the image during execution but I cannot :-(
I suggest WM_PAINT as the place to paint the BMP.
You might also try BitBlt to 0,0 instead of 10,220
InvalidateRect() should cause paint to modify the bmp.
Quote
All calls seem to be successful, they return "normal" results, not zero.
This is my order:
case WM_PAINT:
if(First){First=FALSE;MakeMenu();}
SendMessage( ghWnd, WM_NCPAINT,0,0);
hdc=BeginPaint(hWnd,&ps);
hbmp = LoadBitmap(ghInst, bitmapname);
GetObject(hbmp, sizeof(BITMAP), &bm);
//hdc = GetDC(ghWnd);//use BeginPaint instead
hdcTemp = CreateCompatibleDC(hdc);
hbmpSaved = SelectObject(hdcTemp, hbmp);
BitBlt(hdc, 0,0, bm.bmWidth, bm.bmHe
SelectObject(hdcTemp, hbmpSaved);
DeleteDC(hdcTemp);
//ReleaseDC(ghWnd, hdc);// release if we used GetDc()
DeleteObject(hbmp);
EndPaint(hWnd,&ps);
return 0;
 

Re:Bitmap not shown

Thank You, Bob.
Now it works but only in WinXP, in Win2000 is the child window empty.
I did'nt include
GetObject(hbmp, sizeof(BITMAP), &bm);
I don't know what is bm. sizeof(BITMAP) is in pixels or in bytes?
The main problem was that is not enough to modify the bitmap. I must delete
the source bitmap and create it again. Moreover, the repaint procedure
called on WM_PAINT does not redrave the image because Windows does not send
the WM_PAINT MESSAGE. I made a Repaint procedure called from WM_PAINT
routine and from main window procedure after changing the image.
Regards
Ivan
"Bob Gonder" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote
Ivan Kossey wrote:

>I try to display a bitmap on the main window. It is shown well when I
place
>the following commands BEFORE creating main window but not AFTER its
>creating. I must change the image during execution but I cannot :-(

I suggest WM_PAINT as the place to paint the BMP.
You might also try BitBlt to 0,0 instead of 10,220
InvalidateRect() should cause paint to modify the bmp.

>All calls seem to be successful, they return "normal" results, not zero.

This is my order:

case WM_PAINT:
if(First){First=FALSE;MakeMenu();}
SendMessage( ghWnd, WM_NCPAINT,0,0);
hdc=BeginPaint(hWnd,&ps);
hbmp = LoadBitmap(ghInst, bitmapname);
GetObject(hbmp, sizeof(BITMAP), &bm);

//hdc = GetDC(ghWnd);//use BeginPaint instead
hdcTemp = CreateCompatibleDC(hdc);
hbmpSaved = SelectObject(hdcTemp, hbmp);

BitBlt(hdc, 0,0, bm.bmWidth, bm.bmHe

SelectObject(hdcTemp, hbmpSaved);
DeleteDC(hdcTemp);
//ReleaseDC(ghWnd, hdc);// release if we used GetDc()
DeleteObject(hbmp);
EndPaint(hWnd,&ps);
return 0;

 

{smallsort}

Re:Bitmap not shown

Ivan Kossey wrote:
Quote
I did'nt include
GetObject(hbmp, sizeof(BITMAP), &bm);
I don't know what is bm. sizeof(BITMAP) is in pixels or in bytes?
bm is a BITMAP
BITMAP is a standard Win32 structure.
sizeof() is number of bytes,
bm is used for the height/width of the BitBlt
Quote
>BitBlt(hdc, 0,0, bm.bmWidth, bm.bmHeight ....
The main problem was that is not enough to modify the bitmap. I must delete
the source bitmap and create it again.
Yes, I do that in Wm_Paint.....Create/Use/Delete
Quote
Moreover, the repaint procedure
called on WM_PAINT does not redrave the image because Windows does not send
the WM_PAINT MESSAGE. I made a Repaint procedure called from WM_PAINT
routine and from main window procedure after changing the image.
Windows should repaint if you call InvalidateRect( hWnd, NULL, TRUE )
after you change the image.
 

Re:Bitmap not shown

Thank You, Bob!
"Bob Gonder" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote
bm is a BITMAP
BITMAP is a standard Win32 structure.
sizeof() is number of bytes,

bm is used for the height/width of the BitBlt
>>BitBlt(hdc, 0,0, bm.bmWidth, bm.bmHeight ....


Windows should repaint if you call InvalidateRect( hWnd, NULL, TRUE )
after you change the image.