首页
社区
课程
招聘
请问菜单工具图标是怎么实现的?
发表于: 2004-12-1 16:19 5455

请问菜单工具图标是怎么实现的?

2004-12-1 16:19
5455
如图:



wnb.exe是一个exe工具,浏览器(或其它软件)怎么实现将工具的图标放上去的,通过什么 API 或什么方法,是不是 跟注册表项目有关?高手指点一二吧,最后从汇编+API 来解释实现方法。。。Thks:)

[峰会]看雪.第八届安全开发者峰会10月23日上海龙之梦大酒店举办!

收藏
免费 1
支持
分享
最新回复 (7)
雪    币: 209
活跃值: (40)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
呃?通咿暂?表???的,是一肺com的??,具篦?的砧法我也不清楚,反正是在暂?表的class_root下的某?地方放入?似CLSID一?的?西??的,具篦?是上?程??vckbase或csdn看看吧
2004-12-2 12:48
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
我不知道有没有理解错你的意思
下面有一段delphi的代码,实现在标题栏画图标

unit Capbtn;

interface

uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, Buttons;

type
TTitleBtnForm = class(TForm)
   procedure FormResize(Sender: TObject);
private
   TitleButton : TRect;
   procedure DrawTitleButton;
   {Paint-related messages}
   procedure WMSetText(var Msg : TWMSetText); message WM_SETTEXT;
   procedure WMNCPaint(var Msg : TWMNCPaint); message WM_NCPAINT;
   procedure WMNCActivate(var Msg : TWMNCActivate); message WM_NCACTIVATE;
   {Mouse down-related messages}
   procedure WMNCHitTest(var Msg : TWMNCHitTest); message WM_NCHITTEST;
   procedure WMNCLButtonDown(var Msg : TWMNCLButtonDown); message

WM_NCLBUTTONDOWN;
   function GetVerInfo : DWORD;
end;

var
TitleBtnForm: TTitleBtnForm;

const
htTitleBtn = htSizeLast + 1;

implementation
{$R *.DFM}

procedure TTitleBtnForm.DrawTitleButton;
var
bmap : TBitmap; {Bitmap to be drawn - 16 X 16 : 16 Colors}
XFrame,  {X and Y size of Sizeable area of Frame}
YFrame,
XTtlBit, {X and Y size of Bitmaps in caption}
YTtlBit  : Integer;
begin
{Get size of form frame and bitmaps in title bar}
XFrame  := GetSystemMetrics(SM_CXFRAME);
YFrame  := GetSystemMetrics(SM_CYFRAME);
XTtlBit := GetSystemMetrics(SM_CXSIZE);
YTtlBit := GetSystemMetrics(SM_CYSIZE);

{$IFNDEF WIN32}
   TitleButton := Bounds(Width - (3 * XTtlBit) - ((XTtlBit div 2) - 2),
                         YFrame - 1,
                         XTtlBit + 2,
                         YTtlBit + 2);

{$ELSE}     {Delphi 2.0 positioning}
   if (GetVerInfo = VER_PLATFORM_WIN32_NT) then
     TitleButton := Bounds(Width - (3 * XTtlBit) - ((XTtlBit div 2) - 2),
                           YFrame - 1,
                           XTtlBit + 2,
                           YTtlBit + 2)
   else
     TitleButton := Bounds(Width - XFrame - 4*XTtlBit + 2,
                          XFrame + 2,
                          XTtlBit + 2,
                          YTtlBit + 2);
{$ENDIF}

Canvas.Handle := GetWindowDC(Self.Handle); {Get Device context for drawing}
try
   {Draw a button face on the TRect}
   DrawButtonFace(Canvas, TitleButton, 1, bsAutoDetect, False, False, False);
   bmap := TBitmap.Create;
   bmap.LoadFromFile('help.bmp');
   with TitleButton do
     {$IFNDEF WIN32}
       Canvas.Draw(Left + 2, Top + 2, bmap);
     {$ELSE}
       if (GetVerInfo = VER_PLATFORM_WIN32_NT) then
         Canvas.Draw(Left + 2, Top + 2, bmap)
       else
         Canvas.StretchDraw(TitleButton, bmap);
     {$ENDIF}

finally
   ReleaseDC(Self.Handle, Canvas.Handle);
   bmap.Free;
   Canvas.Handle := 0;
end;
end;

{Paint triggering events}
procedure TTitleBtnForm.WMNCActivate(var Msg : TWMNCActivate);
begin
Inherited;
DrawTitleButton;
end;

procedure TTitleBtnForm.FormResize(Sender: TObject);
begin
Perform(WM_NCACTIVATE, Word(Active), 0);
end;

{Painting events}
procedure TTitleBtnForm.WMNCPaint(var Msg : TWMNCPaint);
begin
Inherited;
DrawTitleButton;
end;

procedure TTitleBtnForm.WMSetText(var Msg : TWMSetText);
begin
Inherited;
DrawTitleButton;
end;

{Mouse-related procedures}
procedure TTitleBtnForm.WMNCHitTest(var Msg : TWMNCHitTest);
begin
Inherited;
{Check to see if the mouse was clicked in the area of the button}
with Msg do
   if PtInRect(TitleButton, Point(XPos - Left, YPos - Top)) then
     Result := htTitleBtn;
end;

procedure TTitleBtnForm.WMNCLButtonDown(var Msg : TWMNCLButtonDown);
begin
inherited;
if (Msg.HitTest = htTitleBtn) then
   ShowMessage('You pressed the new button');
end;

function TTitleBtnForm.GetVerInfo : DWORD;
var
verInfo : TOSVERSIONINFO;
begin
verInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
if GetVersionEx(verInfo) then
   Result := verInfo.dwPlatformID;
   {Returns:
     VER_PLATFORM_WIN32s             Win32s on Windows 3.1
     VER_PLATFORM_WIN32_WINDOWS        Win32 on Windows 95
     VER_PLATFORM_WIN32_NT           Windows NT }
end;

end.
2004-12-18 02:46
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
或者你想像FlashGet那样添加一个图标到IE工具栏上?
可以用COM编程,如果不用COM直接在
HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Extensions添加也可以

如果你装了FlashGet、QQ就去研究一下上面的注册表

下面是一段delphi程序实现,希望能帮上你的忙
procedure TForm1.BitBtn1Click(Sender: TObject);
var
  rg:Tregistry;
begin
   rg:=Tregistry.create;
   rg.rootkey:=HKEY_LOCAL_MACHINE;
   rg.openkey('SOFTWARE\MICROSOFT\INTERNET EXPLORER\EXTENSIONS\{0713E8D2-850A-101B-AFC0-4210102A8DA7}',true);

   rg.writestring('BUTTONTEXT',Ewenzi.text);
   rg.writestring('CLSID','{1FBA04EE-3024-11D2-8F1F-0000F87ABD16}');
   rg.writestring('DEFAULT VISIBLE','YES');
   rg.writestring('EXEC',AppName);     
   rg.writestring('ICON',AppDir+'\Icon2.ico');
   rg.writestring('HOTICON',AppDir+'\Icon1.ico');

   rg.closekey;
   rg.free;
end;
2004-12-18 02:54
0
雪    币: 383
活跃值: (786)
能力值: ( LV12,RANK:730 )
在线值:
发帖
回帖
粉丝
5
thank you very much
   谢谢高手分享
我的意思,就是比如你手头有 n 多个 exe 工具,它们当中有的要安装,有的是绿色软件,用自定义工具路径的方法将它们做成动态菜单,当然希望菜单有图标和工具名字,图标将想将它们程序本身的图标添加或画到相应的菜单上,名字就用工具名,似乎只能用你说的 Com...不知我说对了没有
2004-12-18 10:19
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
VC Delphi等编程工具里,都有简便方法就能实现的把图标放到菜单上的说。
2004-12-18 13:02
0
雪    币: 383
活跃值: (786)
能力值: ( LV12,RANK:730 )
在线值:
发帖
回帖
粉丝
7
当然能够,你的意思是根据路径向 exe文件提取图标,还是。。。

小弟仅近期初玩 Delph...:p
2004-12-18 17:40
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
8
对头
高手就是高手,说个开头就明白了
2004-12-19 00:42
0
游客
登录 | 注册 方可回帖
返回
//