IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors  SOLVED

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by zarkogajic »

Hi Support,

I'm using ShowPopupMenu to display my custom menu over document's tab.

The location of the popup menu is set by the stPos parameter.

I'm getting mouse coordinates via GetCursorPos API.

Setting stPos.Left and .Top = GetCursorPos.X; stPos.Bottom and .Right = GetCursorPos.Y;

I have 3 monitors, all three have 1920x1080 resolution.

GetCursorPos returns:
negative X values for my left monitor,
X in the rage of 1-1920 for my center monitor,
X in the range of 1921-3840 for my right monitor.

If my application is on my left monitor, negative X values reported, the popup does appear over tab at correct location
If my application is on my center monitor, 1-1920 X values reported, the popup does appear over tab at correct location

BUT, if my application is on my right monitor, X values from 1921-3840 -> the popup gets displayed to the right edge of the main screen (at 1920-width of the popup).


As image:

image.png
image.png (5.62 KiB) Viewed 2752 times


This is when using SDK obviously. The EU Editor does display the popup correctly.

Is there something I can do here, or a bug in ShowPopupMenu ?

-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

Try using those methods:

Code: Select all

		hr = m_pObj->get_ClientRect(&rc);
		ASSERT(IS_DS_SUCCESSFUL(hr));
		if (IS_DS_SUCCESSFUL(hr))
		{
			hr = m_pObj->ClientRectToScreen(&rc, &rc);
			ASSERT(IS_DS_SUCCESSFUL(hr));
		}
Then the rc is passed to the ShowPopupMenu method.
Basically you can take a rectangle of some object for testing and try calling this.
The ClientRectToScreen and ScreenRectToClient allow converting from two systems. Also there are ScreenPtToClient and ScreenRectToClient methods.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by zarkogajic »

Hi Alex,

Thanks. After some playing around, here's the working result:

Code: Select all

  oMousePos : TPoint;

  dv : IPXV_DocumentView;
  tp : tagPOINT;
  menuRect : tagRect;
...
  GetCursorPos(oMousePos);

  tp.x := oMousePos.X;
  tp.y := oMousePos.Y;

  dv.Obj.ScreenPtToClient(tp, tp);

  menuRect.left := tp.X; menuRect.top := tp.X;
  menuRect.bottom := tp.Y; menuRect.right := tp.Y;

  dv.Obj.ClientRectToScreen(menuRect, menuRect);

  InstUIX.CmdManager.ShowPopupMenu(dv.Obj, theMenu, menuRect, true, 0);

-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by zarkogajic »

Hi Alex,

"Sorry", need to reopen this.

As stated all works as expected for me now - when working on 100% DPI / Full HD resolution

On laptop, 250% DPI, 4K UHD (3840x2160), the popup position always appears to the left of the DocumentView Obj.

I've tested how EU Editor works:
on 100% DPI screen the document's tab popup TOP/*LEFT* corner is where the mouse was clicked
on 250% DPI screen the document's tab popup TOP/*RIGHT* corner is where the mouse was clicked

-> So, even with EU Editor the popup placement is slightly different, but still, more-or-less as expected.

For my application (using the code from previous post) the popup's right edge appears to the left edge of the DocumentView Obj. Top is ok, but Left is wrong.


p.s.
Maybe some of UIX_ShowPopupFlags would help here? For the moment I'm using "0" for nPopupFlags.


-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

That's not OK - forwarded that to our testing team for investigation - seems like a bug from our side.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

We struggle recreating this one - can you please make a few screenshots to illustrate what you mean?
Also, what did you mean by document's tab popup?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by zarkogajic »

Hi Alex,

EU Editor on HighDPI - the second tab is right clicked and the mouse was where the top right-corner of the popup is.

tabpopuphighdpi.png

Anyhow: this seems to be a thing of Windows as I see such placement in Windows File Explorer as well (popup's top-right where the mouse was right clicked).


On non-HighDPI screens, the popup's top-left is where the mouse is.

image.png

My app on HighDPI (right click over second tab):

myapptabpopuphighdpi.png

And I'm using the same code - so must be something else wrongly placing the popup ...

-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

Is this recreatable in the FullDemo project, so I can test it from there?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by zarkogajic »

Hi Alex,

You mean the looks and where the popup appears is in my application?

That will be a heavy task to "transfer" all my code in C# ...

-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

Not the looks - just popup appearance - that's all we need to test this.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by zarkogajic »

Hi Alex,

Have you tried Eu Editor on HighDPI?

Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

Well as you have said before - the offset that you are experiencing is Windows "feature".
The offset from your SDK application - that's not OK.
Here's how we are showing the menu:

Code: Select all

//We are getting the mouse position from any of the mouse events
pEvent->nCode >= WM_MOUSEFIRST && pEvent->nCode <= WM_MOUSELAST
//Then we are getting the pointer position
	pos.x = GET_X_LPARAM(nParam2);
	pos.y = GET_Y_LPARAM(nParam2);

	if ((nCode != WM_MOUSEWHEEL) && (nCode != WM_MOUSEHWHEEL))
		::ClientToScreen((HWND)hWnd, &pos);

	g_ptMouseEventPos = pos;
//Alternatively we can use this - though the first way is used in EU Editor
::GetCursorPos(&pos);

//Then we create a rectangle with the (pos.x, pos.y, pos.x, pos.y) paramers - left top right bottom
//After that we are calling the IUIX_CmdManager::ShowPopupMenu method while passing the rectangle with 0 flags - that's all

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by zarkogajic »

Hi Alex,

Thanks, that's what I am doing (with a few more ClientToScreen and back) ..

ok, keep it so for the moment, and will get back to that problem later and report if I find our something ...

-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

Got it.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by zarkogajic »

Hi Alex,
Sasha - Tracker Dev Team wrote: Thu Mar 11, 2021 1:31 pm Here's how we are showing the menu:

Code: Select all

//We are getting the mouse position from any of the mouse events
pEvent->nCode >= WM_MOUSEFIRST && pEvent->nCode <= WM_MOUSELAST
...
Where do you do this?

I can catch mouse events in my custom IUIX_ObjImpl implementation - but I need to do this for a particular IUIX_Obj. So, I can and do PagesView, BookmarsksView, MainFrame .. and the rest - and that's many places to have the same code of getting to know where the mouse is..

Is there a single place where I can catch such native events (Windows messages) ?

I've tried Inst.EventServer.Register[Native]EventHandler for WM_MouseXYZ stuff but am not sure what nEventID should be used (cannot use eg WM_MOUSEMOVE as event id).

-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

Nope, I was talking about some tool that can show a popup menu. Basically the same case if you implemented your own object or object event handler.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors  SOLVED

Post by zarkogajic »

Hi Alex,

ok, thanks.

-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

IUIX_CmdManager.ShowPopupMenu stPos param on 3 monitors

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply