GIDForums  

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 03-Nov-2007, 19:20
parsemesa parsemesa is offline
New Member
 
Join Date: Nov 2007
Posts: 1
parsemesa is on a distinguished road

Cannot convert 'AnsiString' to 'const char *'


I am writing a browser program in C++ Builder 6 that loads a web page using the following code:

CPP / C++ / C Code:
void __fastcall TForm1::ToolButton1Click(TObject *Sender)
{
     wchar_t buff[100];
     MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
     "http://www.gidforums.com", -1, buff, sizeof(buff));
     CppWebBrowser1->Navigate(buff, 0, 0, 0, 0);
}
To include the address bar implementation, I need a temporary string derived from an edit box. This is the code I have tried but receive the error that I cannot convert an AnsiString to const char * and require a type conversion:

CPP / C++ / C Code:
void __fastcall TForm1::ToolButton1Click(TObject *Sender)
{
     const char *tempstring = Edit1->Text;
     wchar_t buff[100];
     MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
     tempstring, -1, buff, sizeof(buff));
     CppWebBrowser1->Navigate(buff, 0, 0, 0, 0);
}
void __fastcall TForm1::ToolButton1Click(TObject *Sender)I've tried to decipher how the TStringConverter VCL class works but I have been unsuccesful determining how it works either:

TStringConverter::AnsiToWide

Converts a null-terminated ANSI string to a wide (Unicode) string.
static LPWSTR AnsiToWide(LPCSTR src);

WideToAnsi calls MultiByteToWideChar(), using the ANSI code page, to convert the ANSI string specified by src to a null-terminated string of Unicode characters. The source string may be from a multibyte character set.

Thanks in advance for suggestions anyone might have as to how I can resolve this programming obstacle.
Last edited by LuciWiz : 04-Nov-2007 at 14:18. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
 
 

Recent GIDBlogLast Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Classes and allocating memory BlueFireCO. CPP / C++ Forum 13 26-Jul-2007 20:31
Pointer initialization causing program abend? emanresu C Programming Language 0 12-Dec-2006 10:36
Handling keyup events. harroldm FLTK Forum 3 24-Aug-2006 08:48
need help with a console menu system BullBuchanan CPP / C++ Forum 6 20-Aug-2006 14:46
help me to do this program!!! mrdell_06 CPP / C++ Forum 3 21-Feb-2006 21:12

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 22:38.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.