LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GetPanelDisplayBitmap is flawed

Hello,

 

as the subject says, I am (very) unhappy with the function GetPanelDisplayBitmap.

 

The help of this function promises: Creates a bitmap object that contains a screenshot image of the current appearance of a panel.

 

In my understanding, current appearance means the way the panel looks including the current Windows visual style. The same meaning is implied by the well-defined phrase of a screenshot: A screenshot shows a panel as it is displayed by Windows...

 

However, the function generates a bitmap that sort of resembles the visual appearance in the UI editor, i.e. without any visual effect! (Interestingly, the size of the generated bitmap is not identical with the size of the panel in the UI editor) In particular, the wannabe screenshot lacks the panel buttons in the upper right corner of the panel title bar.

 

What I would have expected to see is the same as pressing  Alt+Prt Sc ...

 

It would be nice to have the function fixed - thanks!

0 Kudos
Message 1 of 5
(3,742 Views)

Hi Wolfgang,

 

I'm really sorry that this caused a problem for you.

 

Assuming that you passed VAL_VISIBLE_AREA as the scope, then the panel's frame, scrollbars and titlebar should definitely have been included in the bitmap. However, the frame and titlebar in the bitmap look like what they would have looked like on the screen if your panel were loaded as a child panel of another panel. This is because while CVI is responsible for drawing the frames and titlebars of child panels, it does not draw the frames and titlebars of top-level parents. The OS draws those, both in Linux and in Windows, and in so doing, it implements OS-specific features such as Aero, etc.

 

The restore/maximize/minimize buttons are also drawn by the OS, and they too are left off the bitmap.

 

By the way, this behavior is identical to that of the PrintPanel function.

 

Unfortunately this is not something that we can change. Even it we could change it, we wouldn't want to, since it would break backwards compatibility of the CVI runtime.

 

So, yes, you are correct in that what you get isn't exactly what you see on the screen. This distinction was not made clear in the documentation but I'll make a note to update it accordingly.

 

Sorry about the inconvenience.

 

Luis

0 Kudos
Message 2 of 5
(3,716 Views)

Hi Luis,

 

Yes I did use VAL_VISIBLE_AREA. And yes, I agree, the flaw could be either the documentation or the function...- my complaint was that the function didn't do what the help promised it to do.  And it may well be that the function always performed like this, I simply didn't use it before Smiley Wink But nowadays it's difficult to explain users why the 'screenshot' has so little to do with what they see on their screen...

I'd like to consider using FakeKeystroke instead to obtain the bitmap from the clipboard, but I couldn't find the virtual key for  Alt+Prt Sc . I hope there is a chance to obtain a 'real' screenshot programmatically...

 

Wolfgang

0 Kudos
Message 3 of 5
(3,710 Views)

Hey Wolfgang -

 

I wrote a small example that uses the some Win32 API functions to get a CVI bitmap of a panel.  It only works on top level panels, not child panels.  With the CVI bitmap, you can call ClipboardPutBitmap to get the image on the clipboard.  I have to warn that I wrote the code quickly, so it is not very robust.  For instance, it assumes a 32-bit color depth.

 

Hopefully it will be helpful to you -

 

NickB

National Instruments

Message 4 of 5
(3,692 Views)

Nick,

 

I am moved - thanks a bunch!

 

So far I had only a brief look at your code, I will need to step into all the Windows functions to understand it.

 

In the mean time I was browsing the forum and found this post which looked comparatively simple. But the same applies here, I need to check the functions and play with them...

 

So long,

 

Wolfgang  

0 Kudos
Message 5 of 5
(3,682 Views)