sending CString to CStatic label control from worker thread
I need to send a CString from a thread to a static label on the main
dialog form. I think I have the thread working okay, but I am unsure
how to send the CString to the dialog control. I have seen information
on using PostMessage and SendMessage, but I don't really understand how
to use these functions.
Obviously I can't do like I tried below and I can't get a pointer to the
control from the thread function, so just how do I say send the word
"hello" to the SetWindowText() function of the label control on the
dialog form. I have looked on the Internet and in se...CString
How can I covert argv to LPCSTR?
Shouldn't CString(argv) do the trick?
[ Verhagen@nonono.Sander.com ]
"Oliver Young" <firstname.lastname@example.org> wrote in message
> How can I covert argv to LPCSTR?
> Shouldn't CString(argv) do the trick?
OK. And how can I convert CString into LPCSTR? I need LPCSTR.
I need to convert from char** ( argv ) into LPCSTR. Please, forget CString, and MFC if possible.
> How can I covert argv to LPCSTR?
LPCSTR...std::string vs Cstring
I have recently been encouraged to utilise String classes, as opposed to C
type char arrays due to some difficulty debugging some buffer overflows.
I have looked into std::string and CString, but what are the benefits and
The main problem I have is that I do a lot of data formatting using sprintf,
for which I see no substitute using std::string,
On Thu, 30 Dec 2004 23:25:21 -0000, "Mark Randall"
>I have recently been encouraged to utilise String classes, as opposed to C
>type cha...CString (again)
I have a class:
BOOL CalcArea(double * pArea);
Now when I go like this:
TestClass * pNew = new TestClass;
pNew->Name = "anything in here will cause an error";
At runtime i get an unhandled exception which is comign from
How do i fix this?
Can't seem to reproduce this ...How to covert CString to TCHAR and CString to LPCWSTR?
How to covert CString to TCHAR and CString to LPCWSTR?
Where can I read about this?
See my essay on CStrings on my MVP Tips site.
On Mon, 30 Jun 2003 04:33:56 -0700, "julych" <email@example.com> wrote:
>How to covert CString to TCHAR and CString to LPCWSTR?
>Where can I read about this?
Joseph M. Newcomer [MVP]
MVP Tips: http://www.flounder.com/mvp_tips.htm
...How to convert a BSTR to CString ??
I'm sure I'm missing something easy but..... How does one convert a BSTR
to a CString? More specifically, I am processing the returned VARIANT value
from an ActiveX control and it's value is a BSTR that I would like to move
to a CString. Thanks in advance for your help.
szValue = (LPCWSTR)bstrValue;
Bob Curry wrote:
> I'm sure I'm missing something easy but..... How does one convert a BSTR
> to a CString? More specifically, I am processing the returned VARIANT value
> from an ActiveX control and it...CString...
What is the maximum characters a CString variable can hold? Is there anyway
to increase a CString variables capacity to hold more characters?
As all index and length parameters are int variables, and there is no
checking on assignment, the limit would be 2147483647 on a 32bit machine. If
that's not big enough, rethink what you're doing.
"RBert" <firstname.lastname@example.org> wrote in message
> What is the maximum characters a CString variable can hold? Is there
> to increase a CString va...CString in DLL
When I try to use CString in an MFC DLL, it gives the following error:
error LNK2019: unresolved external symbol "public: __thiscall
CString::~CString(void)" (??1CString@@QAE@XZ) referenced in function
"public: virtual int __thiscall CMfcDllApp::InitInstance(void)"
How can I use CString?
Forgot to mention that the Env used is VC++ .NET
"ajd" <email@example.com> wrote in message
> When I try to use CString in an MFC DLL, it gives the following error:
> error L...Array of CString s vs. CString Array
What's the deal with CStringArray? I have used CStringArray in several
places but now I'm wondering why can't I use an array of CStrings instead
- at least I wouldn't have to bother with SetSize().
You can use whatever you like. CStringArray has been part of MFC before
vector other STL collection became a part of C++. I'd use vector<CString>.
Ajay Kalra [MVP - VC++]
"Richard C" <firstname.lastname@example.org> wrote in message
> Hi all
> What&...Are there any function like ReplaceNoCase for CString?
I can only find CString::Replace, but I need a function like
You are correct. Replace is case sensitive. You could convert the string
to all upper or lower case first, but then your resulting string would be
changed as well. You could also derive your own class from CString and add
the new functionality to it.
<email@example.com> wrote in message
>I can only find CString::Replace, but I need a function like
...Issue with casting CString to LPARAM and recasting it to CString...
I have developed a custom control with some customizations of the
List Control class of MFC (CListCtrl). I have another custom class
(MyItem) which is inherited from CItem. Each and every entry in the
list control is a MyItem.
Every time a new item is added into the LIst control we use the logic
of maintaining a unique sequence number which is a CString and member
of MyItem class. Here goes the implementation of the 2 main members of
void MyItem::SetListItemSequence(const CString& seq)
m_sequence = seq;
This member sets the newly added entries sequence value into ...CString ?
One mine user reported strange error using my DLL. After analizing, the
only way error could be mine is if this peace of code is wrong:
hr = pMyCOMObj->get_someProperty(&p1);
prop.someProperty = (LPCSTR)cP1;
This peace of code is inside of my COM object. "prop" is C-type
structure. "someProperty" is "const char*". I'm not working with very long
The CString cP1 seems to be a temporary stack object that'll get destroyed
when it goes out of scope thereby rendering the pointer passed to
prop.someProp...CString to std::string
How to convert from CString to stl string?
I tried many things and doesn't work.
CString Temp = "This is a test";
string Str = (LPCSTR)Temp;
"Derek" <firstname.lastname@example.org> wrote in message
> How to convert from CString to stl string?
> I tried many things and doesn't work.
that I tried, doesn't work.
"AliR" <AliR@online.nospam> wrote in message
> CString Temp = "This is a t...inherit from CString
I'd like to make a new class that inherits from CString and adds a few new
string manipulation functions as well as some other member variables. For
constructors, I'd like to simply use the CString constructors and add only
my initialization values for my new member variables. Considering that
there are multiple constructors for CString, what is an easy way to do this?
(I'm a VC++ hobbyist, not a pro). I'd like to avoid having to write
separate constructors to match each of the ones for CString.
Remove Xs from address to reply via e-mail.
Matt Roos wrot...Throw Exception from a dll
Hi, I have got a problem then throwing exception from a
dll and catch it in the exe.
It is work to catch the object but then it leave the
catch area and the object it being destroyed the program
crach. What I have understood is that a dll and exe have
different heaps and that is the problem.
Can someone help me? How can a throw exception from a dll
to the exe?
Most likely you are using static linking in one or both of the components. Do not use
static linking. Then you will have one heap.
On Wed, 5 Nov 2003 00:47:55 -0800, <email@example.com> wrote:
>Hi, I h...CString hex value to CString decimal value
Please bare with me, I am quite new to C++.
A CString contains a (large) hexadecimal string value,
this value needs to be converted to an decimal value,
and then put back as a string into an other CString.
Data example: hexadecimal: 93d2f666 = decimal 2480076390
I have googled and found a lot of solutions (hex string to int)
but none of them returns the correct decimal value, I suspect
that converting a large hex string to int does not work.
So if someone could point me to the right direction or
could suply a working sample, please do.
Your not looking hard enough.
I would like to replace \r\n, \n\r or \n by a <BR> in a CString.
I have some methode to do it but they are not optimized.
I am starting with that :
for (int i = 0; i < strHtml.GetLength(); i++)
if (strHtml.GetAt(i) == '\r')
if (strHtml.GetAt(i + 1) == '\n')
strHtml = strHtml.Mid(i, 2);
else if (strHtml.GetAt(i) == '\n')
if (strHtml.GetAt(i + 1) == '\r')
strHtml = strHtml.Mid(i, 2);
I have traced one of my problems to running my dll in release
mode and the exe in debug mode and calling a function in
the exe from the dll that copies (I thought) a CString into an
array of CStrings in the exe. The problem occors when the exe releases the
dll and later deletes the array. The CString data is not really copied as I
thought but only the pointer to the original CString is saved in the new one
and so the heap
pointer is wrong when it is time to delete the second CString.
So, how do I prevent this problem?
>I have traced one of my problems to running my dll in r...Unable to convert from ATL::CString to vector<CString>::iterator
I am going through the lengthy process of upgrading from a VS6 project to
The only issue I am left with is that I cannot work how to convert from a
CString as part of an array to a vector iterator.
The code is as follows
vector<CString>::iterator ii =
and the error message is as follows
error C2440: 'initializing' : cannot convert from
'ATL::CStringT<BaseType,StringTraits> *' to
Can anyone help at all?
&...Is there a method in CString equivalent to std::string::replace?
How can I replace a substring in a CString? Isn't there an equvalent
CString method? For example I can write:
s.replace(s.begin()+8, s.end(), "*.*", 3);
After replacing 's' contains "C:\Temp\*.*";
How to implement this using 'CString'?
Thanks in advance
No, 'CStringT::Replace' does quite a different thing:
A snip from MSDN:
This function replaces instances of the specified character or
how can i get first 4 letter of str?
is there any function to get it?
sorry i am new in visual c++ field,
> CString str;
> str="hello wolrd";
> how can i get first 4 letter of str?
> is there any function to get it?
> sorry i am new in visual c++ field,
You should be able to find this in the Help. If you know the name of the
class, just look at the members (for CString in VS2002 and up you
actually have to look...string (clr) and CString (MFC) in same class
Is there any way to use both string (system.string) and CString in the same
are you talking about System.String (as in .Net frameworks) or std::string?
"Tony H" <TonyH@discussions.microsoft.com> wrote in message
> Is there any way to use both string (system.string) and CString in the
> Tony H
System::String, I think.
I have to interface with a VB class in the same project which uses
> are you tal...'CMap' of 'CString' to 'CString'
I'm trying to create a dictionary with both key and value of type
'CString'. I declare the object of 'CMap' so it is as closer to
std::map, as possible:
CMap<CString, const CString&, CString, const CString&> m_appLangs;
and semantically it's like this:
std::map<std::string, std::string> m_appLangs;
But it seems 'CMap' is not realized as an RB-tree, I guess it must be
realized through hash table. The problem is when I make the above
declaration, my source file refuse to compile. Here is the simplified
cannot convert...Is this a known issue? Call GetBuffer on CString, pass CString to a method prior to releasing the buffer...
....and you can't copy the CString in the called method (it copes nothing)?
I have a method where I use a CString in place of a char buffer via
CString::GetBuffer(4096) and if I pass it to my "log this value" method
prior to calling CString::ReleaseBuffer() my logging method gets an empty
string when adding CString together like this:
l_csLog += in_csString;
If I break in the called logging method, in_csString has the correct value
in the watch window(s), but l_csLog always equals whatever it was before the
Now, if I call CString::ReleaseBuffer prior to th...new XmlDataDocument(DataSet) throws exception
if i try to synchronize a dataset with xml using
XmlDataDocument dataDoc = new XmlDataDocument(dataSetName)
it throws an exception saying
Object reference not set to an instance of the object.
my dataset has 4 tables not related to each other in any way.