Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 14th, 2007, 09:56 AM
Authorized User
 
Join Date: Jan 2007
Location: Bangalore working in chennai.., Karnataka, India.
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!
Reply With Quote
  #2 (permalink)  
Old February 15th, 2007, 02:44 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
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
Reply With Quote
  #3 (permalink)  
Old February 16th, 2007, 02:10 AM
Authorized User
 
Join Date: Jan 2007
Location: Bangalore working in chennai.., Karnataka, India.
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
Reply With Quote
  #4 (permalink)  
Old February 16th, 2007, 02:15 AM
Authorized User
 
Join Date: Jan 2007
Location: Bangalore working in chennai.., Karnataka, India.
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!
Reply With Quote
  #5 (permalink)  
Old February 16th, 2007, 02:50 AM
Authorized User
 
Join Date: Jan 2007
Location: Bangalore working in chennai.., Karnataka, India.
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
Reply With Quote
  #6 (permalink)  
Old February 17th, 2007, 07:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
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 ;)
Reply With Quote
  #7 (permalink)  
Old February 19th, 2007, 03:34 AM
Authorized User
 
Join Date: Jan 2007
Location: Bangalore working in chennai.., Karnataka, India.
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...
Reply With Quote
  #8 (permalink)  
Old February 20th, 2007, 01:15 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
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
Reply With Quote
  #9 (permalink)  
Old February 20th, 2007, 01:52 AM
Authorized User
 
Join Date: Jan 2007
Location: Bangalore working in chennai.., Karnataka, India.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:33 PM.


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