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 comment

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 comment

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 comment
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 comment
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 comment

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 comment

> 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 comment

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.