Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2005

Tip: Looking for answers? Try searching our database.

Problem porting V6 C++ Project to .NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rob C - 05 Nov 2003 18:28 GMT
I am rebuilding a VC++ w/ MFC Project from Visual Studio
V6 in Visual Studio .NET 2003.

There are 2 errors that I am getting that I do not get
when I build using V6.

1) problem with my declaration of a static fuction.

I have a static function called GetDocID() that returns a
CString.

in my .h file it is declared:

static CString GetDocID()  { return _T("10010"); }

in the .CPP file, I have declared at the top of the file:

CString CCMSMDSAssessmentMgr::GetDocID();

The error message I am getting is:

"Member Function redeclaration not allowed"

Why was the syntax OK in VS V6 but not in VS .NET?  What
is the proper syntax for declaring a member function as
static?

2) GetDefaultPrinter "Identifier Not Found"

I use the SDK function GetDefaultPrinter &
SetDefaultPrinter.  I am assuming that I have the right
version of the SDK

installed because this builds OK with VC++ V6.  Any ideas
what I need to do here?

Thanks for your help.

Regards,

-Rob
Hendrik Schober - 06 Nov 2003 18:02 GMT
> [...]
> in my .h file it is declared:
[quoted text clipped - 4 lines]
>
> CString CCMSMDSAssessmentMgr::GetDocID();

 Why? I have never seen this.

> The error message I am getting is:
>
> "Member Function redeclaration not allowed"

 Fine. The compiler catches this error.

> Why was the syntax OK in VS V6 but not in VS .NET?

 I dunno why was it allowed in VC6. Maybe
 a bug? I don't think it's std conform to
 declare a class member like this, so I'm
 fine with the new compiler disallowing it.
 (Meybe you confuse this with the need to
 _define_ static data members?)

>                                                     What
> is the proper syntax for declaring a member function as
> static?

 As you did:
   static CString GetDocID();

> 2) GetDefaultPrinter "Identifier Not Found"
>
[quoted text clipped - 4 lines]
> installed because this builds OK with VC++ V6.  Any ideas
> what I need to do here?

 My browser finds it in "winspool.h", the
 help says "Declared in Winspool.h; include
 Windows.h".

> Thanks for your help.

 HTH!

> Regards,
>
> -Rob

 Schobi

Signature

SpamTrap@gmx.de is never read
I'm Schobi at suespammers org

"And why should I know better by now/When I'm old enough not to?"
 Beth Orton

Rob C - 09 Nov 2003 03:57 GMT
Thanks for your help.  I'm not sure why I declared the
static functions that way in the first place.  I just
remember having all sorts of compile errors when I first
tried it and that seemed to get rid of them.  I must have
changed 2 things at the same time and thought that I
needed to redeclare the static in teh CPP file.  Oh well.

I also did an include of winspool.h and then it complied.  
I still find it odd hat I did not have to do this when
building under VC V6.

Regards,

-Rob

>-----Original Message-----
>> [...]
[quoted text clipped - 52 lines]
>
>  Schobi
Hendrik Schober - 10 Nov 2003 11:45 GMT
> [...]
> I also did an include of winspool.h and then it complied.

 As I quoted, <windows.h> would be the
 file you should have to include.

> I still find it odd hat I did not have to do this when
> building under VC V6.

 Probably one of the std lib headers
 pulled <windows.h> in, already.

> Regards,
>
> -Rob
> [...]

 Schobi

Signature

SpamTrap@gmx.de is never read
I'm Schobi at suespammers org

"And why should I know better by now/When I'm old enough not to?"
 Beth Orton

Arvind Kumar Sharda - 06 May 2005 12:30 GMT
Hi..

In VC6 code will be working fine bcz it will not bother about int and
CString ..like as i m looking into ur code

static CString GetDocID()
{
 return _T("10010");
}

But it will give problem in VC7 bcz in .Net when we are passing INT/LONG in
place of CString Parameters .We are passing a number for a CString.  but
there is no LPCTSTR conversion to CString. So it is giving problem .

For Example

#define something 10
...
F  myInstance;
//We are passing a number for a CString.  This isn't valid in VC++ 7 as
there is no LPCTSTR conversion to CString.
myInstance.foo(something);

class F
{
    void foo(CString a_sFoo)
    {
        //In most cases a_sFoo ends up as "" or some other corrupted string
        AfxMessageBox(a_sFoo);
    }
};

I think it will resolve ur problem

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.