您的位置:程序门 -> windows专区 -> windows nt/2000/xp/2003



gdi绘图基础问题,有决心教会我的人进。。。


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


gdi绘图基础问题,有决心教会我的人进。。。[已结贴,结贴人:dahuatttt]
发表于:2007-05-20 10:42:33 楼主
我的思路很简单,建一个win窗口,在wm_create消息时获取窗口设备场景,createcompatibledc一份设备场景hdcback做幕后处理,在hdcback中绘画完后,invalidaterect主窗口。等待进入wm_paint消息处理,用bitblt把hdcback传给win窗口。
思路有问题么?。。。
下面是部分代码:
_wndmainproc proc uses   ebx   edi   esi,   \
hwnd:dword,umsg:dword,wparam:dword,lparam:dword

local @stps:paintstruct
local @hdc:dword
local @hbrush:dword

mov eax,umsg
.if eax   == wm_create
mov eax,hwnd
mov hwinmain,eax
call _init
;********************************************************************
.elseif eax   ==   wm_paint
invoke beginpaint,hwnd,addr   @stps
mov @hdc,eax

invoke drawtext,hdcback,addr   szclassname,-1,addr   @stps.rcpaint,\
dt_singleline   or   dt_center   or   dt_vcenter

mov eax,@stps.rcpaint.right
sub eax,@stps.rcpaint.left
mov ecx,@stps.rcpaint.bottom
sub ecx,@stps.rcpaint.top

invoke bitblt,@hdc,@stps.rcpaint.left,@stps.rcpaint.top,eax,ecx,\
hdcback,@stps.rcpaint.left,@stps.rcpaint.top,srccopy

invoke endpaint,hwnd,addr   @stps
;********************************************************************
.elseif eax   == wm_close
call _quit
;********************************************************************
.else
invoke defwindowproc,hwnd,umsg,wparam,lparam
ret
.endif
xor eax,eax
ret

_wndmainproc endp

_init proc
local @hdc:dword
local @strect:rect
local @hbrush:dword

invoke getclientrect,hwinmain,addr   @strect
invoke     getdc,hwinmain
mov @hdc,eax
invoke createcompatibledc,@hdc
mov hdcback,eax

invoke createhatchbrush,hs_diagcross,88888
invoke selectobject,hdcback,eax
invoke deleteobject,eax
invoke fillrect,hdcback,addr   @strect,@hbrush
invoke drawtext,hdcback,addr   szclassname,-1,addr   @strect,\
dt_singleline   or   dt_center   or   dt_vcenter

mov eax,@strect.right
sub eax,@strect.left
mov ecx,@strect.bottom
sub ecx,@strect.top

invoke bitblt,hdcback,@strect.left,@strect.top,eax,ecx,\
@hdc,@strect.left,@strect.top,srccopy

invoke releasedc,hwinmain,@hdc

invoke invalidaterect,hwinmain,addr   @strect,-1
ret
_init endp
发表于:2007-05-20 10:50:111楼 得分:0
还有就是,我想过一个怪问题,把新画刷选进createcompatibledc出来的dc后会不会使它与原窗口dc无法兼容导致无法bitblt成功?所以我自己在家也尝试过在原窗口dc中选入新画刷后再createcompatibledc的,还是不能显示图像。
发表于:2007-05-20 11:36:042楼 得分:30
用马甲顶下!
发表于:2007-05-20 13:01:223楼 得分:0
无限打捞
发表于:2007-05-20 17:48:294楼 得分:0
?


快速检索

最新资讯
热门点击