Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "KOL";
Текущий архив: 2011.10.23;
Скачать: [xml.tar.bz2];

Вниз

Dinamic menu bar   Найти похожие ветки 

 
bert9000   (2009-02-23 19:33) [0]

Hi all,
my name is Alberto from Italy, I"m sorry if I write in english...
I"m developing an application in Lazarus and KOL 2.88.
My application has several pages each one with its own menus.
To create a dynamic menu I"m using TKOLMainMenu and I added several menu items at design-time then, depending on the selected page, I make only two menus visible and all the other items not visibile.
The problem is sometime no menu is displayed, clicking on the menu I see the menu bar item selected but no menu shown. Going back and forth my pages, sometime the menu are displayed again.

This is the code I use to make items visible or not:

   MainMenu.Items[LM_commandwait].Visible := (gui_status = st_commandwait);
   MainMenu.Items[RM_commandwait].Visible := (gui_status = st_commandwait);
   MainMenu.Items[LM_numberdial].Visible := (gui_status = st_numberdial);
   MainMenu.Items[RM_numberdial].Visible := (gui_status = st_numberdial);
   MainMenu.Items[LM_calling].Visible := (gui_status = st_calling);
   MainMenu.Items[RM_calling].Visible := (gui_status = st_calling);

where MainMenu : TKOLMainMenu , LM_* RM_* are costants used for menu identifying and gui_status is about the selected page.
Depending on gui_status, only two menus are visible and all the others not visible.
I tried MainMenu.RedrawFormMenuBar at the end to refresh menu bar but nothing changes.

I searched the forum with no luck and I can"t understand how to fix it.

Many thanks for your attention
Alberto


 
Jon ©   (2009-02-24 05:17) [1]

Here is a test program that demonstrates dynamic menus:


program Test;

uses
 KOL;

var
 MainMenu, Menu1, Menu2, Menu3: PMenu;
 Select1, Select2, Select3, Checkbox: PControl;

procedure CorrectMenuItems;
begin
 if Menu1.Visible then Menu1.Items[0].Visible := Checkbox.Checked;
 if Menu2.Visible then Menu2.Items[0].Visible := Checkbox.Checked;
 if Menu3.Visible then Menu3.Items[0].Visible := Checkbox.Checked;
end;

procedure SelectClick(Dummy: Pointer; Sender: PObj);
begin
 Menu1.Visible := Select1.Checked;
 Menu2.Visible := Select2.Checked;
 Menu3.Visible := Select3.Checked;
 CorrectMenuItems;
end;

procedure CheckboxClick(Dummy: Pointer; Sender: PControl);
begin
 MainMenu.Items[1].Visible := Checkbox.Checked;
 CorrectMenuItems;
end;

begin
 Applet := NewForm(nil,"Test").SetSize(200,200);
 MainMenu := NewMenu(Applet,0,["File","(","Test","Item1","Item2",")","Exit"],nil);
 Menu1 := NewMenu(nil,0,["Test1","111"],nil);
 Menu2 := NewMenu(nil,0,["Test2","222"],nil);
 Menu3 := NewMenu(nil,0,["Test3","333"],nil);
 Menu1.Caption := "Menu 1";
 Menu2.Caption := "Menu 2";
 Menu3.Caption := "Menu 3";
 MainMenu.InsertSubMenu(Menu1,-1);
 MainMenu.InsertSubMenu(Menu2,-1);
 MainMenu.InsertSubMenu(Menu3,-1);
 Menu1.Visible := False;
 Menu2.Visible := False;
 Menu3.Visible := False;
 Select1 := NewRadiobox(Applet,"Page 1").AutoSize(True).PlaceUnder;
 Select2 := NewRadiobox(Applet,"Page 2").AutoSize(True).PlaceUnder;
 Select3 := NewRadiobox(Applet,"Page 3").AutoSize(True).PlaceUnder;
 Select1.OnClick := TOnEvent(MakeMethod(nil,@SelectClick));
 Select2.OnClick := TOnEvent(MakeMethod(nil,@SelectClick));
 Select3.OnClick := TOnEvent(MakeMethod(nil,@SelectClick));
 Checkbox := NewCheckbox(Applet,"Show test items").PlaceUnder.AutoSize(True).SetChecked(True);
 CheckBox.OnClick := TOnEvent(MakeMethod(nil,@CheckboxClick));
 Run(Applet);
end.


 
bert9000   (2009-02-24 13:52) [2]

Hi Jon,

first of all many thanks for your quick reply.
I have to add I am developing for WinCE architecture.
I can run your application and I can understand how it works. It"s fine on Win32 but on WinCE I see only a small window and menus are not modified (not a problem, maybe I should set some applet property).
You are telling me to create menus at run-time but I prefer (if possible) to create them at design time because seems to be easier. On the auto generated *_1.inc file I see these commands:


   Result.MainMenu := NewMenu( Result.Form, 0, [ "Call", "Menu"
     , "(", "Change user status", "Show lost calls"
     , "Show unlistened messages", "Show unread messages", "-"
     , "Settings", "Exit", ")", "Call", "Menu", "("
     , "Send text message", "Retrieve call", "-", "Settings"
     , "Exit", ")", "Hang up", "Menu", "(", "Forward"
     , "On hold", "Switch call", "-", "Start recording"
     , "Stop recording", "-", "Settings", "Exit", ")", "" ], nil );


all the sub-menus created at design-time then making them visibile at run-time


   MainMenu.Items[itemindex].Visible := ...


where Items[itemindex] is the single sub-menu item with its own tree.

So my code it"s quite similar to your code but maybe the problem is that I have too many sub-menu items on a single menu and making them visible or not causes this problem...

I"ll try using your code in my application.

Again many thanks
bye
Alberto


 
Jon ©   (2009-02-24 14:16) [3]

If developing for WinCE do not use KOL 2.88.
Use KOL-CE instead: http://sourceforge.net/projects/kol-ce/
More information: http://wiki.freepascal.org/KOL-CE


 
bert9000   (2009-02-24 15:09) [4]

OOps...
Excuse me, I was already using KOL-CE 2.80.1 ...
I see there are new versions available and in 2.80.2 version there is a bug fix
(MCK: Fixed visual glitches in menu and action list editors) that makes me hoping...

Anyway I"ll try the last version 2.80.3

Many thanks for the advice

Alberto

P.S. using your method (run-time submenu creation) on KOL-CE 2.80.1 I still have the same problems (menus sometimes not shown...)


 
bert9000   (2009-02-24 20:11) [5]

Hi,
I updated to Lazarus 0.9.26 and KOL-CE 2.80.3
Still same problems with menus...
I"m gonna try something else, instead of inserting sub menus I could make a single menu with all the items then make the single items visible or not... It was my first idea but it"s more complex to do.

Do you have some other ideas of what could I do?

Thank you!
bye
Alberto


 
Yury Sidorov   (2009-02-24 20:23) [6]

Alberto, do you test on Pocket PC or Smartphone version of Windows Mobile?
Dynamic menus may not work properly on Smartphones.


 
Jon ©   (2009-02-25 02:51) [7]

Hello Yuri - this is off-topic, but do you and Vladimir have any plans in the future to merge KOL and KOL-CE to create a universal Win32/WinCE/Delphi/FPC solution? (Maybe even add support for Win64?)


 
blackman2003   (2009-02-25 08:59) [8]

Yury Sidorov полностью подтверждаю наличие такого бага.
KOL-CE + Lazarus
Причем проявляться может интересно - один и тот же код компилируется под Win32 и WinCE, при этом под Win32 наблюдается это странное дублирование названий пунктов меню (хотя обращение идет только к свойствам типа Visible и Enabled), а под WinCE этого нет.
Ранее без использования MCK точно такой же баг проявлялся на обеих платформах, но там KOL-CE была более ранних версий.


 
bert9000   (2009-02-25 12:39) [9]

Yury, here are my test results:
- FAIL on a real HTC Smartphone with Windows Mobile 6 (CE 5.2.1235 Build 17740.0.2.0)
- FAIL on a emulated Smartphone device Windows Mobile 5.0 (OS 5.1.195 Build 14847.2.0.0)
- FAIL on a emulated Smartphone QVGA device Windows Mobile 5.0 (OS 5.1.195 Build 14847.2.0.0)
- SUCCESS on a emulated Pocket PC device Windows Mobile 5.0 (OS 5.1.195 Build 14847.2.0.0)

FAIL means that menus sometimes not shown when clicked (in a random way), SUCCESS means that menus are always shown but after some "Visible" property settings the menu bar look different (usually I have MENULEFT KEYBOARD MENURIGHT, then MENULEFT MENURIGHT KEYBOARD with a different color and font).

My question is: should I try a different way? I was thinking about two huge menus with all the items, playing with items.visible property and changing menu caption?

Thanks for your beautiful work Yury
bye
Alberto


 
bert9000   (2009-02-25 15:01) [10]

Oh-ho...
I"m in big trouble now... I made a huge menus with all the items, playing with items.visible property and changing menu caption but it has the same problems... So it"s not a SubMenu thing but a items.visible property issue... At first they work then moving around they randomly disappear...
What else? Using popup menus? Or disable all menus and paint them on my form (it would be a huuuge work...)

:(
Alberto


 
Jon ©   (2009-02-25 17:36) [11]

Try toolbar?


 
bert9000   (2009-02-26 20:34) [12]

Hi,
good news! I"m using popup menus to do the task and they work well.
I have many popup menus, one for each menu I need and a main menu with only two items. I change the main menu captions as I need and I catch the clicks on main menu items and make the proper popup menu to show with the PopUp method. As coordinates I use 1,300 for the left menu and 300,300 for the right menu so they are aligned with left or right margin of the window (maybe I could use a smarter method to align).
It works fine on a real Windows Mobile 6.0 Smartphone and on a emulated Windows Mobile 5.0 Pocket PC.

So, I"m sorry for the faulty main menu item but this seems to be a brilliant way to resolve this problem.

Thanks you all!
bye
Alberto


 
Yury Sidorov   (2009-02-26 21:39) [13]

Alberto,
Please submit bug report to KOL-CE project page on SourceForge and attach the test program. I will take a look on it some day.


 
bert9000   (2009-03-02 20:24) [14]

Hi,
I"ll try to make a test application as soon as possible.
But it"s very simple to make it happens, just play with the Items.visible property and soon or later the problem will come up!

bye
Alberto


 
имя   (2009-03-30 12:06) [15]

Удалено модератором


 
имя   (2009-03-30 12:06) [16]

Удалено модератором



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

Форум: "KOL";
Текущий архив: 2011.10.23;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.49 MB
Время: 0.003 c
15-1309120193
Юрий
2011-06-27 00:29
2011.10.23
С днем рождения ! 27 июня 2011 понедельник


1-1269772989
dmitry1208197320
2010-03-28 14:43
2011.10.23
Как организовать работу с картами типа google?


15-1308914383
Мимо не прошел
2011-06-24 15:19
2011.10.23
Пессимистичная фантазия.


2-1309782690
Criptonik
2011-07-04 16:31
2011.10.23
Вставка в Memo


15-1309155531
brother
2011-06-27 10:18
2011.10.23
Служюы в WinXP





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский