Jump to content

Need way in G to get monitor size minus taskbar, OS independent


Recommended Posts

Does anyone have a picture showing how, given a VI, I can get ...
     ... the size of the monitor hosting that VI's panel...
          ... minus the taskbar size (if any) on that monitor...
               ... in a platform (OS) independent manner?

I had a clean-but-annoying way to do this until I discovered that Windows10 has a mode that lets the task bar be replicated onto different monitors (and, worse, those taskbars aren't necessarily the same size). The only trick I can come up with is to maximize the panel momentarily and grab the panel size at that moment, but that creates flicker in the UI.

Yes, I am aware of these two properties:

image.png.e7ac24070956511468cf0d7226a44c44.png

They do not suffice. The first one gives all the monitor sizes without accounting for taskbar. The second one only reports taskbar on primary monitor. If I could be sure the taskbar was only ever on the primary monitor, I can figure it out from this info, but discovering taskbars on multiple monitors was an option throws a wrench in that plan.

Edited by Aristos Queue
Link to post
Share on other sites

I guess you could do your trick of maximizing momentarily with the transparency at 99% transparent.  
 

Open the VI Hidden, change the transparency, maximize, get VI panel size, change back to standard, set size and transparency. 

  • Like 1
Link to post
Share on other sites

I don't know of a way to do this OS independent. Here is a VI that gets the monitor and workspace area for any monitor, given a screen coordinate. Of course, this only works on Windows. Workspace.vi

Link to post
Share on other sites

Very neat.  So I wanted to update this to return all monitors, and all Windows, and Panel sizes.  I also saw that this was using scripting which means it won't be available in the run-time engine.  Attached is an updated version that I believe does this. (2018)  I also added a feedback node to return the previously read data if it is called again, with an optional input for a full refresh.  I did this since I believe changing monitor position and resolutions after and application has started is rare.  Still if you do this often you can just wire a True to this.  Another option would be to use the Elapse Time, and maybe do a full refresh once every couple of seconds.

One thing I also removed was the passing in of a VI reference to get the application instance to use.  I wasn't sure why this was being done since regardless of the application instance the monitors and panel bounds will be the same.  I realize AQ and Darren often work in private instances, it's just in this case I didn't think it would matter.  Please correct me if I'm wrong.  I also left in the VI description stating it is thread safe, but am unsure if it still is.

 

Compute Maximum Desktop Bounds Hooovahh Edit.vi

  • Like 1
Link to post
Share on other sites

Oh also I found a .Net method of doing this.  Using the Systems.Windows.Forms.Screen you can get All Screens, and in a loop get the Working Area of each.  Still I prefer the non-OS dependent method posted earlier.

Link to post
Share on other sites
Posted (edited)
15 hours ago, hooovahh said:

One thing I also removed was the passing in of a VI reference to get the application instance to use. 

That pretty much defeats the purpose of the VI. The whole point of the exercise was to figure out how big to size the VI relative to the monitor so the caller VI could maximally lay out its controls without taking up the whole screen... and if I don't know which monitor it is on, it doesn't work. 🙂

BUT... you made a great point about the run-time engine. 

You're right that I should have avoided the use of scripting, esp since there's a dead obvious existing VI to use -- the subVI itself! So I eliminated the app reference (HUGE performance savings closing that reference), and the creation of the new VI (no screwing with the Untitled VI count every time this VI runs), and got rid of the close ref of the new VI (another major savings). And now it'll work in a run-time engine, and it is now fast enough that I don't have to worry about caching. Thank you for the suggestion.

Saved, as before, in LV 2014.

Note: I worked in LV 2020, and I just picked 2014 as the version to save back to... it'll go back earlier if someone needs it, but, honestly, folks, I only get paid if you upgrade! 🙂

Compute Maximum Desktop Bounds.vi

Edited by Aristos Queue
Link to post
Share on other sites
1 hour ago, Aristos Queue said:

Note: I worked in LV 2020, and I just picked 2014 as the version to save back to... it'll go back earlier if someone needs it, but, honestly, folks, I only get paid if you upgrade!

which begs for the question : will LV 2020 be released in august 2020 xor at next NIWeek?

Link to post
Share on other sites

I have heard directly from NI that there are no plans to delay the releases that were planned for NI Week being in May.  So I would expect the virtual event planned instead of NI Week in May will have all of the normal product announcements we would normally have in NI Week keynotes.

Link to post
Share on other sites

> I have heard directly from NI that there are no plans to delay the releases that were planned for NI Week being in May. 

A few are moving a bit earlier even. I'll be flagging LV 2020 on LAVA as soon as it is available (if the NI marketing folks don't beat me to it). I'm maybe perhaps just a little bit excited about this particular release.

Link to post
Share on other sites
7 minutes ago, Aristos Queue said:

I'm maybe perhaps just a little bit excited about this particular release.

What in particular has you excited? If you can share today. I didn't do the beta this year so I'm out of the loop on the new stuff.

Link to post
Share on other sites

Bah, Crossulz! You are definitely not invited to the next White Elephant gift exchange. You'd show up with a wrapped present and just announce, "It's socks. Just so you know." 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.