今天换了BMP直接LOAD然后画的有问题了测试中发现显示总是有问题
这个好象不需要创建兼容DC吧 也不知道是哪里出错了
这个搞好了还得加3个BUTTON之类的消息进去,郁闷
哪位好心人帮偶看看是哪里的问题数字偶反复输了好几次拖动的时候就有问题
unit UnitAqua;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TAqua = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure FormResize(Sender: TObject);
private
{ Private declarations }
shuai :boolean;
Procedure DrawActivate;
Procedure DrawDeactivate;
protected
procedure wndproc(var message:Tmessage);override;
procedure wmnchittest(var msg:TWMNCHITTEST);message WM_NCHITTEST;
// procedure wmncmousemove(var msg: TWMNcMousemove);message wm_ncmousemove;
// procedure wmnclbuttondown(var msg:Twmnclbuttondown);message wm_nclbuttondown;
// procedure wmnclbuttondblclk(var msg:TWMNCLButtonDblClk);message wm_nclbuttondblclk;
// procedure wmnclbuttonup(var msg:twmnclbuttonup);message wm_nclbuttonup;
public
{ Public declarations }
end;
var
Aqua: TAqua;
bmp_topleft :tbitmap;
bmp_top :Tbitmap;
bmp_topright :Tbitmap;
bmp_left :Tbitmap;
bmp_bottomleft :Tbitmap;
bmp_bottom :Tbitmap;
bmp_bottomright :Tbitmap;
bmp_btnclose :Tbitmap;
bmp_right :TBitmap;
bmp_btnmax :Tbitmap;
bmp_btnmin :Tbitmap;
bmp_btnclose_hover :Tbitmap;
bmp_btnmax_hover :Tbitmap;
bmp_btnmin_hover :Tbitmap;
bmp_btnclose_down :Tbitmap;
bmp_btnmax_down :Tbitmap;
bmp_btnmin_down :Tbitmap;
bmp_btndeactive :Tbitmap; rc_topleft :TRect;
rc_top :TRect;
rc_topright :TRect;
rc_left :TRect;
rc_bottomleft :TRect;
rc_bottom :TRect;
rc_bottomright :TRect;
rc_right :TRect;
rc_btnclose :TRect;
rc_btnmax :TRect;
rc_btnmin :TRect;
rc_caption :TRect;
rc_icon :TRect;implementation
{$R *.dfm}procedure TAqua.wmnchittest(var msg:Twmnchittest);
var
pt :Tpoint;//鼠标指针
begin
inherited ;
pt.X := Screentoclient(mouse.CursorPos).x;//鼠标X
pt.Y := Screentoclient(mouse.CursorPos).y;// Y值
//准备欺骗系统了 ,因为BSNONE样式的窗体是没有这些返回消息的
if ptinrect(rc_btnmin,pt)
then
msg.Result := htminbutton //告诉它在最小化按纽这里
else
if ptinrect(rc_btnmax,pt)
then
msg.Result := htmaxbutton //告诉它在最大化按纽这里
else
if ptinrect(rc_btnclose,pt)
then
msg.Result := htClose //告诉它在关闭 按纽这里
else
if ptinrect(rc_caption,pt)
then
msg.Result := htCaption //告诉它在标题栏这里
else
if (pt.x<5) and (pt.y<5) then
msg.Result:=httopleft //告诉它在左上角
else
if (pt.x>width-5) and (pt.y<5) then
msg.Result:=httopright //告诉它在右上角
else
if (pt.x >width-4) and (pt.y>height-4) then
msg.Result:=htbottomright //告诉它在右下角
else
if (pt.x<4) and (pt.y>height-4) then
msg.Result:=htbottomleft //告诉它在左下角
else
if (pt.x<4) then
msg.Result:=htleft //偶是左派
else
if (pt.y<4) then
msg.Result:=httop //我在上面,低头不见抬头见
else
if (pt.x>width-4) then
msg.Result:=htright //偶是右派
else
if (pt.y>height-4) then
msg.Result:=htbottom //偶是贫下中农
end;procedure TAqua.DrawActivate;
var
dc :Hdc;
begin
dc:=getwindowdc(handle);
setstretchbltmode(dc,STRETCH_DELETESCANS );
rc_topleft :=rect(0,0,6,23);
rc_top :=rect(6,0,width-5,23);
rc_topright :=rect(width-5,0,width,23);
rc_left :=rect(0,23,4,height-3);
rc_bottomleft :=rect(0,height-3,4,height);
rc_bottom :=rect(4,height-3,width-3,height);
rc_bottomright:=rect(width-3,height-4,width,height);
rc_right :=rect(width-3,23,width,height-4);
rc_caption :=rect(23,1,width-66,22);
rc_btnmin :=rect((Width - 66),4, (Width - 51), 16);
rc_btnmax :=rect((Width - 45),4, (Width - 28), 16);
rc_btnclose :=rect((Width - 24),4, (Width - 7), 16);
rc_icon :=rect(4,4,17,17);
bmp_topleft :=tbitmap.create;
bmp_top :=tbitmap.Create;
bmp_topright :=tbitmap.Create;
bmp_left :=tbitmap.Create;
bmp_bottomleft :=tbitmap.Create;
bmp_bottom :=tbitmap.Create;
bmp_bottomright :=tbitmap.Create;
bmp_btnclose :=tbitmap.Create;
bmp_right :=Tbitmap.Create;
bmp_btnmax :=tbitmap.Create;
bmp_btnmin :=tbitmap.Create;
bmp_btnclose_hover :=tbitmap.Create;
bmp_btnmax_hover :=tbitmap.Create;
bmp_btnmin_hover :=tbitmap.Create;
bmp_btnclose_down :=tbitmap.Create;
bmp_btnmax_down :=tbitmap.Create;
bmp_btnmin_down :=tbitmap.Create;
bmp_btndeactive :=tbitmap.Create;
bmp_topleft .loadfromfile('.\image\topleft.bmp');
bmp_top .LoadFromFile('.\image\top.bmp');
bmp_topright .LoadFromFile('.\image\topright.bmp');
bmp_left .LoadFromFile('.\image\left.bmp');
bmp_bottomleft .LoadFromFile('.\image\bottomleft.bmp');
bmp_bottom .LoadFromFile('.\image\bottom.bmp');
bmp_bottomright .LoadFromFile('.\image\bottomright.bmp');
bmp_btnclose .LoadFromFile('.\image\btn_close.bmp');
bmp_right .LoadFromFile('.\image\right.bmp');
bmp_btnmax .LoadFromFile('.\image\btn_max.bmp');
bmp_btnmin .LoadFromFile('.\image\btn_min.bmp') ;
// bmp_btnclose_hover .LoadFromFile('.\image\btn_close_hover.bmp');
// bmp_btnmax_hover .LoadFromFile('.\image\btn_max_hover.bmp');
// bmp_btnmin_hover .LoadFromFile('.\image\btn_min_hover.bmp');
// bmp_btnclose_down .LoadFromFile('.\image\btn_close_down.bmp');
// bmp_btnmax_down .LoadFromFile('.\image\btn_max_down.bmp');
// bmp_btnmin_down .LoadFromFile('.\image\btn_min_down.bmp');
// bmp_btndeactive .LoadFromFile('.\image\btn_deactive.bmp');
canvas.Handle:=dc;
canvas.Lock;
canvas.Brush.Bitmap:=bmp_topleft;
canvas.fillrect(rc_topleft);
canvas.Brush.Bitmap:=bmp_top;
canvas.StretchDraw(rc_top,bmp_top);
canvas.Brush.bitmap:=bmp_topright;
canvas.fillrect(rc_topright);
canvas.Brush.Bitmap:=bmp_left;
canvas.FillRect(rc_left);
canvas.Brush.Bitmap:=bmp_right;
canvas.FillRect(rc_right);
canvas.Brush.Bitmap:=bmp_bottomleft;
canvas.FillRect(rc_bottomleft);
canvas.Brush.Bitmap:=bmp_bottom;
canvas.StretchDraw(rc_bottom,bmp_bottom);
canvas.Brush.Bitmap:=bmp_bottomright;
canvas.FillRect(rc_bottomright);
canvas.Unlock;
releasedc(handle,dc);
end;
//procedure TAqua.DrawdeActivate;和上面一样,写太多,不让发的,
procedure TAqua.wndproc(var message:Tmessage);
begin
inherited wndproc(message);
if message.Msg=wm_activate then
begin
case message.WParamLo of
wa_active,wa_clickactive:
begin
DrawActivate;
shuai:=true;
end;
wa_inactive:
begin
DrawDeactivate;
shuai:=false;
end;
end;
end;
end;procedure TAqua.FormCreate(Sender: TObject);
begin
borderstyle:=bsnone;
FormResize(sender);
end;procedure TAqua.FormPaint(Sender: TObject);
begin
DrawActivate;
end;procedure TAqua.FormResize(Sender: TObject);
begin
Invalidate; //这句很重要哦
end;
end.
这个好象不需要创建兼容DC吧 也不知道是哪里出错了
这个搞好了还得加3个BUTTON之类的消息进去,郁闷
哪位好心人帮偶看看是哪里的问题数字偶反复输了好几次拖动的时候就有问题
unit UnitAqua;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TAqua = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure FormResize(Sender: TObject);
private
{ Private declarations }
shuai :boolean;
Procedure DrawActivate;
Procedure DrawDeactivate;
protected
procedure wndproc(var message:Tmessage);override;
procedure wmnchittest(var msg:TWMNCHITTEST);message WM_NCHITTEST;
// procedure wmncmousemove(var msg: TWMNcMousemove);message wm_ncmousemove;
// procedure wmnclbuttondown(var msg:Twmnclbuttondown);message wm_nclbuttondown;
// procedure wmnclbuttondblclk(var msg:TWMNCLButtonDblClk);message wm_nclbuttondblclk;
// procedure wmnclbuttonup(var msg:twmnclbuttonup);message wm_nclbuttonup;
public
{ Public declarations }
end;
var
Aqua: TAqua;
bmp_topleft :tbitmap;
bmp_top :Tbitmap;
bmp_topright :Tbitmap;
bmp_left :Tbitmap;
bmp_bottomleft :Tbitmap;
bmp_bottom :Tbitmap;
bmp_bottomright :Tbitmap;
bmp_btnclose :Tbitmap;
bmp_right :TBitmap;
bmp_btnmax :Tbitmap;
bmp_btnmin :Tbitmap;
bmp_btnclose_hover :Tbitmap;
bmp_btnmax_hover :Tbitmap;
bmp_btnmin_hover :Tbitmap;
bmp_btnclose_down :Tbitmap;
bmp_btnmax_down :Tbitmap;
bmp_btnmin_down :Tbitmap;
bmp_btndeactive :Tbitmap; rc_topleft :TRect;
rc_top :TRect;
rc_topright :TRect;
rc_left :TRect;
rc_bottomleft :TRect;
rc_bottom :TRect;
rc_bottomright :TRect;
rc_right :TRect;
rc_btnclose :TRect;
rc_btnmax :TRect;
rc_btnmin :TRect;
rc_caption :TRect;
rc_icon :TRect;implementation
{$R *.dfm}procedure TAqua.wmnchittest(var msg:Twmnchittest);
var
pt :Tpoint;//鼠标指针
begin
inherited ;
pt.X := Screentoclient(mouse.CursorPos).x;//鼠标X
pt.Y := Screentoclient(mouse.CursorPos).y;// Y值
//准备欺骗系统了 ,因为BSNONE样式的窗体是没有这些返回消息的
if ptinrect(rc_btnmin,pt)
then
msg.Result := htminbutton //告诉它在最小化按纽这里
else
if ptinrect(rc_btnmax,pt)
then
msg.Result := htmaxbutton //告诉它在最大化按纽这里
else
if ptinrect(rc_btnclose,pt)
then
msg.Result := htClose //告诉它在关闭 按纽这里
else
if ptinrect(rc_caption,pt)
then
msg.Result := htCaption //告诉它在标题栏这里
else
if (pt.x<5) and (pt.y<5) then
msg.Result:=httopleft //告诉它在左上角
else
if (pt.x>width-5) and (pt.y<5) then
msg.Result:=httopright //告诉它在右上角
else
if (pt.x >width-4) and (pt.y>height-4) then
msg.Result:=htbottomright //告诉它在右下角
else
if (pt.x<4) and (pt.y>height-4) then
msg.Result:=htbottomleft //告诉它在左下角
else
if (pt.x<4) then
msg.Result:=htleft //偶是左派
else
if (pt.y<4) then
msg.Result:=httop //我在上面,低头不见抬头见
else
if (pt.x>width-4) then
msg.Result:=htright //偶是右派
else
if (pt.y>height-4) then
msg.Result:=htbottom //偶是贫下中农
end;procedure TAqua.DrawActivate;
var
dc :Hdc;
begin
dc:=getwindowdc(handle);
setstretchbltmode(dc,STRETCH_DELETESCANS );
rc_topleft :=rect(0,0,6,23);
rc_top :=rect(6,0,width-5,23);
rc_topright :=rect(width-5,0,width,23);
rc_left :=rect(0,23,4,height-3);
rc_bottomleft :=rect(0,height-3,4,height);
rc_bottom :=rect(4,height-3,width-3,height);
rc_bottomright:=rect(width-3,height-4,width,height);
rc_right :=rect(width-3,23,width,height-4);
rc_caption :=rect(23,1,width-66,22);
rc_btnmin :=rect((Width - 66),4, (Width - 51), 16);
rc_btnmax :=rect((Width - 45),4, (Width - 28), 16);
rc_btnclose :=rect((Width - 24),4, (Width - 7), 16);
rc_icon :=rect(4,4,17,17);
bmp_topleft :=tbitmap.create;
bmp_top :=tbitmap.Create;
bmp_topright :=tbitmap.Create;
bmp_left :=tbitmap.Create;
bmp_bottomleft :=tbitmap.Create;
bmp_bottom :=tbitmap.Create;
bmp_bottomright :=tbitmap.Create;
bmp_btnclose :=tbitmap.Create;
bmp_right :=Tbitmap.Create;
bmp_btnmax :=tbitmap.Create;
bmp_btnmin :=tbitmap.Create;
bmp_btnclose_hover :=tbitmap.Create;
bmp_btnmax_hover :=tbitmap.Create;
bmp_btnmin_hover :=tbitmap.Create;
bmp_btnclose_down :=tbitmap.Create;
bmp_btnmax_down :=tbitmap.Create;
bmp_btnmin_down :=tbitmap.Create;
bmp_btndeactive :=tbitmap.Create;
bmp_topleft .loadfromfile('.\image\topleft.bmp');
bmp_top .LoadFromFile('.\image\top.bmp');
bmp_topright .LoadFromFile('.\image\topright.bmp');
bmp_left .LoadFromFile('.\image\left.bmp');
bmp_bottomleft .LoadFromFile('.\image\bottomleft.bmp');
bmp_bottom .LoadFromFile('.\image\bottom.bmp');
bmp_bottomright .LoadFromFile('.\image\bottomright.bmp');
bmp_btnclose .LoadFromFile('.\image\btn_close.bmp');
bmp_right .LoadFromFile('.\image\right.bmp');
bmp_btnmax .LoadFromFile('.\image\btn_max.bmp');
bmp_btnmin .LoadFromFile('.\image\btn_min.bmp') ;
// bmp_btnclose_hover .LoadFromFile('.\image\btn_close_hover.bmp');
// bmp_btnmax_hover .LoadFromFile('.\image\btn_max_hover.bmp');
// bmp_btnmin_hover .LoadFromFile('.\image\btn_min_hover.bmp');
// bmp_btnclose_down .LoadFromFile('.\image\btn_close_down.bmp');
// bmp_btnmax_down .LoadFromFile('.\image\btn_max_down.bmp');
// bmp_btnmin_down .LoadFromFile('.\image\btn_min_down.bmp');
// bmp_btndeactive .LoadFromFile('.\image\btn_deactive.bmp');
canvas.Handle:=dc;
canvas.Lock;
canvas.Brush.Bitmap:=bmp_topleft;
canvas.fillrect(rc_topleft);
canvas.Brush.Bitmap:=bmp_top;
canvas.StretchDraw(rc_top,bmp_top);
canvas.Brush.bitmap:=bmp_topright;
canvas.fillrect(rc_topright);
canvas.Brush.Bitmap:=bmp_left;
canvas.FillRect(rc_left);
canvas.Brush.Bitmap:=bmp_right;
canvas.FillRect(rc_right);
canvas.Brush.Bitmap:=bmp_bottomleft;
canvas.FillRect(rc_bottomleft);
canvas.Brush.Bitmap:=bmp_bottom;
canvas.StretchDraw(rc_bottom,bmp_bottom);
canvas.Brush.Bitmap:=bmp_bottomright;
canvas.FillRect(rc_bottomright);
canvas.Unlock;
releasedc(handle,dc);
end;
//procedure TAqua.DrawdeActivate;和上面一样,写太多,不让发的,
procedure TAqua.wndproc(var message:Tmessage);
begin
inherited wndproc(message);
if message.Msg=wm_activate then
begin
case message.WParamLo of
wa_active,wa_clickactive:
begin
DrawActivate;
shuai:=true;
end;
wa_inactive:
begin
DrawDeactivate;
shuai:=false;
end;
end;
end;
end;procedure TAqua.FormCreate(Sender: TObject);
begin
borderstyle:=bsnone;
FormResize(sender);
end;procedure TAqua.FormPaint(Sender: TObject);
begin
DrawActivate;
end;procedure TAqua.FormResize(Sender: TObject);
begin
Invalidate; //这句很重要哦
end;
end.
解决方案 »
- 在Mapx中,用BindLayer对象绑出来的范围专题,为什么不能显示范围图例?
- 誰有DELPHI版的五子棋的源代码?
- 急:请问怎样才能最快的学好DELPHI???
- 关于线程求教
- 莫名其妙的问题 急!急!在线等
- 如何在2000和NT下监测机器中安装得多台网络打印机的状态是否可用!!急!急!急!在线等。。。。。。。。。。。。。。。。。。。。。。。
- listbox问题?
- ===关于IE控件的问题:是否可以直接对IE上显示的内容进行编辑(托拽)===
- SQL SERVER 7.0问题
- dephi开发ASP组件时,如何返回一个记录集?
- 一个主程序调用外部的一个程序,外部程序的窗口需要像MDI的子窗体一样显示在主窗体上,这个应该怎么实现?
- 小妹急用,请大家帮忙写个关于文件操作的小程序,谢谢!
为了活到九十九,至今老婆都没有。
顶直到传说中的 牛 人 出现