Hello everybody,

The following code displays bitmaps correctly:

.ELSEIF uMsg==WM_PAINT

invoke BeginPaint,hStaticWin,ADDR Ps
mov hDC,eax
mov dwWidth,197
mov dwHeight,218
invoke PaintScaleProc,hStaticWin,hDC,dwWidth,dwHeight,hImage
invoke EndPaint,hStaticWin,ADDR Ps


PaintScaleProc proc hWnd:DWORD,hDC:DWORD,WidthBmp:DWORD,HeightBmp:DWORD,hBitMap:DWORD

LOCAL hOld :DWORD
LOCAL memDC :DWORD
LOCAL rect :RECT




invoke CreateCompatibleDC,hDC
mov memDC,eax

invoke SelectObject,memDC,hBitMap
mov hOld,eax
invoke GetClientRect,hWnd,addr rect

invoke StretchBlt,hDC,rect.left,rect.top,rect.right,rect.bottom,\
memDC,0,0,WidthBmp,HeightBmp,SRCCOPY

invoke SelectObject,hDC,hOld
invoke DeleteDC,memDC


ret


PaintScaleProc endp


the following code does not display bitmap:

.IF uMsg==WM_INITDIALOG

...
...
...


mov dwWidth,197
mov dwHeight,218
invoke PaintScaleProc,hStaticWin,hDC,dwWidth,dwHeight,hImage

I think I have a very poor understanding of GDI :o
Any help appreciated.

best regards,

czDrillard
Posted on 2003-11-13 10:03:46 by czDrillard
WM_INITDIALOG is sent "immediately before a dialog box is displayed". This would cause your GetClientRect call in your paint procedure to fail.

I don't know enough about graphics to give you a good alternative, but you'll need to find some function that is called AFTER the dialog box is displayed...you already said WM_PAINT works...how about WM_SIZE?
Posted on 2003-11-13 12:20:59 by sirchess
And you are using the variable hDC as a parameter which I assume has not yet been initialized for your dialog box when you process the WM_INITDIALOG message. Have you tried GetDC before calling your PaintScaleProc?

Raymond
Posted on 2003-11-13 23:27:25 by Raymond
Thanks for your answers.

sirchess : It works when called from WM_PAINT until the window is covered then uncoverered. No dialog controls are redrawn.

Raymond : My mistake cutting and pasting I actually use NULL in the call (unless calling from BeginPaint with the dc) and get DC in the proc as follows:

invoke PaintScaleProc,hStaticWin,NULL,dwWidth,dwHeight,hImage

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PaintScaleProc proc hWnd:DWORD,hdc:DWORD,WidthBmp:DWORD,HeightBmp:DWORD,hBitMap:DWORD

LOCAL OldDC :DWORD
LOCAL memDC :DWORD
LOCAL rect :RECT
LOCAL hDC :DWORD

;;;;;;;;;;;;;;;;;
invoke GetDC,hWnd ;included if not calling proc
mov hDC,eax ;from BeginPaint
;;;;;;;;;;;;;;;;;
invoke CreateCompatibleDC,hDC
mov memDC,eax

invoke SelectObject,memDC,hBitMap
mov OldDC,eax
invoke GetClientRect,hWnd,addr rect

invoke StretchBlt,hDC,rect.left,rect.top,rect.right,rect.bottom,\
memDC,0,0,WidthBmp,HeightBmp,SRCCOPY

invoke SelectObject,hDC,OldDC
invoke DeleteDC,memDC

invoke ReleaseDC,hDC,hWnd
ret


PaintScaleProc endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

It seems to me that the return value of GetDC and BeginPaint are not the same type of DC. Is this possible? The documentation indicates that they are interchangeable insofar as getting a DC to paint on. Or perhaps I am making some dumb mistake.

best regards,

czDrillard
Posted on 2003-11-14 09:51:04 by czDrillard
I am assuming you are still trying to use your PaintScaleProc while processing the WM_INITDIALOG message.

A few questions related to your last posted code.
invoke GetDC,hWnd
Where does the hWnd come from. Is it your dialog box handle? If so, did you get that value from the WM_INITDIALOG parameters?
invoke SelectObject,hDC,OldDC
The OldDC value came from the "memDC" when you selected the hBitMap object. Why select it in the hDC???
invoke ReleaseDC,hDC,hWnd
If that hDC handle is valid, it would not change until you exit the program (that would be your main window's DC). If necessary, you can release it only when you process the WM_CLOSE message. (I don't know if you can even release it before:confused: )

Raymond
Posted on 2003-11-14 13:46:20 by Raymond
Hello Raymond,

hWnd is the handle of a static window.
I'm not sure why I did some of the things the way that I did :o

I have included an attachment of the source file. If someone would take a look at it and make some suggestions I would appreciate it.


best regards,

czDrillard
Posted on 2003-11-14 20:48:22 by czDrillard