www.f-in-box.com Forum Index www.f-in-box.com
F-IN-BOX
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
F-IN-BOX Home | DLL Edition | Delphi Edition | .NET Edition

Problems in context menu related code in TFPC/TTFPC

 
Post new topic   Reply to topic    www.f-in-box.com Forum Index -> Delphi / Builder / VCL Edition
View previous topic :: View next topic  
Author Message
jpierce



Joined: 11 Jan 2007
Posts: 23

PostPosted: Wed Oct 01, 2008 9:46 pm    Post subject: Problems in context menu related code in TFPC/TTFPC Reply with quote

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:

  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:

  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:

  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:

  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.
Back to top
View user's profile Send private message
Softanics
Site Admin


Joined: 18 Sep 2004
Posts: 1264
Location: Russia, St. Petersburg

PostPosted: Fri Oct 03, 2008 12:01 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Softanics
Site Admin


Joined: 18 Sep 2004
Posts: 1264
Location: Russia, St. Petersburg

PostPosted: Wed Nov 19, 2008 7:00 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jpierce



Joined: 11 Jan 2007
Posts: 23

PostPosted: Wed Nov 19, 2008 7:13 pm    Post subject: Reply with quote

Excellent! I'll have to clean up my context menu code and post it now.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    www.f-in-box.com Forum Index -> Delphi / Builder / VCL Edition All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group