Форум: "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