📄 winsubclass.pas
字号:
btemp.canvas.Font.Color:= fsd.button.normalcolor2;
if (i=4) and (fsd.button.newover) then
btemp.canvas.Font.Color:= fsd.button.overcolor2;
if (i=2) and (fsd.Button.newdown) then
btemp.canvas.Font.Color:= fsd.button.downcolor2;
if not enable then
btemp.canvas.Font.Color := clBtnShadow;
SetBkMode(btemp.Canvas.Handle, TRANSPARENT);
// DrawText(bg.canvas.Handle, PChar(btn.caption),Length(btn.caption),TextBounds,DrawStyle);
Tnt_DrawTextW(btemp.canvas.Handle,caption,TextBounds,DrawStyle);
// acanvas.draw(rc.left,rc.top,BG);
aCanvas.draw(rc.left,rc.top,btemp);
end;
procedure TSkinControl.DrawCaption(acanvas: TCanvas; rc:TRect;
text:widestring; enabled,defaulted:boolean;Alignment:word=DT_CENTER);
const
Alignments: array[TAlignment] of Word = (DT_LEFT,DT_RIGHT,DT_CENTER );
var
r1: TRect;
DrawStyle: Longint;
begin
DrawStyle := DT_EXPANDTABS or Alignment;
r1 := rc;
SetBkMode(aCanvas.Handle, TRANSPARENT);
with ACanvas do begin
Brush.Style := bsClear;
font.style:=[];
// Calculate vertical layout
// DrawText(ACanvas.Handle,PChar(Text),Length(Text),r1,DrawStyle or DT_CALCRECT or DT_NOCLIP);
tnt_DrawTextw(ACanvas.Handle,Text,r1,DrawStyle or DT_CALCRECT or DT_NOCLIP);
if Alignment=dt_center then
OffsetRect(r1, ((rc.right - rc.left) - (r1.right - r1.left)) div 2,
((rc.Bottom - rc.Top) - (r1.Bottom - r1.Top)) div 2-1)
else begin
OffsetRect(r1, 0,((rc.Bottom - rc.Top) - (r1.Bottom - r1.Top)) div 2-1);
r1.Left:=rc.left;r1.right:=rc.Right;
end;
if not enabled then Font.Color := clBtnShadow;
// DrawText(ACanvas.Handle, PChar(Text),-1,r1,DrawStyle);
Tnt_DrawTextW(ACanvas.Handle, text,r1,DrawStyle);
end;
end;
{ procedure GetImgRect(imgIndex:integer;text:string) ;
var DrawStyle: Longint;
margin:integer;
begin
if imgindex<>-1 then imgrect:=rect(0,0,16,16)
else imgrect:=rect(0,0,0,0);
DrawStyle := DT_EXPANDTABS or DT_SINGLELINE or DT_CENTER;
textrect:=rc;
if imgindex<>-1 then dec(textrect.right,-(2+imgrect.right));
DrawText(Drawtemp.canvas.Handle,PChar(Text),Length(Text),textrect,DrawStyle or DT_CALCRECT or DT_NOCLIP);
margin:=(rc.right-rc.left-imgrect.right-(textrect.right-textrect.left)) div 2;
offsetrect(imgrect,margin,(rc.bottom-rc.top-imgrect.bottom) div 2);
// if (ImgIndex<>-1) then
// ImgList_Draw(imagelist,ImgIndex,ACanvas.handle, r1.Left, r1.Top,ILD_TRANSPARENT);
OffsetRect(textrect,(margin+(textrect.right-textrect.left)) div 2,
((rc.Bottom - rc.Top)-(textrect.Bottom-textrect.Top)) div 2);
end;}
procedure TSkinControl.DrawImgCaption(acanvas: TCanvas; rc:TRect;
ImgList:hImageList;imgIndex:integer;text:widestring;talign:integer=DT_CENTER);
var
imgrect,textrect,r1,r2: TRect;
DrawStyle: Longint;
h,w,margin:integer;
begin
ImageList_GetIconSize(ImgList,w,h);
if (imgindex<>-1) and (ImgList<>0) and ((rc.Right-rc.left)>w) then begin
imgrect:=rect(0,0,w,h);
end else begin
imgrect:=rect(0,0,0,0);
w:=0;
end;
DrawStyle := DT_END_ELLIPSIS or DT_EXPANDTABS or DT_SINGLELINE;// or DT_CENTER;
textrect:=rc;
if (ImgList<>0) and (imgindex<>-1) then dec(textrect.right,-(2+w));
if Length(Text)>0 then
TNT_DrawTextw(acanvas.Handle,Text,textrect,DrawStyle or DT_CALCRECT or DT_NOCLIP)
// DrawText(acanvas.Handle,PChar(Text),Length(Text),textrect,DrawStyle or DT_CALCRECT or DT_NOCLIP)
else textrect.right:=textrect.left;
offsetrect(imgrect,rc.left,rc.top);
case talign of
DT_CENTER :
margin:=(rc.right-rc.left-w-(textrect.right-textrect.left)) div 2;
DT_Left :
margin:=2;
DT_right :
margin:=(rc.right-rc.left-w-(textrect.right-textrect.left))-2;
end;
if margin<2 then margin:=2;
offsetrect(imgrect,margin,(rc.bottom-rc.top-w) div 2);
OffsetRect(textrect,margin+w+1,
((rc.Bottom - rc.Top)-(textrect.Bottom-textrect.Top)) div 2);
if (ImgList<>0) and (ImgIndex<>-1) then
ImageList_Draw(imglist,ImgIndex,ACanvas.handle,
imgrect.Left, imgrect.Top,ILD_TRANSPARENT);
if Length(Text)=0 then exit;
SetBkMode(aCanvas.Handle, TRANSPARENT);
ACanvas.Brush.Style := bsClear;
ACanvas.font.style:=[];
if not enabled then ACanvas.Font.Color := clBtnShadow;
if textrect.Left<rc.Left then textrect.Left:=rc.Left;
if textrect.right>rc.right then textrect.right:=rc.right;
// DrawText(ACanvas.Handle, PChar(Text),Length(Text),textrect,DrawStyle);
Tnt_DrawTextW(ACanvas.Handle,Text,textrect,DrawStyle);
end;
{procedure TSkinControl.DrawImgCaption(acanvas: TCanvas; rc:TRect;
ImgList:TCustomImageList;imgIndex:integer;
text:string; enabled,default:boolean;Alignment: TAlignment=taCenter);
const
Alignments: array[TAlignment] of Word = (DT_LEFT,DT_RIGHT,DT_CENTER );
var
r1: TRect;
DrawStyle: Longint;
begin
DrawStyle := DT_EXPANDTABS or DT_SINGLELINE or Alignments[Alignment];
r1.Left := rc.Left + 6;
r1.Top := rc.Top + 1;
r1.Right := r1.Left + 16;
r1.Bottom := r1.Top + 16;
if (ImgIndex>-1) and (ImgIndex <ImgList.Count) then
ImgList.Draw(ACanvas, r1.Left, r1.Top, ImgIndex,Enabled);
rc.left:=r1.right;
r1:=rc;
SetBkMode(aCanvas.Handle, TRANSPARENT);
with ACanvas do begin
Brush.Style := bsClear;
// if Default then
// Font.Style := Font.Style + [fsBold];
font.style:=[];
DrawText(Handle,PChar(Text),Length(Text),r1,DrawStyle or DT_CALCRECT or DT_NOCLIP);
OffsetRect(r1, ((rc.right - rc.left) - (r1.right - r1.left)) div 2,
((rc.Bottom - rc.Top) - (r1.Bottom - r1.Top)) div 2);
Font.Color := fsd.colors[csButtonText];
if not enabled then
Font.Color := clBtnShadow;
DrawText(Handle, PChar(Text),Length(Text),r1,DrawStyle);
end;
end;}
procedure TSkinControl.DrawSkinMap( dc:HDC; rc:TRect;
aObject:TdataSkinObject;I,N:integer);
var temp:Tbitmap;
adc:HDC;
begin
if (rc.right<rc.left) or (rc.bottom<rc.top) then exit;
temp:=GetHMap(rc,aobject.map,aobject.r,i,n,aobject.tile);
if aobject.trans=1 then begin
DrawTranmap(DC,rc,temp);
end else
BitBlt(dc,rc.left ,rc.top,rc.right-rc.left,rc.bottom-rc.Top,
temp.Canvas.Handle ,0 ,0 ,Srccopy);
temp.free;
end;
procedure TSkinControl.DrawBuf( dc:HDC; rc:TRect);
begin
// fcanvas.handle:=dc;
// fcanvas.draw(rc.left,rc.top,BG);
BitBlt(dc,rc.left ,rc.top,rc.right-rc.left,rc.bottom-rc.Top,
bg.Canvas.Handle ,0 ,0 ,Srccopy);
end;
procedure TSkinControl.WMPaint(message:TMessage);
var ps: TPaintStruct ;
dc: HDC ;
rc :Trect;
begin
if ( message.wParam=0 ) then begin
DC := BeginPaint(hWnd, ps);
end else begin
DC := message.wParam;
end;
if GetWindowRect( hWnd, rc ) then begin
// GetWindowRect( hWnd, rc );
boundsrect:=rc;
OffsetRect( rc, -rc.left, -rc.top );
// try
Drawcontrol(dc,rc);
// except
// end;
end;
if ( message.wParam=0 ) then
EndPaint(hWnd, ps);
end;
procedure TSkinControl.DrawBMPSkin( abmp:Tbitmap;rc:TRect;aObject:TdataSkinObject;
I,N:integer;trans:integer);
var temp:Tbitmap;
begin
if ((rc.right-rc.left)<0) or ((rc.bottom-rc.top)<0) then exit;
temp:=GetHMap(rc,aobject.map,aobject.r,i,n,aobject.tile);
fillBG(abmp.canvas.handle,rc);
if trans=1 then begin
temp.Transparent:=true;
temp.Transparentcolor:=clFuchsia;
// temp.Transparentcolor:= temp.Canvas.Pixels[0, 0];
end;
abmp.canvas.draw(0,0,temp);
temp.free;
end;
procedure TSkinControl.DrawSkin( rc:TRect;aObject:TdataSkinObject;
I,N:integer;trans:integer);
var temp:Tbitmap;
begin
if ((rc.right-rc.left)<0) or ((rc.bottom-rc.top)<0) then exit;
temp:=GetHMap(rc,aobject.map,aobject.r,i,n,aobject.tile);
fillBG(bg.canvas.handle,rc);
if trans=1 then begin
temp.Transparent:=true;
temp.Transparentcolor:=clFuchsia;
// temp.Transparentcolor:= temp.Canvas.Pixels[0, 0];
end;
bg.canvas.draw(0,0,temp);
temp.free;
end;
procedure TSkinControl.DrawSkinMap1( dc:HDC; rc:TRect;
bmp:Tbitmap;I,N:integer);
var temp:Tbitmap;
w,h,x:integer;
adc:HDC;
acanvas:Tcanvas;
begin
if (rc.right<rc.left) or (rc.bottom<rc.top) then exit;
temp:=Tbitmap.create;
w:=bmp.width div n;
h:=bmp.height;
temp.height:=rc.bottom-rc.top;
temp.width:=rc.right-rc.left;
x:=(i-1)*w;
temp.canvas.copyrect( rect(0,0,rc.right-rc.left,rc.bottom-rc.top),
bmp.canvas,rect(x,0,x+w,h));
acanvas:=Tcanvas.create;
acanvas.handle:=dc;
try
temp.Transparent:=true;
temp.Transparentcolor:=clFuchsia;
// temp.Transparentcolor:=temp.Canvas.Pixels[0, 0];
acanvas.draw(rc.left,rc.top,temp);
finally
temp.free;
acanvas.free;
end;
end;
procedure TSkinControl.DrawSkinMap3( acanvas:Tcanvas; rc:TRect;
bmp:Tbitmap;I,N:integer);
var temp1:Tbitmap;
w,h,x:integer;
begin
if (rc.right<rc.left) or (rc.bottom<rc.top) then exit;
temp1:=Tbitmap.create;
w:=bmp.width div n;
h:=bmp.height;
temp1.height:=rc.bottom-rc.top;
temp1.width:=rc.right-rc.left;
x:=(i-1)*w;
temp1.canvas.copyrect( rect(0,0,rc.right-rc.left,rc.bottom-rc.top),
bmp.canvas,rect(x,0,x+w,h));
temp1.Transparent:=true;
temp1.Transparentcolor:=clFuchsia;
acanvas.draw(rc.left,rc.top,temp1);
temp1.free;
end;
procedure TSkinControl.DrawSkinMap2( dc:HDC; rc:TRect;
bmp:Tbitmap;I,N:integer);
var temp:Tbitmap;
w,h,x:integer;
begin
if (rc.right<rc.left) or (rc.bottom<rc.top) then exit;
temp:=Tbitmap.create;
w:=bmp.width div n;
h:=bmp.height;
temp.height:=rc.bottom-rc.top;
temp.width:=rc.right-rc.left;
x:=(i-1)*w;
temp.canvas.copyrect( rect(0,0,rc.right-rc.left,rc.bottom-rc.top),
bmp.canvas,rect(x,0,x+w,h));
{ fcanvas.handle:=dc;
temp.Transparent:=true;
temp.Transparentcolor:=clFuchsia;
// temp.Transparentcolor:=temp.Canvas.Pixels[0, 0];
fcanvas.draw(rc.left,rc.top,temp);}
DrawTranmap(DC,rc,temp);
temp.free;
end;
{procedure TSkinControl.DrawSkinMap2( dc:HDC; rc:TRect;
bmp:Tbitmap;I,N:integer);
var mask:Tbitmap;
w,h,x:integer;
begin
if (rc.right<rc.left) or (rc.bottom<rc.top) then exit;
mask:=Tbitmap.create;
mask.assign(bmp);
mask.mask(clFuchsia);
w:=bmp.width div n;
h:=bmp.height;
x:=(i-1)*w;
TransparentStretchBlt(dc,rc.left,rc.Top,rc.Right-rc.Left,rc.Bottom-rc.Top,
bmp.Canvas.Handle,x,0,x+w,h,mask.Handle,x,0);
mask.free;
end;}
function TSkinStatusBar.BeforeProc(var Message: TMessage):boolean;
var r:Trect;
begin
result:=inherited BeforeProc(message);
exit;
result:=true;
case message.msg of
WM_ERASEBKGND: begin
// GetClientRect(hwnd,r);
// FillRect( message.wparam,r,fsd.BGbrush);
message.result:=1;
result:=false;
end;
WM_Paint : begin
wmpaint(message);
result:=false;
end;
else result:=inherited BeforeProc(message);
end;
end;
procedure TSkinStatusBar.DrawControl( dc:HDC; rc:TRect);
var i,n,j,m,w1,h1:integer;
r,r1,r2:Trect;
sb:Tstatusbar;
dwstyle:dword;
bfont,cfont:Hfont;
Flags:TAlignment;
text:widestring;
begin
sb:=Tstatusbar(control);
n:= sb.Panels.count;
r1:=rc;
offsetrect(r1,-r1.left,-r1.top);
bg.width:=r1.right;
bg.height:=r1.bottom;
bg.canvas.brush.color:=fsd.colors[csButtonFace];
bg.canvas.fillrect(r1);
bg.canvas.Font := TAcControl(control).Font;
bg.canvas.font.style:=[];
if fsd.statusbar<>nil then
bg.canvas.Font.Color:= fsd.statusbar.normalcolor2;
// bfont:=sendmessage(hwnd,wm_getfont,0,0);
// cfont := selectobject(bg.canvas.handle,bfont);
if fsd.statusbar<>nil then
SetTextColor(bg.canvas.handle,fsd.statusbar.normalcolor2);
if (sb.simplepanel) or (sb.Panels.count=0) then begin
j:=1;
if (sb.IsRightToLeft) then
Flags:=taLeftJustify
else
Flags:=taLeftJustify;
text:= GetStringProp(sb,'simpletext');
if (fsd.statusbar<>nil) and (not fsd.statusbar.map.empty) then
drawitem(bg.canvas.handle,rc,j,text,Flags)
else
Defaultpaint(bg.canvas.handle,rc,j,text,Flags);
end else begin
m:=0;
for i:= 0 to n-1 do begin
j:=0;
flags:=sb.Panels[i].alignment;
if (sb.Panels[i].bidimode=bdRightToLeft) then begin
if Flags=taLeftJustify then
Flags :=taRightJustify
else if Flags=taRightJustify then
Flags:=taLeftJustify;
end;
if sb.Panels[i].Bevel=pblowered then j:=1;
if sb.Panels[i].Bevel=pbNone then j:=3;
if sb.Panels[i].Bevel=pbRaised then j :=2;
if sendmessage(hwnd,SB_GETRECT,i,integer(@r))<>0 then begin
// InflateRect( r, -2, 0 );
if i=n-1 then r.Right := rc.Right;
text:= GetStringProp(sb.Panels[i],'Text');
if (fsd.statusbar<>nil) and (not fsd.statusbar.map.empty) then
drawitem(bg.canvas.handle,r,j,text,Flags)
else
Defaultpaint(bg.canvas.handle,r,j,text,Flags);
end;
end;
end;
dwstyle:= GetWindowLong(hWnd,GWL_STYLE);
if (dwstyle and SBARS_SIZEGRIP)>0 then begin
r1.Right := rc.Right - 1;
r1.bottom := rc.bottom - 1;
if (fsd.ExtraImages<>nil) and (not fsd.ExtraImages.map.empty) then begin
w1:= fsd.ExtraImages.map.width d
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -