Author Topic: MFC to view WMF files  (Read 2549 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6941
  • AKA Daniel
MFC to view WMF files
« on: March 23, 2009, 03:32:06 AM »
I though I would share this, it took me such a long time to find a good method of displaying a WMF file in a dialog. I started out using CImage but it looked terrible when shrinking down the image. I finally ran across this post
http://www.codeproject.com/KB/static/imagepreview.aspx

I put the GdiplusStartup in On_kInitAppMsg  and  GdiplusShutdown in On_kUnloadAppMsg, to force the black background I added these lines to the DrawItem() method;

Code: [Select]
SolidBrush brush(Color(255,0,0,0));
m_graphics->FillRectangle(&brush,destRect);

and here is the result



pkohut

  • Guest
Re: MFC to view WMF files
« Reply #1 on: March 23, 2009, 03:54:09 AM »
Nice Daniel.  Without looking it up, are not twip sizes different in CImage and CStatic?

Are the dialog data entry why you were asking about "pragma property" the other day?
PM me, as I've been down this road in C++, though not using pragma property.

Are you using Vista, or a C++ MFC GUI framework API? (Can't tell from the screen shot)

TIA,
Paul

pkohut

  • Guest
Re: MFC to view WMF files
« Reply #2 on: March 23, 2009, 04:02:37 AM »
ARG, twips are what 76 per inch or something like that.  What is the unit
measure in CImage and CStatic?  Then convert that to twip and scale
as needed.

Paul

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6941
  • AKA Daniel
Re: MFC to view WMF files
« Reply #3 on: March 23, 2009, 06:14:19 AM »
Nice Daniel.  Without looking it up, are not twip sizes different in CImage and CStatic?

That could have been my problem, I was trying to scale the image by converting the WMF to a Bitmap then using StretchBlt, 
I think the GdiPlus is the way to go for WMF files.

Are the dialog data entry why you were asking about "pragma property" the other day?
PM me, as I've been down this road in C++, though not using pragma property.

No the properties were for something else, My thought is that this dialog with be populated by and external source (maybe a database) 
then all my other objects can pull from the updated data. Iíll probably use a std::map to store the parameters.
I had prototyped my app in C# but I didnít like the way my forms/AutoCAD would sometimes loose focus during GetXXX operations.
I thought I might try out MFC

Are you using Vista, or a C++ MFC GUI framework API? (Can't tell from the screen shot)

Iím just using XP, MFC,and the ARX CAcUi classes, I figure I need to start with the simple stuff first.