Jump to content

Geting EMF image of an VI window


dcooper

Recommended Posts

I am trying to get a emf image of a VI front panel in Microsoft Windows. I don't want to use jpeg, BMP, or png. I am using CreateEnhMetaFileA and SendMessage with WM_PRINT. I am able to get the image of the parent window with no problem. Unfortunatly, I found out the hard way that Labview Front Panel (CLIENT) and controls and indicators (Children windows) are not acually windows. So when I capture the Window Image, I only get the parent window. The rest is blank. How does Labview create controls in the Windows OS environment? I know LV is cross platform, but how do they get around this?

Does anyone have any other ideas for how to get the image? I know I can get a EMF of a graph, but I want an EMF of the entire front panel.

I have attached an example VI that works for getting screen shot of parent window. (Please excuse the messy vi, it is just for test)

Thanks

Link to comment

I believe LV use an antiquated version of the mesa.dll to render objects in the FP and BD. This dll is located under your resource folder (in here "C:\Program Files\National Instruments\LabVIEW 8.6\resource\mesa.dll" for a typical installation).

As far as I know this dll has been customized by NI (I might be wrong here) but there might be some functions available in there for getting emf images of objects.

Hmm there is a wglGetCurrentDC in there; may be this could get you somewhere.

Let us know how it goes.

PJM

PS: You might want to update your profile to indicate that you are using LV 8.6

Link to comment

QUOTE (PJM_labview @ Oct 8 2008, 12:26 PM)

I believe LV use an antiquated version of the mesa.dll to render objects in the FP and BD. This dll is located under your resource folder (in here "C:\Program Files\National Instruments\LabVIEW 8.6\resource\mesa.dll" for a typical installation).

As far as I know this dll has been customized by NI (I might be wrong here) but there might be some functions available in there for getting emf images of objects.

Hmm there is a wglGetCurrentDC in there; may be this could get you somewhere.

Let us know how it goes.

PJM

PS: You might want to update your profile to indicate that you are using LV 8.6

Thanks for your help,

I checked wglGetCurrentDC, but it returned 0. At least I know what LV is using for drawing. I just need to get better familar with mesa.

Does anyone have an idea how I can pass the mesa hdc to CreateEnhMetaFileA? Is there a way to create a EMF with mesa? I assume there is not since EMF files are windows only, and mesa is cross platform.

Another alternative is to use a Virtual Print Driver to create the EMF when using the Panel Print To Printer method, but this is an awkward solution.

Any Ideas would be great!

Link to comment
  • 2 weeks later...

QUOTE (PJM_labview @ Oct 8 2008, 12:26 PM)

I believe LV use an antiquated version of the mesa.dll to render objects in the FP and BD. This dll is located under your resource folder (in here "C:\Program Files\National Instruments\LabVIEW 8.6\resource\mesa.dll" for a typical installation).

As far as I know this dll has been customized by NI (I might be wrong here) but there might be some functions available in there for getting emf images of objects.

Hmm there is a wglGetCurrentDC in there; may be this could get you somewhere.

No! LabVIEW uses its own completely self cooked widget library. Basically a highly object oriented thing but all implemented in standard C way back in LabVIEW 2 days. So a LabVIEW window is in fact an OS window but anything inside that window are simply self generated widgets using drawing primitives of the underlaying OS. In the case of Windows LabVIEW actually draws lines (vectors) using Windows GDI, for the Mac it uses (used?) Quickdraw, and for Unix it directly uses XWindows drawing primitives. So as far as the OS is concerned there are no UI objects on a LabVIEW front panel but simply lines, circles, rectangles and text.

That said it should be possible to capture the EMF drawing of a LabVIEW frontpanel by getting Windows to render the redrawing of a window into an EMF context instead of into the window. How to do that is however probably quite tricky. I know that it worked perfectly in Windows 95 as I have often gotten screen shots into MS Word that scaled nicely. In newer Windows versions it was a bit more tricky but it is usually possible. The way I do that is by using the Crtl-PrntScrn keyboard shortcut which gets various capture formats of the currently active window into the clipboard. many applications choose to pick the BMP format from the clipboard when it is available but Word seems to prefer EMF resp. WMF if it is there. You do of course need to have an application that does know how to deal with these metaformats properly.

PS: Mesa aka. OpenGL is only used for the 3D controls and there mainly for the alpha shading but for the rest those controls are simply native LabVIEW widgets as all other controls too.

Rolf Kalbermatter

Link to comment

QUOTE (rolfk @ Oct 18 2008, 01:13 PM)

PS: Mesa aka. OpenGL is only used for the 3D controls and there mainly for the alpha shading but for the rest those controls are simply native LabVIEW widgets as all other controls too.

Rolf Kalbermatter

Ah, I knew that you would be the one that would have the answer to this one. This is good to know.

By the way, when I upgrade the mesa.dll to a newer version, every 3D controls/widget (even on toolbar) are no longer rendered.

Just though I would share this.

Thanks again Rolf for the info.

PJM

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.