Главная страница
    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.048 c
2-1130299499
UVV
2005-10-26 08:04
2005.11.13
Можно ли так, или я многого хочу от Delphi


1-1129798274
Dimedrol
2005-10-20 12:51
2005.11.13
Автоматизация и контроль над Internet Explorer


3-1125670434
Analitik
2005-09-02 18:13
2005.11.13
как запостить файл в поле BLOB для INTERBASE?


14-1129884103
TButton
2005-10-21 12:41
2005.11.13
глючит звук


3-1128368821
ALEX_T
2005-10-03 23:47
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
Английский Французский Немецкий Итальянский Португальский Русский Испанский