This works fine if there is a date in the textbox, but if the textbox is
empty or null, I get an error. This is part of an SQL statement. What can
I do if it's Null so that it still works.
Change you line to
This will return a zero legnth string instead of a null value, and will
allow your code to process it.
Note that if at any point you are comparing that field to Null, it will
fail, and you will have to compar...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...OnCtlColorDlg & return NULL
The MS documentation about WM_CTLCOLORDLG says:
"If an application processes this message, it must return the handle of
a brush. The system uses the brush to paint the background of the
The documentation about "CWnd::OnCtlColor" says something quite
similar. But then when the wizzard generates OnCtlColor the included
"TODO: Return a different brush if the default is not desired".
Now I wonder if really a brush MUST(!) be returned. Returning NULL
works. Nevertheless, that doesn't mean it's valid to do so.
Finally, if I can re...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
...Using Multislect on feilsd with null value
I have a query that gets its criteria from a form with 4 multiselct list boxs.
The problem i have is that some of the freilds can have null value. The
fields that I am using are [Site id], [Primary function], Secondary_function],
and [tertiarty fuctin] teh Second and Ter funcs may have null value, when you
select multi feilds and multiple items teh query doe snot produce the desired
results. exmaple, if you select a specfic location, and gyms in the primary
fuction and run the query, you do not get all of tthe areas that are
classified as gym, there are 5 entries and 3 have not secondary ot te...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...Null Field to Interupt Closing
I am using this code to check for blank fields in BeforeUpdate:
If NZ(Trim(Me!Date),vbnullstring) = vbnullstring then
Msgbox "PLEASE ENTER DATE",,"Missing date"
Cancel = True
It almost works, except the form goes ahead and closes anyway. The user
clicks the close button and the message box pops up if the field is empty,
they click OK and instead of keeping the form open and then setting focus on
the empty field, it closes the form.
How can I get it to interupt the close and keep the form open?
Thank you in advance for any...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...Set focus to a control if it's null
I have a form where there are two controls I want users to fill in but don't
want to set the property to required. I want the form to not be able to
close if they haven't filled in these two fields and if they tab past the
field, it should give you a message box saying you must fill something in and
stay in that control until something is chosen from the drop down boxes. The
set focus and docmd.gotocontrol are not really working, they can still close
the form and tab past that control.
Use the BeforeUpdate event procedure of the *form* (not the control's
events) to test i...Anyone suggest why FindWindow returns NULL in release build?
I'm running a service and send information to an application via a
HWND hWnd = FindWindow(NULL, "ServiceManager");
only FindWindow returns NULL in Release mode.
ah hah... in the Services administrator make sure 'Allow Service To
Interact With Desktop' is ticked.
I have a database that list clients...I want to create a report that is only
open clients and excludes closed clients. I created a query on which to base
the report but I cannot seem to eliminate the clients that have been closed.
>I have a database that list clients...I want to create a report that is only
>open clients and excludes closed clients. I created a query on which to base
>the report but I cannot seem to eliminate the clients that have been closed.
Post back with a Copy/Paste of your query's SQL view along
with an explanation...Null value syntax of export XML
I use excel 2003 to export a excel file into xml file. For those blank
cells in the excel file, I input a ' so that excel can recognize it as a null
value when exporting to xml. After exporting, the syntax of null value in
the xml file will look liked
However, I expect the syntax of null value will look liked
Everytime I will use Notepad to modify the syntax. May I ask whether there
is any method to modify the xml output syntax?
...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&...Replace null string with blank cell
I have a large table which was created via lookups from other tables.
Many of the entries are (or should be) blank. After the table was
created, I converted everything to values (Paste Special/Values) in
order to save memory. However, the table now contains a null string or
other unprintable character in each of the "blank" cells. Thus, if I
use END-DN or END-UP to find the next value in the table, the cursor
goes to the end of the table, as it sees something in each cell. If I
edit a "Blank" cell, I see no characters, and if I select the formula
bar & hit ENTER, ...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...Query will not open in Design Mode
I've created the following query from two tables:
SELECT tblTrnsctn.TxnDate, tblTrnsctn.Amount, tblCoa.AcntNmbr,
tblCoa.AcntDscriptn, tblCoa.LeadSheet, tblCoa.qbListID
FROM tblTrnsctn LEFT JOIN tblCoa ON tblTrnsctn.AccountRefListID =
This query seems to run fine, but once I save the query, I no longer
can open the query in Design Mode to edit - I can view in sql mode. I
modified the above query to return records that do not contain any
null values in any fields.
When I try to view the query in Design Mode - 'Invalid use of Null'
error message is ret...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...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.