Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

menu problem [Delphi, Windows]


Страницы:   1 2

arthur ©   (2008-10-27 20:09:00) 

this is the code i use to create the menus

 treemenu := NewMenu(channeltree, 0, [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'Clear Hotkeys'], treemenuproc);
 channeltree.SetAutoPopupMenu(treemenu);
 traymenu := NewMenu(nil, 0, [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'Clear Hotkeys'], traymenuproc);
 Tray.PopupMenu := traymenu.Handle;

Tray is a BAPTrayIcon
channeltree is a treeview

the problem is, if i create those 2 menus i receive an application error when add items to my treeview

if i don't create the tray menu the chanelltree it works nice,
and if i don't create the channeltree menu the traymenu works nice

... i already tried several things, but to keep my treeview working i can't create more than 1 menu =\.

any idea of what is wrong?

Thanks,
Arthur.

obs: sorry my english, i'm from brazil.


Jon   (2008-11-09 23:35:00) [21]

[OT] Seems like you are updating 1ClickMusic - I have v1.8.0 - would like update when done ;-)


Jon   (2008-11-09 19:52:00) [22]

Your code works for me. Maybe the problem is with "traymenuproc" - try using "nil" to test. Or show us more of your code.


arthur   (2008-11-09 19:39:00) [23]

come on these menus are very problematic,

if i try,


>   //# MENUS
>   NewMenu(Form, 0, [''], nil);
>
>   treemenu := NewMenu(channeltree, 0, [' ', ' ', ' ', '
> ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'Clear Hotkeys'],
>  treemenuproc);
>   channeltree.SetAutoPopupMenu(treemenu);
>
>   traymenu := NewMenu(Form, 0, ['Radios', '(', ' ', ' ',
>  ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ')',
> 'About', 'Exit'], traymenuproc);
>   Tray.PopupMenu := traymenu.Handle;


app crashes when adding items to channeltree,
but if i create the the traymenu with less items it works!?, what's wrong now?


Jon   (2008-11-09 04:27:00) [24]

There should be no problem if you do not destroy MainForm.
My example is based upon what MCK would create.
If you want to, you could use Applet as the parent:


 NewMenu(Applet,0,[''],nil);
 TrayMenu := NewMenu(Applet,0,[' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Clear Hotkeys'],nil);


arthur   (2008-11-09 02:25:00) [25]

just another question, is there a problem if i create the tray popup menu with MainForm as Parent (like in your example) ?


Jon   (2008-11-08 16:04:00) [26]

You're welcome - happy to know that it worked.
Note: it is necessary only if MainForm does not have a main menu.


arthur   (2008-11-08 04:26:00) [27]

it works, =D Thanks!!!

NewMenu(MainForm,0,[''],nil);
is the really important

i just added it before creating the other menus everything is working nice now =D


Jon   (2008-11-07 17:50:00) [28]

Here is a complete example using KOL only:


program Test;

uses
 Windows, Messages, KOL;

var
 MainForm, Treeview: PControl;
 TreeMenu, TrayMenu: PMenu;
 TrayIcon: PTrayIcon;

procedure TrayIconMouse(Dummy: PControl; Sender: PObj; WMessage: Word);
var
 Point: TPoint;
begin
 if WMessage = WM_LBUTTONDOWN then
 begin
   GetCursorPos(Point);
   TrayMenu.Popup(Point.X,Point.Y);
 end;
end;

begin
 Applet := NewApplet('Test');
 MainForm := NewForm(Applet,Applet.Caption).SetSize(320,240);
 NewMenu(MainForm,0,[''],nil);
 TreeView := NewTreeView(MainForm,[],nil,nil).SetAlign(caClient);
 TreeMenu := NewMenu(TreeView,0,[' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Clear Hotkeys'],nil);
 TreeView.SetAutoPopupMenu(TreeMenu);
 TrayIcon := NewTrayIcon(Applet,LoadIcon(0,IDI_INFORMATION));
 TrayIcon.Active := True;
 TrayIcon.OnMouse := TOnTrayIconMouse(MakeMethod(nil,@TrayIconMouse));
 TrayMenu := NewMenu(MainForm,0,[' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Clear Hotkeys'],nil);
 Applet.Add2AutoFree(TrayIcon);
 Run(Applet);
end.


The important line is

 NewMenu(MainForm,0,[''],nil);


arthur   (2008-11-07 17:02:00) [29]

please help =\


Страницы:   1 2

Наверх

Титульная страница Поиск, карта сайта Написать письмо