function TForm1.Func_Find_CodePopup(CodeNo: String; CodePopup: TPopupMenu): String;
var
I : Integer;
begin
for I := 0 to CodePopup.Items.Count - 1 do
if CodePopup.Items[I].Hint = CodeNo then
Result := CodePopup.Items[I].Caption;
end;
procedure TForm1.PM_CodePopupItemClick(Sender: TObject);
var
buffer : String;
begin
buffer := TMenuItem(Sender).Caption;
case TMenuItem(Sender).GroupIndex of
1 : Edit1.Text := TMenuItem(Sender).Hint;
end;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
I : Integer;
MenuItem : TMenuItem;
begin
for I := PopupMenu1.Items.Count -1 downto 0 do
PopupMenu1.Items.Delete(I);
for I := 1 to 20 do
begin
MenuItem := TMenuItem.Create(Self);
MenuItem.Caption := IntToStr(I);
MenuItem.Hint := IntToStr(I);
MenuItem.GroupIndex := 1;
if (PopupMenu1.Items.Count mod 15) = 0 then // 15개씩 메뉴를 break
MenuItem.Break := mbBreak;
MenuItem.OnClick := PM_CodePopupItemClick;
PopupMenu1.Items.Add(MenuItem);
end;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
Edit2.Text := Func_Find_CodePopup(Edit1.Text, PopupMenu1);
end;
즐프하세요...^^
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, StdCtrls, Buttons;
type
TForm1 = class(TForm)
Edit1: TEdit;
PopupMenu1: TPopupMenu;
BitBtn1: TBitBtn;
Edit2: TEdit;
////////////////////////////////////////////////////////////////////////////////
// 사용자정의 이벤트...
procedure PM_CodePopupItemClick(Sender: TObject);
////////////////////////////////////////////////////////////////////////////////
procedure BitBtn1Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
private
{ Private declarations }
function Func_Find_CodePopup(CodeNo: String; CodePopup: TPopupMenu): String;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function TForm1.Func_Find_CodePopup(CodeNo: String; CodePopup: TPopupMenu): String;
var
I : Integer;
begin
for I := 0 to CodePopup.Items.Count - 1 do
if CodePopup.Items[I].Hint = CodeNo then
Result := CodePopup.Items[I].Caption;
end;
procedure TForm1.PM_CodePopupItemClick(Sender: TObject);
var
buffer : String;
begin
buffer := TMenuItem(Sender).Caption;
case TMenuItem(Sender).GroupIndex of
1 : Edit1.Text := TMenuItem(Sender).Hint;
end;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
I : Integer;
MenuItem : TMenuItem;
begin
for I := PopupMenu1.Items.Count -1 downto 0 do
PopupMenu1.Items.Delete(I);
for I := 1 to 20 do
begin
MenuItem := TMenuItem.Create(Self);
MenuItem.Caption := IntToStr(I);
MenuItem.Hint := IntToStr(I);
MenuItem.GroupIndex := 1;
if (PopupMenu1.Items.Count mod 15) = 0 then // 15개씩 메뉴를 break
MenuItem.Break := mbBreak;
MenuItem.OnClick := PM_CodePopupItemClick;
PopupMenu1.Items.Add(MenuItem);
end;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
Edit2.Text := Func_Find_CodePopup(Edit1.Text, PopupMenu1);
end;
end.