Mencari Item Nama (Caption or Tag) dalam TMenu.Items?

sesuai dengan judulnya……

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, ComCtrls, Menus;

procedure BypassMenuItem(Func: Pointer; Source: TMenuItem);
function FindItemByName(aMenuItem: TMenuItem; Value: string): TMenuItem;

var
StringValue: string;
IntegerValue: Integer;…implementation

procedure BypassMenuItem(Func: Pointer; Source: TMenuItem);
var
I, J: Integer;
MenuSize: Integer;
Done: Boolean;

function ByPass(var I: Integer; aMenuItem: TMenuItem; AFunc: Pointer): Boolean;
var
Item: TMenuItem;
begin
if aMenuItem = nil then Exit;
Result := False;

while not Result and (I < aMenuItem.Count) do
begin
Item := aMenuItem[I];
asm
MOV     EAX,Item
MOV     EDX,[EBP+8]
PUSH    DWORD PTR [EDX]
CALL    DWORD PTR AFunc
ADD     ESP,4
MOV     Result,AL
end;
Inc(I);
end;
end;
begin
I        := 0;
J        := 0;
MenuSize := 0;
if Source <> nil then MenuSize := Source.Count;
Done := False;
while not Done and (I < MenuSize) do
begin
Done := Bypass(I, Source, Func);
while (I < MenuSize) do Inc(I);
end;
end;

function FindItemByName(aMenuItem: TMenuItem; ItemName: string): TMenuItem;

function Find(Item: TMenuItem): Boolean;
var
I: Integer;
begin
Result := False;
if (StringValue = Item.Name) then
begin
FoundItem := Item;
Result := True;
Exit;
end
else
for I := 0 to Item.Count – 1 do
if Find(Item[I]) then
begin
Result := True;
Exit;
end;
end;
begin
FoundItem   := nil;
StringValue := ItemName;

BypassMenuItem(@Find, aMenuItem);
Result := FoundItem;
end;

Tagged: ,

2 thoughts on “Mencari Item Nama (Caption or Tag) dalam TMenu.Items?

  1. starboard 15 Januari 2009 pukul 10:18 am

    ada founditem cuman tidak ada deklarasi variabel nya.

    gimana nih?

    http://www.swissdelphicenter.ch/torry/showcode.php?id=2212

  2. Visit Site 19 Agustus 2013 pukul 8:13 am

    A fascinating discussion is worth comment.

    I do believe that you ought to publish more about
    this subject, it may not be a taboo subject but usually people don’t discuss such topics. To the next! Many thanks!!

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: