Главная страница
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.046 c
2-1141050121
ttt_111
2006-02-27 17:22
2006.03.19
Что означает эта ошибка?


3-1138186225
SdrCoder
2006-01-25 13:50
2006.03.19
Variant or safe array is locked


15-1140954049
постигаю
2006-02-26 14:40
2006.03.19
меняющаяся ячейка


4-1135644089
Arazel
2005-12-27 03:41
2006.03.19
Чтение секторов из под Win9x КАК?


4-1135870536
Sergey2005
2005-12-29 18:35
2006.03.19
Отловить завершение виндовс.