界面美化代码

1. 使控件产生圆角的方法(包括Tform)

procedure TfrmMessageDlg.SetBorder(AControl: TWinControl);
const
  ConRound = 5;

var
  LHrgn: HRGN;
begin
  LHrgn := 0;
  GetWindowRgn(AControl.Handle, LHrgn);
  DeleteObject(LHrgn);
  LHrgn := CreateRoundRectRgn(0, 0, AControl.Width, AControl.Height, ConRound, ConRound);
  SetWindowRgn(AControl.Handle, LHrgn, True);
end;

procedure TfrmMessageDlg.FormCreate(Sender: TObject);
begin
  pnlClient.Width := self.Width-2;
  pnlClient.Height := Self.Height -2;
  SetBorder(Self);
  SetBorder(pnlClient);
end;

设置form的Color为边框颜色,设置pnlClient设置Color为界面颜色

2. 设置非标准窗体标题的panel响应移动事件

procedure TfrmMessageDlg.FormCreate(Sender: TObject);
begin
  SetWindowLong(Self.Handle,GWL_STYLE,GetWindowLong(Self.Handle,GWL_STYLE) and not WS_CAPTION);
  Height := ClientHeight;
end;

procedure TfrmMessageDlg.pnl4MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  ReleaseCapture;
  (Self as TWinControl).Perform(WM_SYSCOMMAND,ConDragMove,0);
end;

3. 减少窗体上控件移动闪烁的问题可以用DoubleBuffered=true来解决即,是防闪烁,二还可以提高点效率。
一、CREATE BITMAP OR DC BUFFER
二、DRAW ON BITMAP
三、BITBLT BITMAP ON YOUR WINDOW。

4. 背景透明的图片问题

delphi7下只能用24bit的图片(即没有alpha通道的图片),要背景透明就只能TImage.Transparent := True;

delphi2010就可以支持32bit的图片了,启用alpha通道Image3.Transparent := False;

 Image3.Picture.Bitmap.AlphaFormat := afPremultiplied;

5. 渐进色的画法

 

procedure  TfrmMain.DoDrawGradient(ACanvas: TCanvas; ATop, ALeft, AWidth,
  AHeight: Integer; AFColor, ATColor: TColor;ADirection: Byte);
// ADirection:  0 :从左到右  1 :从上到下
var
  LBmp: TBitmap;
  P: PByteArray;
  I, J, LFR, LFG, LFB, LTR, LTB, LTG,LR,LB,LG: Integer;
begin
  LBmp :
=  TBitmap.Create;
  
try
    LBmp.PixelFormat :
=  pf24bit;
    LBmp.Width :
=  AWidth;
    LBmp.Height :
=  AHeight;
    LFR :
=  GetRValue(ColorToRGB(AFColor));
    LFB :
=  GetBValue(ColorToRGB(AFColor));
    LFG :
=  GetGValue(ColorToRGB(AFColor));
    LTR :
=  GetRValue(ColorToRGB(ATColor));
    LTB :
=  GetBValue(ColorToRGB(ATColor));
    LTG :
=  GetGValue(ColorToRGB(ATColor));
    
for  I : =   0   to  LBmp.Height  -   1   do
    
begin
      P :
=  LBmp.ScanLine[I];
      
case  ADirection  of
        
0 : for  J : =   0   to  LBmp.Width  -   1   do
        
begin
          p[J 
*   3 ] : =  LTB  +  (AWidth  -  J)  *  (LFB  -  LTB)  div  AWidth;
          p[J 
*   3   +   1 ] : =  LTG  +  (AWidth  -  J)  *  (LFG  -  LTG)  div  AWidth;
          p[J 
*   3   +   2 ] : =  LTR  +  (AWidth  -  J)  *  (LFR  -  LTR)  div  AWidth;
        
end ;
        
1 :
        
begin
          LR :
=  LTR  +  (AHeight  -  I)  *  (LFR  -  LTR)  div  AHeight;
          LB :
=  LTB  +  (AHeight  -  I)  *  (LFB  -  LTB)  div  AHeight;
          LG :
=  LTG  +  (AHeight  -  I)  *  (LFG  -  LTG)  div  AHeight;
          
for  J : =   0   to  LBmp.Width  -   1   do
          
begin
            p[J 
*   3 ] : =  LB;
            p[J 
*   3   +   1 ] : =  LG;
            p[J 
*   3   +   2 ] : =  LR;
          
end ;
        
end ;
      
end ;
    
end ;
    
// 将缓冲区复制到目标上
    
// pnlContent.Canvas.Draw( 0 , 0 ,Lbmp);
    BitBlt(ACanvas.Handle,ALeft, ATop,  AWidth, AHeight, LBmp.Canvas.Handle, 
0 , 0 , SRCCOPY);
  
finally
    FreeAndNil(LBmp);
  
end ;
end ;

 

6. 输出字符的时候设置背景透明:

  SetBkMode(ACanvas.Handle,TRANSPARENT);
  ACanvas.TextOut(ARect.Left,ARect.Top,AText)
 

转载于:https://www.cnblogs.com/enli/archive/2010/07/28/1786941.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SQL代码美化程序 SQL Pretty Printer 3.2.8 Copyright 2005-2011, Gudu Software. All Rights Reserved http://www.dpriver.com -------------------------------------------------------- Overview -------- SQL Pretty Printer is a tool that will help you beautify your SQL code. Using hotkey functionality, SQL Pretty Printer can reformat SQL statements for a wide variety of database tools such as Microsoft Query Analyzer, SQL Server Management Studio (SSMS), TOAD and PL/SQL Developer, development environments such as Visual Studio 2003/2005/2008 and Eclipse, and popular editors such as UltraEditor and EditPlus. In addition to beautifying SQL code, SQL Pretty Printer can translate SQL code into C#, Java, PHP, DELPHI and other program languages. SQL Pretty Printer also includes command line functionality, with the ability to format single files, single directories and multiple directories. SQL Pretty Printer is designed to deal with the syntax used by most popular database systems including Microsoft SQL Server, Oracle, IBM DB2, MySQL and Microsoft Access (Informix, Sybase, and PostgreSQL support is currently in development). Output conforms to most of the entry level SQL99 Standard. Add-Ins for SSMS and Visual Studio 2003/2005/2008/2011 are available. APIs for dotnet and COM version are available. features: ** Beautifies SQL statements utilizing highly customizable format options. ** Formats SQL on-the-fly in popular tools and editors using hotkey functionality. ** Minimizes to the system tray for quick access. ** Includes a command line for batch conversion of single files, single directories or directory trees (use the command line API in your own program!) ** Verifies SQL syntax with detailed error information. ** Converts monochrome SQL code into colorful RTF document. ** Converts monochrome SQL code into colorful HTML for easy placement in blogs and forums. ** Converts SQL to various programming languages including C#, Java, DELPHI, PHP and others. ** Currently supports SQL syntax for Microsoft SQL Server, Oracle, IBM DB2, MySQL and Microsoft Access (Informix, Sybase, and PostgreSQL support is currently in development). ** Add-In for SQL Server Management Studio available. ** Add-In for Visual Studio 2003/2005/2008 available. Requirements ------------ Pentium class CPU or higher Windows 95/98/NT/2000/XP/Vista/win7
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值