Problems in context menu related code in TFPC/TTFPC

F-IN-BOX for Delphi / Builder C++ / VCL
jpierce
Posts: 23
Joined: Thu Jan 11, 2007 4:22 pm

Problems in context menu related code in TFPC/TTFPC

Postby jpierce » Wed Oct 01, 2008 9:46 pm

I've been working on a unit to allow Flex to have complex popup menus (without Flash Player Limitations) in f-in-box, and I've run into an issue that I think could use some improvement. In TFlashPlayerControl.WndProc, there is the following code:

Code: Select all

  if not (csDesigning in ComponentState) then
    begin
      if (Message.Msg = WM_RBUTTONUP) then
        begin
          if Assigned(PopupMenu) then
          begin
            Point.X := Message.LParamLo;
            Point.Y := Message.LParamHi;

            Point := Self.ClientToScreen(Point);

            PopupMenu.Popup(Point.X, Point.Y);

            Exit;
          end;
    end;


When you call PopupMenu.Popup like this, it doesn't set PopupComponent. There are also some other things like checking for AutoPopup that are normally done by a TControl.

So instead, I propose this code replace the former:

Code: Select all

  if (Message.Msg = WM_RBUTTONUP) then
    begin
      Point.X := Message.LParamLo;
      Point.Y := Message.LParamHi;

      Point := Self.ClientToScreen(Point);

      Message.Result := Perform(WM_CONTEXTMENU, Message.WParam, MakeLParam(Point.X, Point.Y));

      Exit;
    end;


This would allow it to be processed just like a normal context menu click. Don't worry about ComponentState, the TControl checks that.

A similar thing needs to change in TTransparentFlashPlayerControl.ParentWndProc

Code: Select all

  if ((Message.Msg = WM_KEYDOWN) And (Message.WParam = VK_APPS) And (Not FStandartMenu)) then Exit;


By exiting on the VK_APPS key, you prevent being able to use a popup menu with the control that can be brought up with the apps key.

It should change to:

Code: Select all

  if (Message.Msg = WM_KEYDOWN) And (Message.WParam = VK_APPS) then
    if PopupMenu <> nil then
    begin
      Message.Result := Perform(WM_CONTEXTMENU, Message.WParam, MakeLParam(Word(-1), Word(-1)));

      Exit;
    end
    else if not StandartMenu then
      Exit;


This allows the underlying context menu event be properly processed.

I'd love to see these changes in the next version or otherwise relatively soon. This is the only thing holding me up from posting my ExternalPopupMenus code. It's some pretty cool code that lets you define and connect popup menus in Flex and have Delphi pop them up. It includes icons and submenus and has no restrictions like always having "About" and "Settings..." menu options.

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Fri Oct 03, 2008 12:01 pm

Thank you very much for the suggestions. They seems to be correct. So we will include the changes in the nearest release.

Thank you.
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Wed Nov 19, 2008 7:00 pm

The fix is included in the new version 3.4.

Thank you!
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

jpierce
Posts: 23
Joined: Thu Jan 11, 2007 4:22 pm

Postby jpierce » Wed Nov 19, 2008 7:13 pm

Excellent! I'll have to clean up my context menu code and post it now.


Return to “Delphi / Builder / VCL Edition”

Who is online

Users browsing this forum: No registered users and 6 guests

cron