Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
|
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 14th, 2007, 09:56 AM
Authorized User
 
Join Date: Jan 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to arun.sharma.kumar
Default convert wchar* to cstring

Pls can any one guide me how to convert WCHAR* to CString

Arun Kumar.
Size the day put no efforts on the morrow!
__________________
Arun Kumar.
Size the day put no efforts on the morrow!
 
Old February 15th, 2007, 02:44 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

#include <AFXPRIV.H>

.
.
.

    USES_CONVERSION;
    WCHAR szSize[MAX_PATH];
    wcscpy(szSize,L"adsfasfasdfasf");
        .
        .
        .
        CString ss(W2A(szSize));
    AfxMessageBox(ss);

How is that ? ;)

Regards
Ankur
 
Old February 16th, 2007, 02:10 AM
Authorized User
 
Join Date: Jan 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to arun.sharma.kumar
Default

thanks a lot ! Ankur .... for giving the simplest way.... and thanks for p2p...

Arun..

Quote:
quote:Originally posted by Ankur_Verma
 #include <AFXPRIV.H>

.
.
.

    USES_CONVERSION;
    WCHAR szSize[MAX_PATH];
    wcscpy(szSize,L"adsfasfasdfasf");
        .
        .
        .
        CString ss(W2A(szSize));
    AfxMessageBox(ss);

How is that ? ;)

Regards
Ankur
 
Old February 16th, 2007, 02:15 AM
Authorized User
 
Join Date: Jan 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to arun.sharma.kumar
Default

is there any simple ways like this to convert CString to wchar*... ? i mean visaversa... pls let me know..

Arun Kumar.
Size the day put no efforts on the morrow!
 
Old February 16th, 2007, 02:50 AM
Authorized User
 
Join Date: Jan 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to arun.sharma.kumar
Default

sorry and thanks i got the VV way to convert...

Arun
 
Old February 17th, 2007, 07:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

So you did ;)
 
Old February 19th, 2007, 03:34 AM
Authorized User
 
Join Date: Jan 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to arun.sharma.kumar
Default

ya i did VV using Multibytetowidechar function...
as given below

m_val1 is the textbox variable of type cstring

        PWSTR wstr;
    char *aa;
    int count = 0;
    aa = (char *)(LPCTSTR)(LPCSTR)M_Val1;
    count = MultiByteToWideChar (CP_ACP,0,aa,strlen(aa),NULL,0);
    if ( count > 0 )
    {
        wstr = SysAllocStringLen(0,count);
        count = MultiByteToWideChar (CP_ACP, 0, aa, strlen(aa),wstr,count);
    }

but is there any simpler way like which u gave for the above...
 
Old February 20th, 2007, 01:15 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Did you try

A2W()


Regards
Ankur
 
Old February 20th, 2007, 01:52 AM
Authorized User
 
Join Date: Jan 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to arun.sharma.kumar
Default

Oh! thanks a lot... again...!


Regards
Arun





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to convert ???? bobolov Classic ASP Basics 2 June 15th, 2006 12:58 PM
Where is CString?? samehkh Visual C++ 1 April 11th, 2006 10:19 PM
Converting from managed String to MFC CString neethling Visual C++ 0 October 28th, 2004 10:20 AM
CONVERT Adam H-W SQL Server ASP 5 September 24th, 2004 10:53 AM
convert ngang SQL Language 1 November 21st, 2003 05:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.