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

Вниз

Adding OnClick-Event to PMenu   Найти похожие ветки 

 
rofl   (2005-03-19 19:35) [0]

i have a pmenu that expands a folder structure. now if i click on a item THAT HAS A SUBMENU, the OnMenuItem event is not executed !
so i seek a way to add a click-handler procedure to the menu, in vcl i would do it like this:

TMyMenu = class(TMenu)
private
 procedure WndProc(var Message: TMessage); override;
end;

implementation
procedure TMyButton.WndProc(var Message: TMessage);
begin
 case Message.Msg of
   WM_LBUTTONDOWN, WM_LBUTTONDBLCLK: doSomething;
 end;
 inherited;
end;

how can it be done in KOL ?
thank you


 
ECM ©   (2005-03-19 20:36) [1]

Popup Menu...?
IMHO: Click-Handler procedure to the menu that has a submenu it`s impossible (use only Win32 API)...
try use WM_INITMENUPOPUP:

The WM_INITMENUPOPUP message is sent when a drop-down menu or submenu is about to become active. This allows an application to modify the menu before it is displayed, without changing the entire menu.

function TMainForm.KOLForm1Message(var Msg: tagMSG;
 var Rslt: Integer): Boolean;
begin
 if Msg.message = WM_INITMENUPOPUP  then begin
   if LoWord(Msg.lParam) = MenuItemThatHasSubMenu then begin
     // Build folder structure and submenu items
   end;
 end
end;


 
ECM ©   (2005-03-19 20:47) [2]

Use menu without submenu -> OnMenuItem -> Build new separate menu and popup then ...


 
rofl   (2005-03-19 21:16) [3]

thank you ECM,
i tried like this, but how can i get back to the default windows handler proc for my form ?
function TForm1.KOLForm1Message(var Msg: tagMSG;
 var Rslt: Integer): Boolean;
begin
 if Msg.message = WM_INITMENUPOPUP  then begin
  asm int 3 end;
  //if LoWord(Msg.lParam) = MenuItemThatHasSubMenu then begin
    // Build folder structure and submenu items
  //end;
end
  else inherited; // <- doesn"t work
end;

with inherited it doesn"t work, my form is not even painted


 
ECM ©   (2005-03-19 22:06) [4]

Sorry.. forget set Result...

function TMainForm.KOLForm1Message(var Msg: tagMSG;
var Rslt: Integer): Boolean;
begin
Result := FALSE;
if Msg.message = WM_INITMENUPOPUP  then begin
  if LoWord(Msg.lParam) = MenuItemThatHasSubMenu then begin
    // Build folder structure and submenu items
    Result := TRUE;
  end;
  // else inherited - not needed!
end
end;


 
rofl   (2005-03-21 20:57) [5]

thank you, the code works like this, but i create my whole menu on the start of the program in an own thread, because it takes around 1 minute. isn"t there a simpler way to catch the click ?
recoding the whole thing would take a long time...
when i take your code example but with WM_LBUTTONDOWN than that code is not executed when clicking on a submenu item, but spy++ tells me there have been such an event ^^


 
thaddy   (2005-03-21 21:31) [6]

You could API hook into the code with a messagehook on the Parent menu.
That way it gets executed first, before the default menu messageprocessing.
btw:I suspect the WM_BTNXXX events are accompanied by notifications? check that in Spy++, maybe I have something different.



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

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

Наверх




Память: 0.45 MB
Время: 0.042 c
14-1129797523
старый маразматик(с)
2005-10-20 12:38
2005.11.13
Алаплант Мулдашева


14-1129816780
CrazyDog
2005-10-20 17:59
2005.11.13
64 bit поддержка в Delphi


9-1120024771
cyborg
2005-06-29 09:59
2005.11.13
Как узнать имена текстур из X Mesh?


2-1130172359
Dudee
2005-10-24 20:45
2005.11.13
TString


1-1129742445
555
2005-10-19 21:20
2005.11.13
Перехват прокручивания скролла мыши.





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский