How to use GDI+ in an ActiveX Control? [modified]
-
I wrote an ActiveX control. At first there was no GDI+ code in it and it worked well. Then I added follow code: class ATL_NO_VTABLE MyControl: public ......... { ... BOOL OpenImageFile(BSTR FilePath) // added a method { USES_CONVERSION; m_pBitmap = Bitmap::FromFile(FilePath); return m_pBitmap!=NULL; } Bitmap *m_pBitmap; // added a point } After I added a point and a method, MyControl was no long created successfully. I searched in www.codeproject.com and finded Ryan Johnston's article----http://www.codeproject.com/KB/GDI-plus/gdipluscontrol.aspx, I read the article and thought it would resolve my problem, en..., it didn't. It's very strange that after I remove my method, MyControl can be created, but if I add "static InitGDIPlus GDI_Plus_Controler;" in MyControl.cpp, MyControl can not be created again. I have not call the object's method yet, only declare a static global. Why this declaration make MyControl create failed? I hope someone can help me resolving this problem. Suggestion, article, code example, anything may be helpful is appreciated, thank you. :confused: My System: Windows 2000 Server, VC6(ATL3.0), Windows Server 2003 SP1 SDK
modified on Tuesday, March 18, 2008 11:06 AM
-
I wrote an ActiveX control. At first there was no GDI+ code in it and it worked well. Then I added follow code: class ATL_NO_VTABLE MyControl: public ......... { ... BOOL OpenImageFile(BSTR FilePath) // added a method { USES_CONVERSION; m_pBitmap = Bitmap::FromFile(FilePath); return m_pBitmap!=NULL; } Bitmap *m_pBitmap; // added a point } After I added a point and a method, MyControl was no long created successfully. I searched in www.codeproject.com and finded Ryan Johnston's article----http://www.codeproject.com/KB/GDI-plus/gdipluscontrol.aspx, I read the article and thought it would resolve my problem, en..., it didn't. It's very strange that after I remove my method, MyControl can be created, but if I add "static InitGDIPlus GDI_Plus_Controler;" in MyControl.cpp, MyControl can not be created again. I have not call the object's method yet, only declare a static global. Why this declaration make MyControl create failed? I hope someone can help me resolving this problem. Suggestion, article, code example, anything may be helpful is appreciated, thank you. :confused: My System: Windows 2000 Server, VC6(ATL3.0), Windows Server 2003 SP1 SDK
modified on Tuesday, March 18, 2008 11:06 AM
-
I wrote an ActiveX control. At first there was no GDI+ code in it and it worked well. Then I added follow code: class ATL_NO_VTABLE MyControl: public ......... { ... BOOL OpenImageFile(BSTR FilePath) // added a method { USES_CONVERSION; m_pBitmap = Bitmap::FromFile(FilePath); return m_pBitmap!=NULL; } Bitmap *m_pBitmap; // added a point } After I added a point and a method, MyControl was no long created successfully. I searched in www.codeproject.com and finded Ryan Johnston's article----http://www.codeproject.com/KB/GDI-plus/gdipluscontrol.aspx, I read the article and thought it would resolve my problem, en..., it didn't. It's very strange that after I remove my method, MyControl can be created, but if I add "static InitGDIPlus GDI_Plus_Controler;" in MyControl.cpp, MyControl can not be created again. I have not call the object's method yet, only declare a static global. Why this declaration make MyControl create failed? I hope someone can help me resolving this problem. Suggestion, article, code example, anything may be helpful is appreciated, thank you. :confused: My System: Windows 2000 Server, VC6(ATL3.0), Windows Server 2003 SP1 SDK
modified on Tuesday, March 18, 2008 11:06 AM
Sounds like you're missing gdiplus.dll. That didn't come with Win 2K.
--Mike-- Visual C++ MVP :cool: LINKS~! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ "That's what's great about doing user interface work. No matter what you do, people will say that what you did was idiotic." -- Raymond Chen