📄 winskinform.pas
字号:
// if not sf.timer.enabled then sf.timer.enabled:=true;
b:=false;
if (sf.activebtn<>nil) then begin
if (sf.activebtn<>self) then begin
sf.activebtn.mouseleave;
b:=true;
end;
end else b:=true;
if b and visible then begin
sf.activebtn:=self;
state:=3;
draw;
end;
end;
procedure TNCObject.MouseLeave;
begin
if visible then begin
sf.activebtn:=nil;
state:=1;
draw;
end;
end;
procedure TNCObject.Draw;
begin
end;
procedure TWinSysButton.Draw;
begin
sf.drawsysbtn(self,state);
end;
procedure TWinSkinMenu.UpdataBtn1;
var i,n:integer;
mi:TMenuItemInfo;
Buffer: array[0..79] of Char;
item:Tmenuitem;
newmenu:Thandle;
begin
newmenu := getmenu(sf.hwnd);
if newmenu<>0 then hmenu := newmenu;
if hmenu = 0 then exit;
if sf.FForm<>nil then begin
if sf.FForm.Menu=nil then exit;
menu:=sf.FForm.Menu;
end;
for i:= 0 to high(Buttons) do Buttons[i].free;
setlength(buttons,menu.Items.Count);
count:=menu.Items.count;
for i:= 0 to menu.Items.Count-1 do begin
item := menu.Items[i];
buttons[i]:=TMenuBtn.create;
buttons[i].fsd:=fsd;
buttons[i].sf:=sf;
buttons[i].index:= i;
buttons[i].visible:= item.visible;
buttons[i].enabled:= item.Enabled;
buttons[i].mid:= item.Command;
// buttons[i].caption:= item.Caption;
buttons[i].caption:=GetStringProp(item,'Caption');
buttons[i].menuitem:= item;
if item.count>0 then
buttons[i].hsubmenu:=item.Handle
else
buttons[i].hsubmenu:=0;
inc(n);
end;
SetMenu(sf.hwnd, 0);
end;
procedure TWinSkinMenu.UpdataBtn;
var i,n,j:integer;
mi:TMenuItemInfo;
Buffer: array[0..79] of Char;
item:Tmenuitem;
newmenu:Thandle;
b:boolean;
begin
b:= (Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion <5);
// b:= b or (winversion >= $80000000);
b:=b or ((Win32MajorVersion=4) and (Win32MinorVersion=0));
if b then begin
updatabtn1;
exit;
end;
newmenu := getmenu(sf.hwnd);
if newmenu<>0 then hmenu := newmenu;
if hmenu = 0 then exit;
if sf.FForm<>nil then begin
if sf.FForm.Menu=nil then exit;
menu:=sf.FForm.Menu;
end;
// fsd.DoDebug('UpdataBtn');
for i:= 0 to high(Buttons) do Buttons[i].free;
count:= GetMenuItemCount(hmenu);
if count<=0 then exit;
setlength(buttons,count);
for i:= 0 to count-1 do begin
mi.cbSize:= sizeof(TMENUITEMINFO);
mi.fMask := MIIM_ID or MIIM_TYPE or MIIM_STATE or MIIM_SUBMENU;
fillchar(buffer,sizeof(buffer),#0);
mi.dwTypeData := Buffer;
Mi.cch := SizeOf(Buffer);
GetMenuItemInfo(hmenu, i, TRUE, mi);
buttons[i]:=TMenuBtn.create;
buttons[i].fsd:=fsd;
buttons[i].sf:=sf;
buttons[i].index:= i;
buttons[i].hsubmenu:=mi.hSubMenu;
buttons[i].enabled:= (mi.fState and MFS_DISABLED)=0;
buttons[i].visible:= true;
buttons[i].mid:=mi.wid;
buttons[i].caption:= buffer;
inc(n);
//fsd.DoDebug(inttostr(mi.wid));
//if (buttons[i].caption='') then begin
Item := menu.FindItem(mi.wID,fkCommand);
if item<>nil then begin
if Assigned(item.Action) then item.Action.Update;
buttons[i].caption:=GetStringProp(item,'Caption');
buttons[i].enabled:= item.Enabled;
buttons[i].menuitem:=item;
if item.count>0 then
buttons[i].hsubmenu:=item.Handle
else
buttons[i].hsubmenu:=0;
end;
//end;
end;
SetMenu(sf.hwnd, 0);
end;
{procedure TWinSkinMenu.UpdataBtn1;
var i,n:integer;
mi:TMenuItemInfo;
Buffer: array[0..79] of Char;
item:Tmenuitem;
newmenu:Thandle;
begin
newmenu := getmenu(sf.hwnd);
if newmenu<>0 then hmenu := newmenu;
if hmenu = 0 then exit;
for i:= 0 to high(Buttons) do Buttons[i].free;
count:= GetMenuItemCount(hmenu);
if count<=0 then exit;
setlength(buttons,count);
for i:= 0 to count-1 do begin
mi.cbSize:= sizeof(TMENUITEMINFO);
mi.fMask := MIIM_ID or MIIM_TYPE or MIIM_STATE or MIIM_SUBMENU;
fillchar(buffer,sizeof(buffer),#0);
mi.dwTypeData := Buffer;
Mi.cch := SizeOf(Buffer);
GetMenuItemInfo(hmenu, i, TRUE, mi);
buttons[i]:=TMenuBtn.create;
buttons[i].fsd:=fsd;
buttons[i].sf:=sf;
buttons[i].index:= i;
buttons[i].hsubmenu:=mi.hSubMenu;
buttons[i].enabled:= (mi.fState and MFS_DISABLED)=0;
buttons[i].visible:= true;
buttons[i].mid:=mi.wid;
buttons[i].caption:= buffer;
inc(n);
if (buttons[i].caption='') and (menu<>nil)
and (i<menu.items.Count) then begin
Item := menu.items[i];
if item<>nil then begin
if Assigned(item.Action) then item.Action.Update;
buttons[i].caption:= item.caption;
buttons[i].enabled:= item.Enabled;
buttons[i].mid:=GetMenuItemID(hmenu,i);
if item.count>0 then
buttons[i].hsubmenu:=item.Handle
else
buttons[i].hsubmenu:=0;
end;
end;
end;
SetMenu(sf.hwnd, 0);
end;}
procedure TWinSkinMenu.UpdataBtn3;
var i,n:integer;
item:Tmenuitem;
newmenu:Thandle;
begin
newmenu := getmenu(sf.hwnd);
if newmenu<>0 then hmenu := newmenu;
for i:= 0 to high(Buttons) do Buttons[i].free;
count:= menu.items.Count;
if count<=0 then exit;
setlength(buttons,count);
for i:= 0 to count-1 do begin
buttons[i]:=TMenuBtn.create;
inc(n);
Item := menu.items[i];
if Assigned(item.Action) then item.Action.Update;
buttons[i].caption:= item.caption;
buttons[i].enabled:= item.Enabled;
buttons[i].visible:= item.visible;
buttons[i].mid:=item.Command;
buttons[i].fsd:=fsd;
buttons[i].sf:=sf;
buttons[i].index:= i;
if item.count>0 then
buttons[i].hsubmenu:=item.Handle
else
buttons[i].hsubmenu:=0;
end;
SetMenu(sf.hwnd, 0);
sf.activebtn:=nil;
end;
procedure TWinSkinMenu.UpdataBtn2(newmenu:Thandle);
var i,n,j:integer;
mi:TMenuItemInfo;
Buffer: array[0..79] of Char;
item:Tmenuitem;
begin
newmenu := getmenu(sf.hwnd);
if newmenu<>0 then hmenu := newmenu;
if hmenu = 0 then exit;
if sf.FForm<>nil then begin
if sf.FForm.Menu=nil then exit;
menu:=sf.FForm.Menu;
end;
// fsd.DoDebug('UpdataBtn2');
for i:= 0 to high(Buttons) do Buttons[i].free;
count:= GetMenuItemCount(hmenu);
if count<=0 then exit;
setlength(buttons,count);
for i:= 0 to count-1 do begin
mi.cbSize:= sizeof(TMENUITEMINFO);
mi.fMask := MIIM_ID or MIIM_TYPE or MIIM_STATE or MIIM_SUBMENU;
fillchar(buffer,sizeof(buffer),#0);
mi.dwTypeData := Buffer;
Mi.cch := SizeOf(Buffer);
GetMenuItemInfo(hmenu, i, TRUE, mi);
buttons[i]:=TMenuBtn.create;
buttons[i].fsd:=fsd;
buttons[i].sf:=sf;
buttons[i].index:= i;
buttons[i].hsubmenu:=mi.hSubMenu;
buttons[i].enabled:= (mi.fState and MFS_DISABLED)=0;
buttons[i].visible:= true;
buttons[i].mid:=mi.wid;
buttons[i].caption:= buffer;
inc(n);
if (buttons[i].caption='') then begin
Item := menu.FindItem(mi.wID,fkCommand);
if item<>nil then begin
if Assigned(item.Action) then item.Action.Update;
buttons[i].caption:= item.caption;
buttons[i].enabled:= item.Enabled;
buttons[i].mid:=item.Command;
if item.count>0 then
buttons[i].hsubmenu:=item.Handle
else
buttons[i].hsubmenu:=0;
end;
end;
end;
SetMenu(sf.hwnd, 0);
SetMenuRect();
end;
{procedure TWinSkinMenu.UpdataBtn;
var i:integer;
mi:TMenuItemInfo;
Buffer: array[0..79] of Char;
begin
hmenu:= getmenu(sf.hwnd);
for i:= 0 to high(Buttons) do Buttons[i].free;
count:= GetMenuItemCount(hmenu);
if count=0 then exit;
setlength(buttons,count);
for i:= 0 to count-1 do begin
buttons[i]:=TMenuBtn.create;
buttons[i].fsd:=fsd;
buttons[i].sf:=sf;
buttons[i].index:= i;
GetMenuString(hmenu,i,buffer,sizeof(buffer),MF_BYPOSITION);
buttons[i].caption:= buffer;
mi.cbSize:= sizeof(TMENUITEMINFO);
// mi.fMask := MIIM_TYPE;
mi.fMask := MIIM_TYPE or MIIM_STATE or MIIM_SUBMENU;
mi.fType := MFT_STRING;
fillchar(buffer,sizeof(buffer),#0);
mi.dwTypeData := Buffer;
Mi.cch := SizeOf(Buffer);
GetMenuItemInfo(hmenu, i, TRUE, mi);
// if mi.ftype=MFT_STRING then begin
buttons[i].caption:= buffer;
buttons[i].hsubmenu:=mi.hSubMenu;
buttons[i].enabled:= (mi.fState and MFS_DISABLED)=0;
buttons[i].visible:= true;
// end;
end;
SetMenu(sf.hwnd, 0);
end;}
procedure TWinSkinMenu.Copymenu(source,dst:Hmenu);
var i,n,aid:integer;
begin
n:= GetMenuItemCount(source);
for i:=0 to n-1 do begin
aid:=GetMenuItemID(source, i);
end;
end;
constructor TWinSkinMenu.Create(AOwner: TComponent);
begin
inherited create(AOwner);
bkmap:=Tbitmap.create;
end;
destructor TWinSkinMenu.Destroy;
var i:integer;
begin
bkmap.free;
for i:= 0 to length(Buttons)-1 do Buttons[i].free;
setlength(Buttons,0);
inherited destroy;
end;
type
TMenuItemAccess = class(TMenuItem);
TACControl = class(TControl);
TACWinControl = class(TWinControl);
TACGrid = class(TCustomGrid);
TACBitmap = class(TBitmap);
procedure TWinSkinMenu.DrawMenu(dc:HDC;rc:TRect);
var i,w,h,x: integer;
r,r1:Trect;
item:Tmenuitem;
btn:Tmenubtn;
begin
// fsd.DoDebug('DrawMenu');
r1:=rc;
offsetrect(rc,-rc.left,-rc.top);
bg.width:=rc.right;
bg.height:=rc.bottom;
if fsd.menubar=nil then begin
bg.canvas.brush.color:=fsd.colors[csMenuBar];
bg.canvas.fillrect(rc);
x:=6;
end else begin
if sf.FWindowActive then i:=1
else i:=2;
// DrawRect2(acanvas.handle,rc,fsd.menubar.map,fsd.menubar.r,1,2,0,0,1);
if fsd.menubar.tile=1 then
DrawRect2(bg.canvas.handle,rc,fsd.menubar.map,fsd.menubar.r,i,2,0,0,1)
else
DrawRectTile(bg.canvas,rc,fsd.menubar.map,fsd.menubar.r,i,2);
if Menu.IsRightToLeft then
x:=8+fsd.menubar.r.right
else
x:=4+fsd.menubar.r.left;
if x>rc.right then x:=12;
end;
//save bar map;
bar:=r1;
bkmap.assign(bg);
//copybmp(bg,map);
{ r:=rc;
offsetrect(r,-r.left,-r.top);
map.width:=rc.right;
map.height:=rc.bottom;
BitBlt(map.canvas.handle,0,0,rc.right,rc.bottom,
bg.Canvas.Handle ,0 ,0 ,SrcCopy)}
bg.canvas.Font := Screen.MenuFont;
bg.canvas.Font.color:= fsd.colors[csMenuBarText];
bg.canvas.brush.style:= bsclear;
SetBkMode(bg.Canvas.Handle, TRANSPARENT);
topmenu:=true;
if Menu.IsRightToLeft then begin
//bidi righttoleft
x:= rc.Right-x;
for i:= 0 to high(buttons) do begin
btn:=buttons[i];
if not btn.visible then begin
btn.bounds:=rect(0,0,0,0);
continue;
end;
r := r1;
Tnt_DrawTextW(bg.Canvas.Handle, btn.caption,r,DT_Left or DT_CALCRECT or DT_NOCLIP);
w:= r.Right-r.left;
// w:= bg.canvas.TextWidth(btn.caption);
if w>0 then w:=w+10;
r:= rect(x-w,0,x,rc.bottom-1);
if btn.enabled then
bg.canvas.Font.color:= fsd.colors[csMenuBarText]
else
bg.canvas.Font.color:= fsd.colors[csbuttonshadow];
{ if (item.imageindex<>-1) and (menu.images<>nil) then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -