hehe, my e-mail :[email protected]
解决方案 »
- 请问:软件运行前的设置界面显示'第一次运行软件,正在设置...'等信息的东东叫什么?如何做出这种东东呢?
- 关于TWebBrowser和Word文档的问题
- 大侠们给推荐几个关于软件工程的书吧!(帮朋友找的)谢谢!!
- 请问如何调用dll文件中的函数?
- D7的RAVE报表支持BDE不支持ADO????那我拿ADO连接数据库的时候,用什么控件啊!!
- access 在什么地方能敲入sql 语句并运行?
- 没问题可提,可用分太多。散分。
- 高薪诚聘:手机应用开发工程师
- 广州创业公司急聘全职Delphi/java工程师
- 统计问题???
- 关于设置ado
- 用SQL来查询关于DATE字段的问题!!! 总是说类型不配!! 请指教!!!
procedure TFrmMain.FormCreate(Sender: TObject);
var
rgn:HRGN;
begin
rgn:=CreateEllipticRgn(0,0,150,150);
SetWindowRgn(self.Handle, rgn, true);
end;
更一般的用CreatePolygonRgn代替CreateEllipticRgn就可以做出任意形状的窗体了四四方方的窗体也会变形,利用win32 API函数setwindowrgn就可以将窗口定义为任何形状,以下是将窗口定义为园角矩形的例子:
procedure TPortForm.FormCreate(Sender: Tobject);
var hr :thandle;
begin
hr:=createroundrectrgn(0,0,width,height,20,20);//定义园角矩形(win API函数)
setwindowrgn(handle,hr,true); //设置园角窗口
end;
为了使该窗口更好,应在onResize事件处理程序放相同的代码。
/////////////////////////////////////
用汉字做窗体形状
procedure TForm1.FormCreate(Sender: TObject);
var
rgn:HRGN;
begin
BeginPath(Canvas.Handle);
SetBkMode( Canvas.Handle, TRANSPARENT );
Canvas.Font.Name:= '宋体';
Canvas.Font.Size:=100;
Canvas.TextOut( 20, 20, '漂亮吗?');//用"漂亮吗?"作为form的形状
EndPath(Canvas.Handle);
rgn:= PathToRegion(Canvas.Handle);
SetWindowRgn( Handle, rgn, true );
end;
.........................
怎么才能生成象mediaplayer 7.0那样的rgn:HRGN
[email protected]
这里先贴另一片文章:怎样做一个和位图的形状一样的窗体
Example
-------Global Variables
----------------
(In The Private Section Of Your Form Declaration)
SourceBitmap : TBitmap;Procedures
----------
(In The Public Section Of Your Form Declaration)
procedure GetColor(const SLine : PByteArray; const L: Integer;
,var R: Integer,var C: TColor);function GetColorOf(ScanLine: PByteArray; X : Word): TColor;
Int The OnCreate Event Of The Form You Put
------------------------------------------
var
NewRgn, RowRgn, ScanRgn : HRGN;
Rows, Left, Right : Integer;
Line : PByteArray;
SourceColor : TColor;
begin
SourceBitmap := TBitmap.Create;
SourceBitmap.LoadFromFile('example.bmp');
NewRgn := CreateRectRgn(0,0,0,0);
For Rows := 0 To SourceBitmap.Height - 1 Do
Begin
RowRgn := CreateRectRgn(0,Rows,0,Rows);
Line := SourceBitmap.Scanline[Rows];
Left := 0; Right := 0;
repeat
GetColor(Line,Left,Right,SourceColor);
If (SourceColor <> clWhite) Then
Begin
ScanRgn := CreateRectRgn(Left,Rows,Right + 1,Rows + 1);
CombineRgn(RowRgn,RowRgn,ScanRgn,RGN_OR);
DeleteObject(ScanRgn);
End;
CombineRgn(NewRgn,NewRgn,RowRgn,RGN_OR);
DeleteObject(RowRgn);
while (right >= SourceBitmap.Width);
End;
SetWindowRgn(Handle,NewRgn,True);
end;In The GetColor Procedure
-------------------------
var
Column : integer;
CompareColor : TColor;
begin
Column := L;
CompareColor := GetColorOf(SLine,L);
repeat
Inc(Column);
until (CompareColor <> GetColorOf(SLine,Column))
or (Column >= SourceBitmap.Width);
R := column - 1;
C := CompareColor;
end;In The Function GetColorOf
--------------------------
var
Red, Green, Blue : Byte;
begin
If SourceBitmap = nil then exit;
If (X > SourceBitmap.Width) then Exit;
Result := clBlack;
Red := ScanLine[X * 3];
Green := ScanLine[X * 3 + 1];
Blue := ScanLine[X * 3 + 2];
If ((Red >= 138) and (Green >= 138) and (Blue >= 138)) Then
Result := clWhite
end;
给我一份,谢
[email protected]
ps.用SetWindowRgn,怎么才能生成任意形状的rgn:HRGN
[email protected]
运行即可完成字体窗体的创建。
procedure TForm1.FormCreate(Sender: TObject);
var rgn:HRGN;
begin
Form1.Color:=clRed;
BeginPath(Canvas.Handle);
SetBKMode(Canvas.Handle,TRANSPARENT);
Canvas.Font.Name:='宋体';
Canvas.Font.Size:=200;
Canvas.TextOut(150,130,'黄昏狼');
EndPath(Canvas.Handle);
rgn:=PathToRegion(Canvas.Handle);
SetWindowRgn(Handle,rgn,true);
end;