关于不规则窗体的问题 ( 积分: 100 )

  • 主题发起人 主题发起人 moko
  • 开始时间 开始时间
M

moko

Unregistered / Unconfirmed
GUEST, unregistred user!
小弟刚学delphi 也刚接触编程,类似这样低级问题多的事,以后有你们的苦了<br><br>劳驾闪开闪开,让高手进来!!![:D]<br><br>想创建一个中空的窗体,就是窗体中间有一个矩形或圆等不规则的透明的区域<br>和透明还不同,如果是透明当点击透明区域时 窗体会被激活并在上方,如果中空当点击透明区域的时会对后面的窗体操作<br>问如何能做到这样的效果
 
小弟刚学delphi 也刚接触编程,类似这样低级问题多的事,以后有你们的苦了<br><br>劳驾闪开闪开,让高手进来!!![:D]<br><br>想创建一个中空的窗体,就是窗体中间有一个矩形或圆等不规则的透明的区域<br>和透明还不同,如果是透明当点击透明区域时 窗体会被激活并在上方,如果中空当点击透明区域的时会对后面的窗体操作<br>问如何能做到这样的效果
 
procedure TForm1.FormCreate(Sender: TObject);<br>var<br> &nbsp; mFullRgn, mClientRgn, mButtonRgn, mButtonCoverRgn: THandle;<br> &nbsp; mLeftMargin,mTopMargin:Integer;<br> &nbsp; mMargin, mX, mY: Integer;<br> &nbsp; mInt:integer;<br>begin<br> &nbsp;mMargin := (Width - ClientWidth) div 2;<br> &nbsp;mFullRgn := CreateRectRgn(0, 0, Width, Height);<br> &nbsp;mLeftMargin := mMargin;<br> &nbsp;mTopMargin := Height - ClientHeight - mMargin;<br> &nbsp;mClientRgn := CreateRectRgn(mLeftMargin, mTopMargin, mLeftMargin + ClientWidth, mTopMargin + ClientHeight);<br> &nbsp;CombineRgn(mFullRgn, mFullRgn, mClientRgn, RGN_DIFF); &nbsp;<br><br> &nbsp;for mInt:= 0 to ComponentCount-1 do<br> &nbsp;begin<br> &nbsp; &nbsp;if not (Components[mInt] is TWinControl) then continue;<br> &nbsp; &nbsp;if (Components[mInt] as TWinControl).Parent&lt;&gt;self then continue;<br> &nbsp; &nbsp;mX := mLeftMargin + (Components[mInt] as TWinControl).Left ;<br> &nbsp; &nbsp;mY := mTopMargin + (Components[mInt] as TWinControl).Top &nbsp;;<br> &nbsp; &nbsp;mButtonRgn := CreateRectRgn(mX, mY, mX + (Components[mInt] as TWinControl).Width , mY + (Components[mInt] as TWinControl).Height);<br> &nbsp; &nbsp;CombineRgn(mFullRgn, mFullRgn, mButtonRgn, RGN_OR); &nbsp; &nbsp; <br> &nbsp; &nbsp;mButtonCoverRgn := CreateRectRgn(mX+2, mY+2, mX + (Components[mInt] as TWinControl).Width-4 , mY + (Components[mInt] as TWinControl).Height-4); &nbsp; &nbsp; <br> &nbsp; &nbsp;CombineRgn(mFullRgn, mFullRgn, mButtonCoverRgn, RGN_DIFF);<br> &nbsp;end;<br><br> &nbsp;SetWindowRgn(Handle, mFullRgn, True);<br>end;
 
看不到说要高手,我就不回答了。。。本来想赚几分。
 
procedure TForm1.FormCreate(Sender: TObject);<br><br>var<br> &nbsp;hRegion: THandle;<br>begin<br> &nbsp;hRegion := CreateEllipticRgn(0, -Height, Width, Height);<br> &nbsp;SetWindowRgn(Handle, hRegion, True);<br>end;
 
1. procedure TForm1.Button1Click(Sender: TObject);(小圆变大圆)<br> var<br> &nbsp; &nbsp;r:thandle;<br> &nbsp; &nbsp;i:integer;<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;for i:=1 to trunc(width/1.414) do<br> &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;r:=CreateEllipticRgn(trunc(width/2)-i,trunc(height/2)-i,trunc(width/2)+i,trunc(height/2)+i);<br> &nbsp; &nbsp; &nbsp; &nbsp;SetWindowRgn(handle,r,true);<br> &nbsp; &nbsp; &nbsp; &nbsp;Application.ProcessMessages;<br> &nbsp; &nbsp; &nbsp; &nbsp;sleep(1);<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp;end;
 
这些代码只有kanGaXX 的符合要求 窗口中间是矩形 &nbsp;谢谢 楼上所有人
 
后退
顶部