Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a C++ Expert!

Join 244,297 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 849 people online right now. Registration is fast and FREE... Join Now!




File works in console app, not WinForm app

 
Reply to this topicStart new topic

File works in console app, not WinForm app

logBase2
28 Dec, 2008 - 01:53 PM
Post #1

New D.I.C Head
*

Joined: 27 Dec, 2008
Posts: 5

Hi,
Sorry to post so soon again, but this is driving me nuts crazy.gif . I have a few third party CPP files (and headers) which work fine when I create a console application. However, I now want to add a basic UI to the program, so I created a new Windows Form Application. When I try and build, I get two errors in the third party CPP file regarding file conversions (error C2664). Is there something I should watch out for in WinForm applications, as the CPP files work fine in my console app?
Thanks


User is offlineProfile CardPM
+Quote Post


bodom658
RE: File Works In Console App, Not WinForm App
28 Dec, 2008 - 02:42 PM
Post #2

D.I.C Addict
Group Icon

Joined: 22 Feb, 2008
Posts: 670



Thanked: 30 times
Dream Kudos: 300
My Contributions
can you specify the errors?
User is offlineProfile CardPM
+Quote Post

logBase2
RE: File Works In Console App, Not WinForm App
28 Dec, 2008 - 03:10 PM
Post #3

New D.I.C Head
*

Joined: 27 Dec, 2008
Posts: 5

Hi.
The two errors are:

Error 38 error C2664: 'XML_SetElementHandler' : cannot convert parameter 2 from 'void (__clrcall *)(void *,const XML_Char *,const XML_Char **)' to 'XML_StartElementHandler'

Error 39 error C2664: 'XML_SetCharacterDataHandler' : cannot convert parameter 2 from 'void (__clrcall *)(void *,const XML_Char *,int)' to 'XML_CharacterDataHandler'


User is offlineProfile CardPM
+Quote Post

badjava
RE: File Works In Console App, Not WinForm App
28 Dec, 2008 - 04:38 PM
Post #4

D.I.C Regular
Group Icon

Joined: 29 Oct, 2008
Posts: 482



Thanked: 7 times
Dream Kudos: 25
My Contributions
QUOTE(logBase2 @ 28 Dec, 2008 - 03:10 PM) *

Hi.
The two errors are:

Error 38 error C2664: 'XML_SetElementHandler' : cannot convert parameter 2 from 'void (__clrcall *)(void *,const XML_Char *,const XML_Char **)' to 'XML_StartElementHandler'

Error 39 error C2664: 'XML_SetCharacterDataHandler' : cannot convert parameter 2 from 'void (__clrcall *)(void *,const XML_Char *,int)' to 'XML_CharacterDataHandler'


I'm getting my nerve up to convert one of my console apps over to a gui style also (finishing up the console version menu right now) so I'm interested to see what you find out on this.

There are probably a lot of people in the same place (IE every student making console apps in class) who could learn from your experience.

It would be great to see a post on what things you already knew about and fixed up on your own to get your conversion working along with these and any other errors you run in to.

Heck you could make it in to a tutorial, converting your first console to gui application, and upload it for some kudos smile.gif

I know I would like to see it.

This post has been edited by badjava: 28 Dec, 2008 - 04:39 PM
User is offlineProfile CardPM
+Quote Post

JackOfAllTrades
RE: File Works In Console App, Not WinForm App
28 Dec, 2008 - 04:47 PM
Post #5

Cantankerous Old Fart
Group Icon

Joined: 23 Aug, 2008
Posts: 3,055



Thanked: 270 times
Dream Kudos: 50
Expert In: Nothing. Well, nothing relevant here anyway. ;)

My Contributions
I'm going to guess that the console application was *NOT* a Managed C++/CLI .NET application, and of course the Windows Forms app is. .NET has its own XML parsing libraries in the System.Xml namespace which may be a better idea, but if you're intent on using expat (which is what it looks like you are using), can you show us how you're calling these functions?

I believe the problem will come down the need to declare the functions you are passing to expat as handlers will need to be unmanaged. Unfortunately, I've never used C++/CLI, so I'm of little further help.

User is offlineProfile CardPM
+Quote Post

logBase2
RE: File Works In Console App, Not WinForm App
29 Dec, 2008 - 08:28 AM
Post #6

New D.I.C Head
*

Joined: 27 Dec, 2008
Posts: 5

It completely slipped my mind that WinForm is .NET based and the third party library is unmanaged. I'll use MFC instead to create the GUI just for consistency.

QUOTE
I'm getting my nerve up to convert one of my console apps over to a gui style also (finishing up the console version menu right now) so I'm interested to see what you find out on this.

There are probably a lot of people in the same place (IE every student making console apps in class) who could learn from your experience.

It would be great to see a post on what things you already knew about and fixed up on your own to get your conversion working along with these and any other errors you run in to.

Heck you could make it in to a tutorial, converting your first console to gui application, and upload it for some kudos

I know I would like to see it.


I'd love to make a tutorial but it wouldn't be the same regarding this problem. As I'll be using MFC to create the GUI, it'll be a bit more complicated than WinForms. I'd rather use WinForms for ease, but the mixture of unmanaged and managed code on such a basic application isn't worth the hassle. If you need help with your conversion, feel free to message me.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic

Time is now: 7/4/09 04:45PM

Live C++ Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month