界面的技巧!!!
相关文章
相关文章
关于powerdesiger!
PB与Excel的通讯问题,请各位相助
(1)有没有控件可以把button出现在form的caption上,就是和最大化等在一起?
(2)有没有控件可以实现dbgrid的结果前面有一checkbox可选框,可以选择删除之
类似邮件的删除?
------Solutions------
var
h :hdc;
begin
h := GetWindowDc(handle);
canvas.Handle := h;
…………
end
取得整个窗体的hdc,想在什么地方画都行
------Solutions------
要自己画,很麻烦,不过有现成的空间
------Solutions------
用第三方控件,去 下載,什麼樣的都有!
------Solutions------
unit Unit1;
interface
uses
Windows, Buttons, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
procedure FormResize(Sender: TObject);
private
{ Private declarations }
CaptionBtn:TRect;
procedure DrawCaptButton;
procedure WMNCPaint(var Msg:TWMNCPaint);message WM_NCPaint;
procedure WMNCActivate(var Msg:TWMNCActivate);message WM_NCActivate;
procedure WMSetText(var Msg:TWMSetText);message WM_SetText;
procedure WMNCHitTest(var Msg:TWMNCHitTest);message WM_NCHittest;
procedure WMNCLButtonDown(var Msg:TWMNCLButtonDown);message WM_NCLButtonDown;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
const
htCaptionBtn=htSizeLast+1;
{$R *.DFM}
procedure TForm1.DrawCaptButton;
var
xFrame,yFrame,xSize,ySize:Integer;
R:TRect;
begin
xFrame:=GetSystemMetrics(SM_CXFRAME);
yFrame:=GetSystemMetrics(SM_CYFRAME);
xSize:=GetSystemMetrics(SM_CXSIZE);
ySize:=GetSystemMetrics(SM_CYSIZE);
//按钮属性调整->>
CaptionBtn:=Bounds(Width-xFrame-5*xSize+2,yFrame+2,xSize+13,ySize-4);
Canvas.Handle:=GetWindowDC(Self.Handle);
Canvas.Font.Name:='宋体';
Canvas.Font.Color:=clBlue;
Canvas.Pen.Color:=clYellow;
Canvas.Brush.Color:=clBtnFace;
try
DrawButtonFace(Canvas,CaptionBtn,1,bsAutoDetect,False,False,False);
R:=Bounds(Width-xFrame-5*xSize+3,yFrame+3,xSize+10,ySize-7);
with CaptionBtn do
Canvas.TextRect(R,R.Left+2,R.Top,'TEST');
finally
ReleaseDC(Self.Handle,Canvas.Handle);
Canvas.Handle:=0;
end;
end;
procedure TForm1.WMNCActivate(var Msg: TWMNCActivate);
begin
inherited;
DrawCaptButton;
end;
procedure TForm1.WMNCHitTest(var Msg: TWMNCHitTest);
begin
inherited;
with Msg do
if PtInRect(CaptionBtn,Point(xPos-Left,yPos-Top)) then
Result:=htCaptionBtn;
end;
procedure TForm1.WMNCLButtonDown(var Msg: TWMNCLButtonDown);
begin
inherited;
if(Msg.HitTest=htCaptionBtn)then
showmessage('good');
end;
procedure TForm1.WMNCPaint(var Msg: TWMNCPaint);
begin
inherited;
DrawCaptButton;
end;
procedure TForm1.WMSetText(var Msg: TWMSetText);
begin
inherited;
DrawCaptButton;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
Perform(WM_NCACTIVATE,Word(Active),0);
end;
你给分吧
这个一定行啊
------Solutions------
至于第二个只能用第三方的控件啊
------Solutions------
是啊,每次屏幕变化都要重画,而且画出来的效果也不好。还是用控件把,反正道理就是在窗口上自己画个框框,在定位响应鼠标时间就好了。