The MASM Forum

General => The Workshop => Topic started by: xanatose on March 16, 2022, 06:38:43 AM

Title: Is it possible to render a window to a bitmap without showing the window?
Post by: xanatose on March 16, 2022, 06:38:43 AM
I basically need to render win32 controls on an OpenGL application. Letting windows handle the UI. (Specially the text input in other languages). While allowing transformation of the windows rectangles in 3d.

Title: Re: Is it possible to render a window to a bitmap without showing the window?
Post by: Greenhorn on March 16, 2022, 11:07:30 PM
Hi xanatose,

I have no idea what you try to do but anyways ...


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;    CreateBitmapFromCtrl
;
CreateBitmapFromCtrl proc hwndCtrl:HWND

LOCAL hdc: HDC
LOCAL hbm: HBITMAP
LOCAL hObjOld: HGDIOBJ
LOCAL rc: RECT

invoke GetClientRect, hwndCtrl, addr rc

invoke CreateCompatibleDC, 0

.if (rax)
mov  hdc, rax
.else
jmp  @F
.endif

invoke CreateCompatibleBitmap, hdc, rc.right, rc.bottom

.if (rax)
mov  hbm, rax
.else
invoke DeleteDC, hdc
jmp  @F
.endif

invoke SelectObject, hdc, hbm

mov  hObjOld, rax

invoke SendMessage, hwndCtrl, WM_PRINTCLIENT, hdc, PRF_CLIENT

invoke SelectObject, hdc, hObjOld
invoke DeleteDC, hdc

mov  rax, hbm
@@:
ret
CreateBitmapFromCtrl endp


Kind Regards
Greenhorn