![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Adding OnClick-Event to PMenu [Delphi, Windows]
rofl © (2005-03-19 19:35:00)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
thaddy (2005-03-21 21:31:00) [1]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.
rofl (2005-03-21 20:57:00) [2]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 ^^
ECM (2005-03-19 22:06:00) [3]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-19 21:16:00) [4]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 20:47:00) [5]Use menu without submenu -> OnMenuItem -> Build new separate menu and popup then ...
ECM (2005-03-19 20:36:00) [6]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;