From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you get screen coordinates of something inside a subpanel?

Solved!
Go to solution

I have a GUI library that pops up a small dialog-style box next to the "thing" that a user clicks. It's very important that it shows up at the right location. I have it working even when used with splitters, but it doesn't work at all when inside a subpanel. I can't attach all of the code, but here's my current calculation part:

 

BertMcMahan_0-1592528910059.png

 

(It uses a specific cell in a table control to do the popup).

 

This works fine in a regular VI and in one with splitters, but not a subpanel. Googling took me to one thread that was half Portugese and didn't seem to have a solution.

 

I would assume this has something to do with my using the OwningVI.Panel property to invoke the CvtPaneltoScreenCoords method, but I'm not sure.

 

To make this even more annoying, this is going in an Actor Framework project, so the call chain is going to be quite hairy and I'm not quite sure if I can get the info from the call chain that I need.

0 Kudos
Message 1 of 9
(3,182 Views)
Solution
Accepted by topic author BertMcMahan

Maybe you could build off something like this.

"If you weren't supposed to push it, it wouldn't be a button."
Download All
Message 2 of 9
(3,149 Views)

Thanks Paul. I'd prefer to not do it that way as I'd really prefer it "handle" things internally and not have to remember to set a tag. For my particular use-case I'd prefer that I didn't have to modify my VI and I'd rather it didn't have to operate differently if it's in a subpanel or not.

 

This is going in a QControl, so it's already "bundled up" from the user's POV.

 

As a second question, how'd you get that method to show up? I have VI Scripting enabled but don't see it in the list.

0 Kudos
Message 3 of 9
(3,109 Views)

@BertMcMahan wrote:

Thanks Paul. I'd prefer to not do it that way as I'd really prefer it "handle" things internally and not have to remember to set a tag. For my particular use-case I'd prefer that I didn't have to modify my VI and I'd rather it didn't have to operate differently if it's in a subpanel or not.

 

This is going in a QControl, so it's already "bundled up" from the user's POV.

 

As a second question, how'd you get that method to show up? I have VI Scripting enabled but don't see it in the list.


I turn on lots of extra stuff.  It's probably one of these (in labview.ini):

SuperPrivateScriptingFeatureVisible=True
SuperPrivateSpecialStuff=TRUE
SuperSecretPrivateSpecialStuff=True
SuperSecretCLAFeatures=True

"If you weren't supposed to push it, it wouldn't be a button."
Message 4 of 9
(3,086 Views)
Solution
Accepted by topic author BertMcMahan

I wish working with subpanels just gave the right coordinates but it doesn’t.

 

To work around this in a QControl (or anywhere else) I have had to pass the QControl a reference to the Subpanel and do the math internally from there.

 

I’ll try to find an example and post it later when I’m back at my computer. 

Quentin "Q" Alldredge

Chief LabVIEW Architect, Testeract | Owner, Q Software Innovations, LLC (QSI)
Director, GCentral | Admin, LabVIEW Wiki | Creator, The QControl Toolkit
Certified LabVIEW Architect | LabVIEW Champion | NI Alliance Partner



0 Kudos
Message 5 of 9
(3,073 Views)

Thanks Q, I have it working now using a similar method, but instead of sending the subpanel reference I just sent the owning VI reference. That should "stack" better if I ever need it to work with multiple subpanels.

 

I'm marking this as the "solution" just for the confirmation that it's not just me, that method just doesn't work in a subpanel.

 

I threw the idea to fix that on the idea exchange (though IMHO it's more of a bug than an idea 😁)

 

https://forums.ni.com/t5/LabVIEW-Idea-Exchange/Update-quot-Convert-Panel-to-Screen-Coordinates-quot-...

 

0 Kudos
Message 6 of 9
(3,070 Views)

Could your throw up your working code? I'm running into the same issue currently, doing the same thing you are. So it would be nice to see how you resolved it.

0 Kudos
Message 7 of 9
(2,681 Views)

Hi,

Have attached a .vi that can be used to get the screen coordinates for the top-right of a control. This also works in nested sub-panels. You can modify this VI to get different relative positions (and I plan to for "speech-bubble" like ui dialogs of different directions).

Note that it requires the top-level .vi to be passed into it. This allows for scalability of the UI framework without the need for relative position of each nested sub-panel.

 

fergusson_0-1685438775700.png

 

Message 8 of 9
(1,029 Views)

Attached is a modified version from @fergusson which works also if control is part of a tab control and returns an error if control is not found in any pane. It returns bottom left position of the control (LV2020)

LucianM_0-1696253741687.png

 

Lucian
CLA
0 Kudos
Message 9 of 9
(598 Views)