怎样强制刷新窗口的非客户区域? 即:三维边匡和标题条等 (100分)

  • 主题发起人 主题发起人 stanely
  • 开始时间 开始时间
S

stanely

Unregistered / Unconfirmed
GUEST, unregistred user!
我猜可能是发送一个wm_ncpaint消息,但是wparam参数即hrgn怎么办?<br><br>我的目的是做一个能够刷新control以及以他为parent的所有control的客户区和非客户区的函数,但是如下不能刷新Tform的三维边匡和标题栏,也听不到beep。 <br><br>请指教!!!!<br><br><br>procedure RefreshGroupControls(group: tcontrol);<br>var<br>i:integer;<br>rgn,wrgn,crgn:hrgn;<br>wr:trect;<br>begin<br><br>&nbsp; &nbsp;if nil=group then exit; &nbsp; <br>&nbsp; &nbsp;group.repaint;<br>&nbsp; &nbsp;if group is twincontrol then<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp;with twincontrol(group) do<br>&nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;getwindowrect(handle,wr);<br>&nbsp; &nbsp; &nbsp; &nbsp;rgn:=CreateRectRgnIndirect(clientrect);<br>&nbsp; &nbsp; &nbsp; &nbsp;crgn:=CreateRectRgnIndirect(clientrect);<br>&nbsp; &nbsp; &nbsp; &nbsp;wrgn:=CreateRectRgnIndirect(wr);<br><br>&nbsp; &nbsp; &nbsp; &nbsp;if CombineRgn(rgn,wrgn,crgn,RGN_DIFF)=ERROR then beep;<br><br>&nbsp; &nbsp; &nbsp; &nbsp;sendmessage(handle,wm_ncpaint,rgn,0);<br>&nbsp; &nbsp; &nbsp; &nbsp;deleteobject(wrgn);<br>&nbsp; &nbsp; &nbsp; &nbsp;deleteobject(crgn);<br>&nbsp; &nbsp; &nbsp; &nbsp;deleteobject(rgn);<br>&nbsp; &nbsp; &nbsp; &nbsp;//application.ProcessMessages;<br>&nbsp; &nbsp; &nbsp; &nbsp;for i:=0 to ControlCount-1 do<br>&nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RefreshGroupControls(Controls);<br>&nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp;end;<br><br>&nbsp; &nbsp;end;<br>end;
 
运行结果没有听到beep,也没有刷新标题栏和三维边匡...<br>why?
 
不懂 问问哈, nil=group 这样写可以吗? 最好写成 group=nil 吧? 有没有跟踪进去看看?
 
进去跟踪了一下 ,确实 条件不成立。<br>if CombineRgn(rgn,wrgn,crgn,RGN_DIFF)=ERROR &nbsp;<br>&nbsp;then beep;<br><br>
 
由于groupcontrol是子窗口,所以它的非client区域的刷新位置是在parent的dc上,所以你光给子控件发wm_ncpaint无法刷新它的非client区域。其实只要发wm_ncpaint的同时调用一下InvalidateRect设置它的parent同时更新相应区域即可。
 
后退
顶部