Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2006.03.19;
Скачать: CL | DM;

Вниз

К;ак динамически добавить пункты меню в PopupMenu?   Найти похожие ветки 

 
dera   (2006-03-06 09:23) [0]



 
API ©   (2006-03-06 09:26) [1]

PopupMenu.Items.Add(NewItem(<...>));


 
dera   (2006-03-06 09:29) [2]

(<...>)

Что тут должно быть? Наименование пункта? Как его записать?


 
API ©   (2006-03-06 09:44) [3]

F1 уже отменили?


 
dera   (2006-03-06 09:57) [4]

>API ©   (06.03.06 09:44) [3]
Вот так всегда :-(((


 
API ©   (2006-03-06 10:12) [5]

Вот так всегда :-(((

Может, надо сделать соответствующие выводы? А?

NewItem function

Creates and initializes a menu item.

Unit: Menus

function NewItem(const ACaption: string; AShortCut: TShortCut; AChecked, AEnabled: Boolean; AOnClick: TNotifyEvent; hCtx: THelpContext; const AName: string): TMenuItem;

Description

Call NewItem to create and initialize a menu item when constructing a menu programmatically.

The ACaption parameter specifies the string that should appear for the menu item.  
The AShortCut parameter specifies any associated shortcut.
The AChecked parameter indicates whether the menu item appears with a check mark.
The AEnabled parameter specifies whether the menu item is enabled or grayed.
The AOnClick parameter specifies an event handler that executes when the user clicks the menu item.
The hCtx parameter specifies the help context ID for the menu item.

The AName parameter specifies the name of the menu item, which can be used to refer to the menu item in code.

The menu item returned by NewItem can be added to a menu using the target parent’s Add method. If the entire menu is being created dynamically at runtime, the new menu item can be added to an array that is passed as a parameter to the NewMenu, NewPopupMenu, or NewSubMenu function.

Warning: The item returned by NewItem does not have an owner. You are responsible for freeing its memory when it is no longer needed. The Delete and Remove methods of TMenuItem do not free memory.

Пример:

PopupMenu.Items.Add(NewItem("New menu item name", TextToShortCut("Ctrl+N"), false, true, MenuItemClick, 0, "NewMenuItem"));

С учетом Warning - Вы должны обеспечить уничтожение этого пункта меню, в противном случае будут утечки памяти.


 
dera   (2006-03-06 10:38) [6]

>API ©   (06.03.06 10:12) [5]
Спасибо!!! Если честно, не ожидал ответа


 
dera   (2006-03-06 10:43) [7]

Это опять я с вопросом :-)

Пишет: Undeclared identifier: "MenuItemClick"


 
Сайбель Алексей ©   (2006-03-06 10:49) [8]


> Спасибо!!! Если честно, не ожидал ответа

Ответы API © [5] и [3] не отличаются.


> Пишет: Undeclared identifier: "MenuItemClick"

"MenuItemClick" - это parameter specifies an event handler that executes when the user clicks the menu item
Попробуйте с nil, и при клике на вашу вновь созданную кнопку не произойдет ничего.


 
API ©   (2006-03-06 11:08) [9]

Undeclared identifier: "MenuItemClick"

type
 TForm1 = class(TForm)
 <...>
   procedure MenuItemClick(Sender: TObject);
 end;

<...>

procedure TForm1.MenuItemClick(Sender: TObject);
begin
 ShowMessage("New menu item clicked");
end;


P.S. Купите книгу, а? ;)


 
dera   (2006-03-06 11:12) [10]

>Сайбель Алексей ©   (06.03.06 10:49) [8]

спасибо, за понимание и подсказку.



Страницы: 1 вся ветка

Текущий архив: 2006.03.19;
Скачать: CL | DM;

Наверх




Память: 0.49 MB
Время: 0.043 c
2-1141639115
werr
2006-03-06 12:58
2006.03.19
В Delphi 6 перестально работать DefaultDrawColumnCell. Почему???


2-1140677668
Новочеркасский Волк
2006-02-23 09:54
2006.03.19
Отправка почты. Через NMSMTP.


11-1121939979
shalex
2005-07-21 13:59
2006.03.19
MHXPStyle


1-1139816713
BanderLog
2006-02-13 10:45
2006.03.19
Отображение длительных процессов


15-1140520967
Сатир
2006-02-21 14:22
2006.03.19
Подскажите редактор бинарников