CString help

I'm looking at a website on CString Management:

http://www.codeproject.com:80/string/cstringmgmt.asp

In the section entitled, "CString to char * II: Using GetBuffer," the author 
stresses calling ReleaseBuffer after calling GetBuffer.

Is this always necessary?

I often use CString::GetBuffer when using CStrings in MessageBox dialogs 
like so:

MessageBox(m_hWnd, cString.GetBuffer(0), lpTitle, MB_OK);

Should I be adding a ReleaseBuffer after a MessageBox call?

Should I be passing my string data to the MessageBox in another way?

Regards,
Joe 


0
jp2code
6/21/2007 7:17:04 PM
vc.mfc 33608 articles. 0 followers. Follow

38 Replies
2093 Views

Similar Articles

[PageSpeed] 51

> Is this always necessary?
>
> I often use CString::GetBuffer when using CStrings in MessageBox dialogs
> like so:
>
> MessageBox(m_hWnd, cString.GetBuffer(0), lpTitle, MB_OK);

Why use GetBuffer here? You dont need it. Just pass the CString.
Operator LPCTSTR will take care of the rest.

Also, you must call ReleaseBuffer after calling GetBuffer:
http://msdn2.microsoft.com/en-us/library/ms928943.aspx

---
Ajay



0
ajaykalra (6842)
6/21/2007 7:25:21 PM
On Thu, 21 Jun 2007 14:17:04 -0500, "jp2code" <poojo.com/mail> wrote:

>I'm looking at a website on CString Management:
>
>http://www.codeproject.com:80/string/cstringmgmt.asp

This article is by our Joe.
I think that going to his MVP web site would be better, because I
don't know if the CodeProject version of the article is updated like
Joe's own web site version:

http://www.flounder.com/cstring.htm


>In the section entitled, "CString to char * II: Using GetBuffer," the author 
>stresses calling ReleaseBuffer after calling GetBuffer.
>
>Is this always necessary?

I think so.
MSDN seems to say the same thing:

<cite url"=http://msdn2.microsoft.com/en-us/library/ms928943.aspx">
If you use the pointer returned by GetBuffer to change the string
contents, you must call ReleaseBuffer before using any other CString
methods.
</cite>



>I often use CString::GetBuffer when using CStrings in MessageBox dialogs 
>like so:
>
>MessageBox(m_hWnd, cString.GetBuffer(0), lpTitle, MB_OK);

In an MFC context, a simple call to 

  AfxMessageBox( cString ); 

is fine.


MrAsm
0
mrasm (715)
6/21/2007 7:31:03 PM
Wow! Thanks gang! I had 27 occurrences of "GetBuffer(0)" in my code, and not 
one call to ReleaseBuffer.

That's fixed now, though.

I have a little Borland background. There, I had to use AnsiString (like 
std::string) and I accessed the data using AnsiString::c_str(). When I first 
started using VC, GetBuffer looked like Msft's equivalent. Wrong! :)

"Ajay Kalra" wrote:
>
> Why use GetBuffer here? You dont need it. Just pass the CString.
> Operator LPCTSTR will take care of the rest.
>
> Also, you must call ReleaseBuffer after calling GetBuffer:
> http://msdn2.microsoft.com/en-us/library/ms928943.aspx
>
> ---
> Ajay
>



0
jp2code
6/21/2007 7:57:05 PM
On Jun 21, 3:57 pm, "jp2code" <poojo.com/mail> wrote:
> Wow! Thanks gang! I had 27 occurrences of "GetBuffer(0)" in my code, and not
> one call to ReleaseBuffer.
>

Hopefully you are not using GetBuffer/ReleaseBuffer in MessageBox.

---
Ajay

0
ajaykalra (6842)
6/21/2007 8:03:09 PM
No, I'm not. I just deleted all of those. :)

Apparently, I have no need to call GetBuffer!

>
> Hopefully you are not using GetBuffer/ReleaseBuffer in MessageBox.
>
> ---
> Ajay
> 


0
jp2code
6/21/2007 8:08:34 PM
On Thu, 21 Jun 2007 15:08:34 -0500, "jp2code" <poojo.com/mail> wrote:

>Apparently, I have no need to call GetBuffer!

IMHO, it is very uncommon to call GetBuffer...

MrAsm
0
mrasm (715)
6/21/2007 8:13:27 PM
I use GetBuffer() if I need to pass a pointer to a routine that needs to 
modify the buffer (I.E., a LPTSTR).  In those cases you will need to call 
ReleaseBuffer() since the buffer may have changed.  If you are sure the 
buffer was not changed (I.E., you are just reading through it using a 
pointer) you don't need to call ReleaseBuffer().

Tom

"MrAsm" <mrasm@usa.com> wrote in message 
news:ssml73d5j1oivaf8pc94tlit6t0m1gbha6@4ax.com...
> On Thu, 21 Jun 2007 15:08:34 -0500, "jp2code" <poojo.com/mail> wrote:
>
>>Apparently, I have no need to call GetBuffer!
>
> IMHO, it is very uncommon to call GetBuffer...
>
> MrAsm 

0
tom.nospam (3240)
6/21/2007 8:49:02 PM
Hi David,

Doesn't std::string have c_str() to do something similar?  I don't use 
std::string, much, so I could be wrong on this one.

Tom

"David Wilkinson" <no-reply@effisols.com> wrote in message 
news:OTwehBEtHHA.2752@TK2MSFTNGP06.phx.gbl...
> jp2code wrote:
>> Wow! Thanks gang! I had 27 occurrences of "GetBuffer(0)" in my code, and 
>> not one call to ReleaseBuffer.
>>
>> That's fixed now, though.
>>
>> I have a little Borland background. There, I had to use AnsiString (like 
>> std::string) and I accessed the data using AnsiString::c_str(). When I 
>> first started using VC, GetBuffer looked like Msft's equivalent. Wrong! 
>> :)
>
> I don't know Borland, but I would imagine that AnsiString::c_str() returns 
> const char*. CString::GetBuffer() returns char* (in ANSI build), a string 
> whose contents you can modify.
>
> CString::GetBuffer() can increase efficiency in some situations, but is 
> best avoided, IMHO. You will notice that std::string has no such 
> mechanism.
>
> -- 
> David Wilkinson
> Visual C++ MVP 

0
tom.nospam (3240)
6/21/2007 9:02:07 PM
jp2code wrote:
> Wow! Thanks gang! I had 27 occurrences of "GetBuffer(0)" in my code, and not 
> one call to ReleaseBuffer.
> 
> That's fixed now, though.
> 
> I have a little Borland background. There, I had to use AnsiString (like 
> std::string) and I accessed the data using AnsiString::c_str(). When I first 
> started using VC, GetBuffer looked like Msft's equivalent. Wrong! :)

I don't know Borland, but I would imagine that AnsiString::c_str() 
returns const char*. CString::GetBuffer() returns char* (in ANSI build), 
a string whose contents you can modify.

CString::GetBuffer() can increase efficiency in some situations, but is 
best avoided, IMHO. You will notice that std::string has no such mechanism.

-- 
David Wilkinson
Visual C++ MVP
0
no-reply8010 (1791)
6/21/2007 9:12:05 PM
Tom Serface wrote:
> Hi David,
> 
> Doesn't std::string have c_str() to do something similar?  I don't use 
> std::string, much, so I could be wrong on this one.

Tom:

c_str() returns const char*, not char*. The buffer cannot be modified 
without using const_cast tricks which may corrupt the string.

-- 
David Wilkinson
Visual C++ MVP
0
no-reply8010 (1791)
6/21/2007 10:31:47 PM
"jp2code" <poojo.com/mail> wrote in message 
news:e1xRCjDtHHA.3732@TK2MSFTNGP02.phx.gbl...

> In the section entitled, "CString to char * II: Using GetBuffer," the 
> author stresses calling ReleaseBuffer after calling GetBuffer.

Why do you want to use GetBuffer()?

Too be sure, it is there, but in a dozen years of using CStrings I cannot 
remember ever needing it once!   CString provides copious methods for 
manipulating the string.

And it has a cast to const TCHAR * in order to send it to functions which 
just need to read the string.   The result is that you can effectively pass 
a Cstring to any function which has an argument of type LPCTSTR.  (Including 
message boxes, but many more things too.)

Using GetBuffer() tells the CString  "I am going to do something underhand 
to your contents which you can't manage for yourself, so don't try any funny 
business while I'm doing it."     [The following ReleaseBuffer() is a 
promise to the CString that you have finished buggering about with it, and 
that it has permnission to manage itself again.]

 > Is this always necessary?
>
> I often use CString::GetBuffer when using CStrings in MessageBox dialogs 
> like so:
>
> MessageBox(m_hWnd, cString.GetBuffer(0), lpTitle, MB_OK);

That is a very bad idea.

> Should I be passing my string data to the MessageBox in another way?

Yes.

    MessageBox(m_hWnd, cString, lpTitle, MB_OK);

will do just fine.   Why tell the CString you are going to mess it about, 
when all you are doing is reading it?

If you really want to keep explicit track of what you're doing, then

    MessageBox(m_hWnd, (LPCTSTR)cString, lpTitle, MB_OK);

will remind you, but an implicit cast is sufficient.

Dave
-- 
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm

0
dave9996 (486)
6/21/2007 10:51:42 PM
First, you are likely reading my essay.

So why would you need to call CString::GetBuffer in a MessageBox call?  There's no useful
purpose served by doing that.  In fact, you should be doing
	AfxMessageBox(cString, MB_OK);

Microsoft guidelines say the title should be the name of the program, so there is no
reason to use a different title.  There is no reason to use m_hWnd since there is already
a CWnd::MessageBox call, so you would write
	MessageBox(cString, lpTitle, MBOK);

So your complaint is that you are doing something unnecessary?
				joe

On Thu, 21 Jun 2007 14:17:04 -0500, "jp2code" <poojo.com/mail> wrote:

>I'm looking at a website on CString Management:
>
>http://www.codeproject.com:80/string/cstringmgmt.asp
>
>In the section entitled, "CString to char * II: Using GetBuffer," the author 
>stresses calling ReleaseBuffer after calling GetBuffer.
>
>Is this always necessary?
>
>I often use CString::GetBuffer when using CStrings in MessageBox dialogs 
>like so:
>
>MessageBox(m_hWnd, cString.GetBuffer(0), lpTitle, MB_OK);
>
>Should I be adding a ReleaseBuffer after a MessageBox call?
>
>Should I be passing my string data to the MessageBox in another way?
>
>Regards,
>Joe 
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
6/21/2007 11:12:13 PM
Ah, that makes sense thanks.  All I've ever used it for was assigning the 
string to a CString ...

Tom

"David Wilkinson" <no-reply@effisols.com> wrote in message 
news:%23ccODuEtHHA.3556@TK2MSFTNGP05.phx.gbl...
> Tom Serface wrote:

> c_str() returns const char*, not char*. The buffer cannot be modified 
> without using const_cast tricks which may corrupt the string.
>
> -- 
> David Wilkinson
> Visual C++ MVP 

0
tom.nospam (3240)
6/21/2007 11:31:35 PM
> In fact, you should be doing
>      AfxMessageBox(cString, MB_OK);

And even better:
    AfxMessageBox(IDS_STRING_TEST);
You don't put on screen something that is not stored in resources, right?
(I know, the exception is if the string is used for a FormatMessage before)


-- 
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
0
6/22/2007 5:21:39 AM
> CString::GetBuffer() can increase efficiency in some situations, but is 
> best avoided, IMHO. You will notice that std::string has no such mechanism.

To be avoided, but still best to have it.
I think it is bad that std::string does not have such a thing.
See my "std::string internal buffer access" note at
http://www.mihai-nita.net/article.php?artID=20060430a


-- 
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
0
6/22/2007 5:25:43 AM
Hi Mihai,

Nice to see you back.

This is true unless the string came from somewhere during runtime (like the 
string from a system error).

That said, I try to put every string possible (often even format strings) in 
the resource editor and use the FormatMessage version using %1 %2, etc. so 
that the translator can simply switch the order of the parameters at 
runtime.  Very convenient.

Tom

"Mihai N." <nmihai_year_2000@yahoo.com> wrote in message 
news:Xns9956E379515C8MihaiN@207.46.248.16...
>
> And even better:
>    AfxMessageBox(IDS_STRING_TEST);
> You don't put on screen something that is not stored in resources, right?
> (I know, the exception is if the string is used for a FormatMessage 
> before)

0
tom.nospam (3240)
6/22/2007 2:12:44 PM
Good point; I presumed that the string had already been obtained by a localized technique.
				joe

On Thu, 21 Jun 2007 22:21:39 -0700, "Mihai N." <nmihai_year_2000@yahoo.com> wrote:

>> In fact, you should be doing
>>      AfxMessageBox(cString, MB_OK);
>
>And even better:
>    AfxMessageBox(IDS_STRING_TEST);
>You don't put on screen something that is not stored in resources, right?
>(I know, the exception is if the string is used for a FormatMessage before)
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
6/22/2007 2:45:14 PM
Mr. Serface,

Do you have a little tutorial describing what you're talking about?

Regards,
Joe

"Tom Serface" <tom.nospam@camaswood.com> wrote in message 
news:1E49DC41-823B-4232-A50F-2EC5D8991ABC@microsoft.com...
> Hi Mihai,
>
> Nice to see you back.
>
> This is true unless the string came from somewhere during runtime (like 
> the string from a system error).
>
> That said, I try to put every string possible (often even format strings) 
> in the resource editor and use the FormatMessage version using %1 %2, etc. 
> so that the translator can simply switch the order of the parameters at 
> runtime.  Very convenient.
>
> Tom
>
> "Mihai N." <nmihai_year_2000@yahoo.com> wrote in message 
> news:Xns9956E379515C8MihaiN@207.46.248.16...
>>
>> And even better:
>>    AfxMessageBox(IDS_STRING_TEST);
>> You don't put on screen something that is not stored in resources, right?
>> (I know, the exception is if the string is used for a FormatMessage 
>> before)
> 


0
jp2code
6/22/2007 3:15:22 PM
I can explain it better.  Basically, if you use FormatMessage rather than 
Format your argument string tokens are represented as %1, %2, %3 rather than 
things like %s %c %d.  You would mostly do strings, but you can also do 
numbers with a format like %1!d!.  The advantage is when you call 
FormatMessage() the arguments to the function remain positional, but the 
tokens can be rearranged depending on language use.  For example: in English 
the order might be "XXX: %1 %2 %3", but in Spanish it might be "%2 %3 %1 : 
XXX".  The format can change, but you don't have to change the code.  In the 
Format/printf paradigm you sould have to actually change the argument 
sequence as the tokens (%s, %d, %c, ...) are not positional.

In the case of FormatMessage the above example:

IDS_FORMATRESOURCE "XXX: %1 %2 %3"

CString cs;
cs.FormatMessage(IDS_FORMATERESOURCE,csDate, csTime, csOption);

There would be another version of IDS_FORMATRESOURCE in each language 
satellite DLL.

Joe's tutorial might be interesting to you also:

http://www.flounder.com/formatmessage.htm

Tom

"jp2code" <poojo.com/mail> wrote in message 
news:O$bmoAOtHHA.3400@TK2MSFTNGP03.phx.gbl...
> Mr. Serface,
>
> Do you have a little tutorial describing what you're talking about?
>
> Regards,
> Joe
>
> "Tom Serface" <tom.nospam@camaswood.com> wrote in message 
> news:1E49DC41-823B-4232-A50F-2EC5D8991ABC@microsoft.com...
>> Hi Mihai,
>>
>> Nice to see you back.
>>
>> This is true unless the string came from somewhere during runtime (like 
>> the string from a system error).
>>
>> That said, I try to put every string possible (often even format strings) 
>> in the resource editor and use the FormatMessage version using %1 %2, 
>> etc. so that the translator can simply switch the order of the parameters 
>> at runtime.  Very convenient.
>>
>> Tom
>>
>> "Mihai N." <nmihai_year_2000@yahoo.com> wrote in message 
>> news:Xns9956E379515C8MihaiN@207.46.248.16...
>>>
>>> And even better:
>>>    AfxMessageBox(IDS_STRING_TEST);
>>> You don't put on screen something that is not stored in resources, 
>>> right?
>>> (I know, the exception is if the string is used for a FormatMessage 
>>> before)
>>
>
> 

0
tom.nospam (3240)
6/22/2007 5:13:24 PM
On Thu, 21 Jun 2007 22:25:43 -0700, "Mihai N." <nmihai_year_2000@yahoo.com>
wrote:

>> CString::GetBuffer() can increase efficiency in some situations, but is 
>> best avoided, IMHO. You will notice that std::string has no such mechanism.
>
>To be avoided, but still best to have it.
>I think it is bad that std::string does not have such a thing.
>See my "std::string internal buffer access" note at
>http://www.mihai-nita.net/article.php?artID=20060430a

Practically speaking, you can do this:

   const int N = 100;
   std::string s;
   s.resize(N);
   int len = WindowsAPI(&s[0], N);
   s.resize(len);

Though not guaranteed, I don't know any implementation where this won't
work. (I'd really like the non-contiguity, reference-counted, etc options
to just go away. People who need those things can't do without them, and
the possibility they exist complicates things for everyone else.)

Aside: MSDN has gotten a lot better about defining the meaning of N in the
code above. As a function parameter, it usually indicates the maximum
number of characters that may be written to the buffer, including the
terminating nul. As a return value, it usually indicates the number of
characters actually written, excluding the nul. This is true for functions
like GetWindowText, which truncate the returned text as necessary. What
does this imply for the return value?

-- 
Doug Harrison
Visual C++ MVP
0
dsh (2498)
6/22/2007 10:03:03 PM
One of the odd rules is that if you have a trucating API call, then the deal is that if
you get a value n that is equal to (for non-string values) or equal to one less than (for
string values) the size of the buffer, you need to double the buffer and read again,
repeat until the size read is truly less than the buffer size.
						joe

On Fri, 22 Jun 2007 17:03:03 -0500, "Doug Harrison [MVP]" <dsh@mvps.org> wrote:

>On Thu, 21 Jun 2007 22:25:43 -0700, "Mihai N." <nmihai_year_2000@yahoo.com>
>wrote:
>
>>> CString::GetBuffer() can increase efficiency in some situations, but is 
>>> best avoided, IMHO. You will notice that std::string has no such mechanism.
>>
>>To be avoided, but still best to have it.
>>I think it is bad that std::string does not have such a thing.
>>See my "std::string internal buffer access" note at
>>http://www.mihai-nita.net/article.php?artID=20060430a
>
>Practically speaking, you can do this:
>
>   const int N = 100;
>   std::string s;
>   s.resize(N);
>   int len = WindowsAPI(&s[0], N);
>   s.resize(len);
>
>Though not guaranteed, I don't know any implementation where this won't
>work. (I'd really like the non-contiguity, reference-counted, etc options
>to just go away. People who need those things can't do without them, and
>the possibility they exist complicates things for everyone else.)
>
>Aside: MSDN has gotten a lot better about defining the meaning of N in the
>code above. As a function parameter, it usually indicates the maximum
>number of characters that may be written to the buffer, including the
>terminating nul. As a return value, it usually indicates the number of
>characters actually written, excluding the nul. This is true for functions
>like GetWindowText, which truncate the returned text as necessary. What
>does this imply for the return value?
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
6/23/2007 2:10:57 AM
> &s[0]
....
> Though not guaranteed, I don't know any implementation where this won't
> work.

Possible, but implementation speciffic.
Since it is not captured in the standard in any way, it can disapear at any 
time.
(and in fact I think I know a case where this might break: flex_string of 
Andrei Alexandrescu, a very nice string class, standard compliant).


-- 
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
0
6/23/2007 8:35:24 AM
Hi,

> Nice to see you back.
I was around, but had nothing to add (enough good answers already :-)


> I try to put every string possible (often even format strings) in 
> the resource editor and use the FormatMessage version using %1 %2, etc. so 
> that the translator can simply switch the order of the parameters at 
> runtime.  Very convenient.
True. Both CString + FormatMessage take a string ID, forming a great
combination for good localizability.


-- 
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
0
6/23/2007 8:39:58 AM
On Sat, 23 Jun 2007 01:35:24 -0700, "Mihai N." <nmihai_year_2000@yahoo.com>
wrote:

>> &s[0]
>...
>> Though not guaranteed, I don't know any implementation where this won't
>> work.
>
>Possible, but implementation speciffic.
>Since it is not captured in the standard in any way, it can disapear at any 
>time.

Which is why I said:

>>I'd really like the non-contiguity, reference-counted, etc options to just
>>go away. People who need those things can't do without them, and the
>>possibility they exist complicates things for everyone else.

Again, I don't know of any implementation of std::string for which it won't
work, and I expect there would be tremendous resistance to breaking that
sort of code. Furthermore, I bet I can find other non-portable use of
std::string in most every program that makes non-trivial use of it. With at
least 2^4 possible implementations, it's a near certainty.

On a happy note, it appears the contiguity assumption will finally be made
a requirement (note well the rationale, in particular its last sentence):

530. Must elements of a string be contiguous?
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#530

I'm happy to learn of that, but my argument has always been that it's crazy
for a "basic" string to have upwards of 2^4 possible implementations with
wildly difference behavior and performance. Sometimes, too much freedom is
a bad thing, and it's clearly the case here. A basic_string ought to be
"basic", and someone needing a "fancy" string is well-advised to use one
that guarantees the things he requires.

>(and in fact I think I know a case where this might break: flex_string of 
>Andrei Alexandrescu, a very nice string class, standard compliant).

But flex_string != std::basic_string. I skimmed the DDJ article here:

http://www.ddj.com/dept/cpp/184403784

I see Andrei talked at length about "Standard-compliant" and COW. The
problem is, the two aren't compatible, at least if you think
"copy-on-write" actually means "copy-on-write".

-- 
Doug Harrison
Visual C++ MVP
0
dsh (2498)
6/23/2007 5:11:43 PM
Did anyone at Microsoft notice that there is no form of FormatMessage that allows an error
code or the specification of a instance handle for an executable that contains a Message
Table?  How could such critical capability been omitted?
						joe


On Sat, 23 Jun 2007 01:39:58 -0700, "Mihai N." <nmihai_year_2000@yahoo.com> wrote:

>Hi,
>
>> Nice to see you back.
>I was around, but had nothing to add (enough good answers already :-)
>
>
>> I try to put every string possible (often even format strings) in 
>> the resource editor and use the FormatMessage version using %1 %2, etc. so 
>> that the translator can simply switch the order of the parameters at 
>> runtime.  Very convenient.
>True. Both CString + FormatMessage take a string ID, forming a great
>combination for good localizability.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
6/23/2007 7:56:48 PM
On Fri, 22 Jun 2007 22:10:57 -0400, Joseph M. Newcomer
<newcomer@flounder.com> wrote:

>>Aside: MSDN has gotten a lot better about defining the meaning of N in the
>>code above. As a function parameter, it usually indicates the maximum
>>number of characters that may be written to the buffer, including the
>>terminating nul. As a return value, it usually indicates the number of
>>characters actually written, excluding the nul. This is true for functions
>>like GetWindowText, which truncate the returned text as necessary. What
>>does this imply for the return value?
>
>One of the odd rules is that if you have a trucating API call, then the deal is that if
>you get a value n that is equal to (for non-string values) or equal to one less than (for
>string values) the size of the buffer, you need to double the buffer and read again,
>repeat until the size read is truly less than the buffer size.
>						joe

Yep, it's weird. For a function like GetWindowText, the parameter N is a
"can't happen" return value (except for N == 0, I guess). If you get N-1,
you don't know if the string was exactly N-1 characters long or the API
truncated it, so like you say, you have to assume the worst if you want to
read the whole thing. This is all rather subtle, but I don't see a better
way to do it. If the API were to return the actual number of characters
written, including the nul, it wouldn't be returning the string length, and
that's too useful to give up.

-- 
Doug Harrison
Visual C++ MVP
0
dsh (2498)
6/23/2007 8:40:39 PM
FORMAT_MESSAGE_FROM_HMODULE?

What you mean by "error code"?

"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:tluq73998bac5kvd4ubc9plg9h2r075tcm@4ax.com...
> Did anyone at Microsoft notice that there is no form of FormatMessage that 
> allows an error
> code or the specification of a instance handle for an executable that 
> contains a Message
> Table?  How could such critical capability been omitted?
> joe
>
>
> On Sat, 23 Jun 2007 01:39:58 -0700, "Mihai N." 
> <nmihai_year_2000@yahoo.com> wrote:
>
>>Hi,
>>
>>> Nice to see you back.
>>I was around, but had nothing to add (enough good answers already :-)
>>
>>
>>> I try to put every string possible (often even format strings) in
>>> the resource editor and use the FormatMessage version using %1 %2, etc. 
>>> so
>>> that the translator can simply switch the order of the parameters at
>>> runtime.  Very convenient.
>>True. Both CString + FormatMessage take a string ID, forming a great
>>combination for good localizability.
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm 


0
alegr (1131)
6/23/2007 10:33:22 PM
Of course, if you use GetWindowTextLength() first and allocate a buffer of the right size,
you have a reasonble confidence that you will get all the characters (the liklihood that
someone else will change the string contents from another thread is vanishingly small, and
is a case that could be ignored, in that if you GetTextLength() == N and you allocate a
buffer of N+1 characters, and get N characters back, then either it is dead-on-accurate or
somebody wrote a longer string it between the two calls, and a programmer may choose to
ignore that situation.
					joe

On Sat, 23 Jun 2007 15:40:39 -0500, "Doug Harrison [MVP]" <dsh@mvps.org> wrote:

>On Fri, 22 Jun 2007 22:10:57 -0400, Joseph M. Newcomer
><newcomer@flounder.com> wrote:
>
>>>Aside: MSDN has gotten a lot better about defining the meaning of N in the
>>>code above. As a function parameter, it usually indicates the maximum
>>>number of characters that may be written to the buffer, including the
>>>terminating nul. As a return value, it usually indicates the number of
>>>characters actually written, excluding the nul. This is true for functions
>>>like GetWindowText, which truncate the returned text as necessary. What
>>>does this imply for the return value?
>>
>>One of the odd rules is that if you have a trucating API call, then the deal is that if
>>you get a value n that is equal to (for non-string values) or equal to one less than (for
>>string values) the size of the buffer, you need to double the buffer and read again,
>>repeat until the size read is truly less than the buffer size.
>>						joe
>
>Yep, it's weird. For a function like GetWindowText, the parameter N is a
>"can't happen" return value (except for N == 0, I guess). If you get N-1,
>you don't know if the string was exactly N-1 characters long or the API
>truncated it, so like you say, you have to assume the worst if you want to
>read the whole thing. This is all rather subtle, but I don't see a better
>way to do it. If the API were to return the actual number of characters
>written, including the nul, it wouldn't be returning the string length, and
>that's too useful to give up.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
6/23/2007 10:50:59 PM
For example, ::GetLastError codes. These are often represented by MESSAGETABLE resources
in a module.  And yes, ::FormatMessage has all this capability, but CString::FormatMessage
exposes only some of the least interesting aspects of ::FormatMessage.
					joe
On Sat, 23 Jun 2007 15:33:22 -0700, "Alexander Grigoriev" <alegr@earthlink.net> wrote:

>FORMAT_MESSAGE_FROM_HMODULE?
>
>What you mean by "error code"?
>
>"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
>news:tluq73998bac5kvd4ubc9plg9h2r075tcm@4ax.com...
>> Did anyone at Microsoft notice that there is no form of FormatMessage that 
>> allows an error
>> code or the specification of a instance handle for an executable that 
>> contains a Message
>> Table?  How could such critical capability been omitted?
>> joe
>>
>>
>> On Sat, 23 Jun 2007 01:39:58 -0700, "Mihai N." 
>> <nmihai_year_2000@yahoo.com> wrote:
>>
>>>Hi,
>>>
>>>> Nice to see you back.
>>>I was around, but had nothing to add (enough good answers already :-)
>>>
>>>
>>>> I try to put every string possible (often even format strings) in
>>>> the resource editor and use the FormatMessage version using %1 %2, etc. 
>>>> so
>>>> that the translator can simply switch the order of the parameters at
>>>> runtime.  Very convenient.
>>>True. Both CString + FormatMessage take a string ID, forming a great
>>>combination for good localizability.
>> Joseph M. Newcomer [MVP]
>> email: newcomer@flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm 
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
6/23/2007 11:25:04 PM
You're right about CString, but the function is pretty simple.  I use this 
one:

CRITICAL_ERROR CSpanRestoreDlg::DisplayCriticalError(DWORD nError)
{
     LPVOID lpMsgBuf;

     FormatMessage(
          FORMAT_MESSAGE_ALLOCATE_BUFFER |
          FORMAT_MESSAGE_FROM_SYSTEM,
          NULL,
          nError,
          MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
          (LPTSTR) &lpMsgBuf,
          0, NULL );
     CString cs;
     cs.FormatMessage(IDS_CRITICAL_ERROR,nError,lpMsgBuf);
     LocalFree(lpMsgBuf);
     int ret = AfxMessageBox(cs,MB_ICONSTOP | MB_ABORTRETRYIGNORE);
     if(ret == IDABORT)
          return CRITICAL_ABORT;
     else if(ret == IDRETRY)
          return CRITICAL_RETRY;
     else
          return CRITICAL_IGNORE;
}

customized a little for my specific use.

Tom
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:vrar735etcclvtm4fkqnbk10uvs4hll59f@4ax.com...
> For example, ::GetLastError codes. These are often represented by 
> MESSAGETABLE resources
> in a module.  And yes, ::FormatMessage has all this capability, but 
> CString::FormatMessage
> exposes only some of the least interesting aspects of ::FormatMessage.
> joe
> On Sat, 23 Jun 2007 15:33:22 -0700, "Alexander Grigoriev" 
> <alegr@earthlink.net> wrote:
>
>>FORMAT_MESSAGE_FROM_HMODULE?
>>
>>What you mean by "error code"?
>>
>>"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
>>news:tluq73998bac5kvd4ubc9plg9h2r075tcm@4ax.com...
>>> Did anyone at Microsoft notice that there is no form of FormatMessage 
>>> that
>>> allows an error
>>> code or the specification of a instance handle for an executable that
>>> contains a Message
>>> Table?  How could such critical capability been omitted?
>>> joe
>>>
>>>
>>> On Sat, 23 Jun 2007 01:39:58 -0700, "Mihai N."
>>> <nmihai_year_2000@yahoo.com> wrote:
>>>
>>>>Hi,
>>>>
>>>>> Nice to see you back.
>>>>I was around, but had nothing to add (enough good answers already :-)
>>>>
>>>>
>>>>> I try to put every string possible (often even format strings) in
>>>>> the resource editor and use the FormatMessage version using %1 %2, 
>>>>> etc.
>>>>> so
>>>>> that the translator can simply switch the order of the parameters at
>>>>> runtime.  Very convenient.
>>>>True. Both CString + FormatMessage take a string ID, forming a great
>>>>combination for good localizability.
>>> Joseph M. Newcomer [MVP]
>>> email: newcomer@flounder.com
>>> Web: http://www.flounder.com
>>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>>
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm 

0
tom.nospam (3240)
6/24/2007 4:20:17 AM
I have virtually identical code posted on my Web site as far as the conversion code; my
ErrorString function appears in nearly every piece of code I write.  But the real question
is why MFC never supported this?  It should have, if people were more concerned about
useful functionality instead of how to yet-once-again make the IDE even more unusable than
the last release, we might see something productive emerge, something that actually
ENHANCED the usability of the system.  Yet after all these years, we can't even add
extended reflected handlers, which should have been put in as soon as the _EX macros were
invented!  We've gone through four or six releases of MFC and the IDE and MFC *still*
doesn't have methods for every message, or handlers for every event!
					joe

On Sat, 23 Jun 2007 21:20:17 -0700, "Tom Serface" <tom.nospam@camaswood.com> wrote:

>You're right about CString, but the function is pretty simple.  I use this 
>one:
>
>CRITICAL_ERROR CSpanRestoreDlg::DisplayCriticalError(DWORD nError)
>{
>     LPVOID lpMsgBuf;
>
>     FormatMessage(
>          FORMAT_MESSAGE_ALLOCATE_BUFFER |
>          FORMAT_MESSAGE_FROM_SYSTEM,
>          NULL,
>          nError,
>          MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
>          (LPTSTR) &lpMsgBuf,
>          0, NULL );
>     CString cs;
>     cs.FormatMessage(IDS_CRITICAL_ERROR,nError,lpMsgBuf);
>     LocalFree(lpMsgBuf);
>     int ret = AfxMessageBox(cs,MB_ICONSTOP | MB_ABORTRETRYIGNORE);
>     if(ret == IDABORT)
>          return CRITICAL_ABORT;
>     else if(ret == IDRETRY)
>          return CRITICAL_RETRY;
>     else
>          return CRITICAL_IGNORE;
>}
>
>customized a little for my specific use.
>
>Tom
>"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
>news:vrar735etcclvtm4fkqnbk10uvs4hll59f@4ax.com...
>> For example, ::GetLastError codes. These are often represented by 
>> MESSAGETABLE resources
>> in a module.  And yes, ::FormatMessage has all this capability, but 
>> CString::FormatMessage
>> exposes only some of the least interesting aspects of ::FormatMessage.
>> joe
>> On Sat, 23 Jun 2007 15:33:22 -0700, "Alexander Grigoriev" 
>> <alegr@earthlink.net> wrote:
>>
>>>FORMAT_MESSAGE_FROM_HMODULE?
>>>
>>>What you mean by "error code"?
>>>
>>>"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
>>>news:tluq73998bac5kvd4ubc9plg9h2r075tcm@4ax.com...
>>>> Did anyone at Microsoft notice that there is no form of FormatMessage 
>>>> that
>>>> allows an error
>>>> code or the specification of a instance handle for an executable that
>>>> contains a Message
>>>> Table?  How could such critical capability been omitted?
>>>> joe
>>>>
>>>>
>>>> On Sat, 23 Jun 2007 01:39:58 -0700, "Mihai N."
>>>> <nmihai_year_2000@yahoo.com> wrote:
>>>>
>>>>>Hi,
>>>>>
>>>>>> Nice to see you back.
>>>>>I was around, but had nothing to add (enough good answers already :-)
>>>>>
>>>>>
>>>>>> I try to put every string possible (often even format strings) in
>>>>>> the resource editor and use the FormatMessage version using %1 %2, 
>>>>>> etc.
>>>>>> so
>>>>>> that the translator can simply switch the order of the parameters at
>>>>>> runtime.  Very convenient.
>>>>>True. Both CString + FormatMessage take a string ID, forming a great
>>>>>combination for good localizability.
>>>> Joseph M. Newcomer [MVP]
>>>> email: newcomer@flounder.com
>>>> Web: http://www.flounder.com
>>>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>>>
>> Joseph M. Newcomer [MVP]
>> email: newcomer@flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm 
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
6/24/2007 5:33:47 PM
On Sat, 23 Jun 2007 18:50:59 -0400, Joseph M. Newcomer
<newcomer@flounder.com> wrote:

>Of course, if you use GetWindowTextLength() first and allocate a buffer of the right size,
>you have a reasonble confidence that you will get all the characters (the liklihood that
>someone else will change the string contents from another thread is vanishingly small, and
>is a case that could be ignored, in that if you GetTextLength() == N and you allocate a
>buffer of N+1 characters, and get N characters back, then either it is dead-on-accurate or
>somebody wrote a longer string it between the two calls, and a programmer may choose to
>ignore that situation.
>					joe

Sure, that's how I actually did it in my string class:

   const size_type len = ::GetWindowTextLength(hWnd);
   uninitialized_resize(len);
   // Windows doesn't truncate in the strncpy sense; it always
   // nul-terminates.
   resize(::GetWindowText(hWnd, raw_data(), len+1));
   return *this;

I wrote this almost 10 years ago as part of a std::basic_string-like class
that provides true COW, which I still use today. I talked some more about
it here:

http://groups.google.com/group/microsoft.public.vc.stl/msg/fa3c6c5d1ba99453

My string class always makes room for the terminating nul, so the
uninitialized_resize call is indeed correct. That function differs from
resize in that it doesn't initialize the new space when growing the string,
and it was written for exactly this usage pattern. The function raw_data()
is like data() except it returns a non-const pointer. Ironically, I can't
use the &s[0] approach, because s[0] returns a reference object that is
actually of class type, and taking its address returns an iterator, not a
pointer. This is where I deviated from the standard, and it was necessary
to support real COW.

-- 
Doug Harrison
Visual C++ MVP
0
dsh (2498)
6/24/2007 5:45:04 PM
>>(and in fact I think I know a case where this might break: flex_string of 
>>Andrei Alexandrescu, a very nice string class, standard compliant).
> 
> But flex_string != std::basic_string. I skimmed the DDJ article here:
> 
> http://www.ddj.com/dept/cpp/184403784
> 
> I see Andrei talked at length about "Standard-compliant" and COW. The
> problem is, the two aren't compatible, at least if you think
> "copy-on-write" actually means "copy-on-write".

I don't think there is any standard requirement for "copy-on-write" behavior,
that is implementation speciffic.
for me standard-compliant is good enough. It means at any time some
compiler crator can decide to drop his implementation and adopt Andrei's
implementation.
Even the DDJ article says "a policy-based basic_string implementation"
It is an implementation, and I don't know based on what criteria one can
say that flex_string != std::basic_string

The standard does not provide an implementation. So if I write something
that exposes all the public behavior and methods required by the C++
standard for std::basic_string, then the class *is* std::basic_string


-- 
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
0
6/24/2007 9:11:59 PM
On Sun, 24 Jun 2007 14:11:59 -0700, "Mihai N." <nmihai_year_2000@yahoo.com>
wrote:

>>>(and in fact I think I know a case where this might break: flex_string of 
>>>Andrei Alexandrescu, a very nice string class, standard compliant).
>> 
>> But flex_string != std::basic_string. I skimmed the DDJ article here:
>> 
>> http://www.ddj.com/dept/cpp/184403784
>> 
>> I see Andrei talked at length about "Standard-compliant" and COW. The
>> problem is, the two aren't compatible, at least if you think
>> "copy-on-write" actually means "copy-on-write".
>
>I don't think there is any standard requirement for "copy-on-write" behavior,
>that is implementation speciffic.

Of course the standard doesn't require it. What I was getting at is that
the standard does not permit COW.

>for me standard-compliant is good enough. It means at any time some
>compiler crator can decide to drop his implementation and adopt Andrei's
>implementation.
>Even the DDJ article says "a policy-based basic_string implementation"
>It is an implementation, and I don't know based on what criteria one can
>say that flex_string != std::basic_string

I don't know any standard library implementation that comes with
flex_string renamed to basic_string.

>The standard does not provide an implementation. So if I write something
>that exposes all the public behavior and methods required by the C++
>standard for std::basic_string, then the class *is* std::basic_string

And you should feel free to use it. Just make sure you've observed all the
little nuances necessary to use std::string in a truly portable way.

-- 
Doug Harrison
Visual C++ MVP
0
dsh (2498)
6/24/2007 9:21:04 PM
> I don't know any standard library implementation that comes with
> flex_string renamed to basic_string.
True.

> And you should feel free to use it. Just make sure you've observed all the
> little nuances necessary to use std::string in a truly portable way.
After reading your open-std.org link it seems I can do this, but not for long
:-)

But reading it, I still think there is no decend standard way to write
something in a standard string in a standard way.
Even if the storage is contigous, the data is still const, you I cannot
safely change it.


-- 
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
0
6/24/2007 9:33:54 PM
On Sun, 24 Jun 2007 14:33:54 -0700, "Mihai N." <nmihai_year_2000@yahoo.com>
wrote:

>But reading it, I still think there is no decend standard way to write
>something in a standard string in a standard way.
>Even if the storage is contigous, the data is still const, you I cannot
>safely change it.

The following will be fine:

   string s;
   s.resize(n);
   memcpy(&s[0], 0, n);

One of the benefits to requiring s[0] to return a real reference (which is
what disallows COW) is that &s[0] returns a real pointer.

-- 
Doug Harrison
Visual C++ MVP
0
dsh (2498)
6/24/2007 10:10:05 PM
Yeah, I'm hoping a version coming up soon will have some of this fleshed 
out.  It seems like most of the stuff you mention should be table driven and 
easy enough to add to the IDE.  Now that MSFT is focusing again on MFC as a 
native solution I'm hoping it gets some attention.

Tom

"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:iiat73tsjk0vbnid23847fo1u0tda8mgpa@4ax.com...
>I have virtually identical code posted on my Web site as far as the 
>conversion code; my
> ErrorString function appears in nearly every piece of code I write.  But 
> the real question
> is why MFC never supported this?  It should have, if people were more 
> concerned about
> useful functionality instead of how to yet-once-again make the IDE even 
> more unusable than
> the last release, we might see something productive emerge, something that 
> actually
> ENHANCED the usability of the system.  Yet after all these years, we can't 
> even add
> extended reflected handlers, which should have been put in as soon as the 
> _EX macros were
> invented!  We've gone through four or six releases of MFC and the IDE and 
> MFC *still*
> doesn't have methods for every message, or handlers for every event!
> joe

0
tom.nospam (3240)
6/25/2007 5:30:20 AM
> The following will be fine:
> 
>    string s;
>    s.resize(n);
>    memcpy(&s[0], 0, n);
> 
> One of the benefits to requiring s[0] to return a real reference (which is
> what disallows COW) is that &s[0] returns a real pointer.

From wat I know works in all current implementations, but still not
*guaranteed* by the standard in any way.



-- 
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
0
6/25/2007 7:26:54 AM
Reply:

Similar Artilces:

HELP: Assistance required with trying to calculate distances based on latitude and longitude
Hi All, I have been searching the net everywhere and have not been fruitful as yet. I did find formulas to determine distances but when i put them into an SQL statement they cause errors. it appears Access spits the dummy if you have a calculation that is too long. I first tried it in MS Query in Excel and it kept popping up a statement to the effect of an error, then i put it directly into Access and the colums results all show "#error". I constructed the calculation slowly, part by part and it was accepting the staged construction until towards the very end. I was attempti...

HELP RE: DISPLAY CHECK NUMBER ON PAYEE REPORT WITH
How do I get a historic payment reoport for a specific payee including check number, date, amount, and payee name? ie: "Car Loan Payment history for the period 1/1/01 thru today" Payee: Check # : Date: Amount: (and perhaps a running total or a final total) I think I have tried all the built in reports and can't find one to do this or modify existing to do this. I see this information in the "view payee details" window, listed in the format I require but when I select PRINT all that prints is the bar graph that is also displayed on this page. I ca...

Being suppressed little clerk need help~~
Now I have a large amount of data (date , company name, card no. , plac ,officier name), and I need to classify according to company name int different new page and then in each page the data also need to b sorted according to official name and place into tables. How can I do with formula? Please help me ~~~~~ Thx!Thx!Thx -- tingkit ----------------------------------------------------------------------- tingkit1's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1505 View this thread: http://www.excelforum.com/showthread.php?threadid=26679 Hi why not use Excel...

How to verify the size of an editbox item before copying it to a CString ?
Hi all Here's the code : /*******************************************/ CString szPassword; // A test on the text length entered in IDC_EDIT_PASSWORD should be // implemented here // If I enter a very big value for the password, the application bugs // On the following line : GetDlgItemText(IDC_EDIT_PASSWORD, szPassword); MessageBox(szPassword, "PASSWORD", MB_OK); /*******************************************/ Thank you very much if anyone can help ;) MicroCode2004, You can set the limit of the text in the resource editor. Johan Rosengren Abstrakt Mekanik AB "__M...

Can somebody help me to uninstall Publisher 2007 trial?
Everytime i try to uninstall it it says 'Setup could not find any available products to install. please contact your system administrator.' This also happens with 'Microsoft Home and Student trial 2007' Any suggestions? Thank you How to manually uninstall the 2007 Office system if you cannot uninstall it by using the "Add or Remove Programs" feature http://support.microsoft.com/kb/928218/en-us -- Mary Sauer MVP http://msauer.mvps.org/ "Alex" <Alex@discussions.microsoft.com> wrote in message news:98ADA333-7B20-41E2-A481-929A0C...

Help: vc6.0 program crashed under latest windows XP update
Hi I have one vc6.0 program which used to work correctly under windows xp. But now it crashed under latest windows XP update. I got the error message when crashing msvcrt.dll Modver: 7.0.2600.2180 offset:00036803 But the file version of my distrubuted msvcrt.dll is 6.0.9782.0 Any one has the same problem? Any fix? Thank you, -- Best regards, Kelvin Gan Kelvin wrote: > Hi > > I have one vc6.0 program which used to work correctly under windows xp. > But now it crashed under latest windows XP update. > I got the error message when crashing > msvcrt.dll Modver: 7.0....

Deseperately Need Your HELP!
Hi all, When I tried to upgrade the exch2000 frondend to the exch2003, I got this error"Setup failed while installing sub-component Microsoft Exchange server-level objects with error code 0xC0070574(please cousult the installation for a detailed description) BTW, I am using the account with exchange full admin rights and doamin admin here is the detail from the setup log: 10:12:20] Using cached result for domain "/dc=company/dc=local" [10:12:20] The required permissions have not already been set [10:12:20] Leaving ScDetermineIfLocalDomainServerGroupHasAlreadyBeenACLedO...

Outlook Issues -- HELP!!
I recently performed an update in Windows and ever since have problems now with Outlook (ver, whatever comes with XP). Often times when I open Outlook the program will display the following message "The data file "Personal Folders" was not closed properly. The file is being checked for problems." There should be no reason for this, since I always use File, Exit, or else the X at top to close. In addition, it often freezes up for no reason; and sometimes it doesn't automatically send emails through to me, until I hit the Send/Receive button, although it is set ...

Customized Help Content
If you have multiple organizations on the same deployment, how can you customize the help content for each organization. The reason that I would want to do this is that each organization might have a different layout on the forms and different fields that the users are supposed to track. The help files are all stored as phyical files on the server so I am not sure how to make them organization specific. Thanks, Dan ...

Help in Grasping a Concept
I am trying to learn about Macros because our head financial guy is a boob and has everything screwed up. Here is what I am trying to do: 1. I have a list of main data in a spreadsheet on one worksheet 2. Each row of this data needs to be shown as a multiple row view on another sheet (more like it's own mini spreadsheet) as the data needs to be readable and doesn't make sense spread out on a row that has 100 columns. 3. In theory, I would like to create a new sheet for each row on my main worksheet that will show the data in the "viewable" format so, if I have 25 rows ...

Pin Pad Setup Help
I am using RMS and VitalNet and have my Mag Stripe reader working, but I can't get my PinPad to be found. Does anyone know how to set the PinPad up. It's the Verifone 1000SE. I am using a USB to serial adapter. -- Dan Shuman Salem Cycle Salem, MA 01970 ...

Help!! My ICS/Firewall files are missing.. PLEASE HELP!!
Hello, I recently had a virus attack and cleaned everything off.. I have Avast virus software. I noticed that when i restarted my computer that my firewall was turned off.. So i went into the settings and tried to turn it back on but instead i got this message: "Windows Could not open the Firewall/ICs settings beause the associated service is not running". I clicked start on the serivces pane and i got another message saying "error 2 file not found". Now could this of happened when Avast deleted the infected files?? if so how can i get it back?? Please respond ASAP...

Help on help
At work I use Windows XP Professional Version 2002 SP2 with Excel 2002. When I need help, I press F1 from anywhere, I get the normal help with tabs of "Contents", "Answer Wizard", and "Index". This is the same help for a long time and it's great to answer most questions. But at home I use Windows XP Home Edition with Office 2003. I press F1 in Excel and it tries to search the web. I'D REALLY LIKE THE OLD HELP THAT I HAVE AT THE OFFICE!! Does anyone know if this is a setting that can be changed??? THANK YOU! Although the help in 2003 will neve...

REQ
Hi all I have some data (email addresses) that I've imported into Excel and I'm trying to delete the duplicate cells. eg the Sheet looks like the following and I want to get rid of the duplicates. Can someone please tell me how to do this joe.blogs@bigspammer.com joe.blogs@bigspammer.com joe.blogs@bigspammer.com joe.blogs@bigspammer.com ace.whitehead@bigspammer.com ace.whitehead@bigspammer.com ace.whitehead@bigspammer.com ace.whitehead@bigspammer.com neal.cassady@bigspammer.com neal.cassady@bigspammer.com neal.cassady@bigspammer.com neal.cassady@bigspammer.com jack.kerouac@bigspamm...

string (clr) and CString (MFC) in same class
Is there any way to use both string (system.string) and CString in the same class? -- Tony H are you talking about System.String (as in .Net frameworks) or std::string? AliR. "Tony H" <TonyH@discussions.microsoft.com> wrote in message news:EAAFFBB3-C61B-4A88-97D3-AFD052AA8337@microsoft.com... > Is there any way to use both string (system.string) and CString in the same > class? > -- > Tony H > System::String, I think. I have to interface with a VB class in the same project which uses system.string. -- Tony H "AliR" wrote: > are you tal...

Working with hours and minutes. Help please!
I want to draw a graph on something that happened over 24 hours e.g. 0700 2 (i.e. 7am, value - 2) 0713 3 0905 12 1307 2 1906 6 2305 9 (i.e. 11.05pm, value 9) Can I get Excel to put time on the X axis? Can I get Exel to calculate time difference from 7.13am to 9.05am - i.e. it's not 0905 - 0713 = 0202; it should be 1hour 52minutes Yes, it's quite straightforward. The key is to ensure the times are stored as true Excel times. The easiest way is to type the times in with a colon (eg, 07:05). Excel will then graph the values properly. Simply choose your 12 cells (or better yet, a...

urgent help needed 05-22-05
We are doing migration of data to our newcrm system. We made a mistake in mapping the data because of which the subject of the activities was not transferred properly. Now the issue is we have 500000 activities (all with closed state)) with the wrong subject name. We know what the subject should be but do not have enough time to delete all these all these activities and transfer data again. Since we do not use offline capabilities, is it safe to directly update the activity subject in the CRM database? If you are just updating the Subject, this should be safe, however it is not "...

Help-Error validating multiple documents
Hello. I've got a total of 5 schemas. They are: 1 - 1.xsd - a description of a city 2 - 2.xsd - a description of a town 3 - CityHall.xsd - a description of a cityhall-meant to be part of a document based on 1.xsd in "user area". 4 - TownHall.xsd - a description of a townhall-meant to be part of a document based on 2.xsd in "user area". 5 - testmultischema.xsd - a document which combines in a batch instances of cities and towns based upon 1.xsd and 2.xsd. I get the following xml validation error: ERROR: The 'http://adamExt.org:TownHall' element is not declar...

Combo Box Help 01-02-08
Table Fields: Stager Zone Linked as a subform. Using combo box for Stager with the following code: Private Sub Stager_AfterUpdate() Me.Zone = Me.Stager.Column(1) End Sub This works for the first record on the subform. The problem arises when I go to the next record on the subform (continuous form), It automatically changes the information in the first record to whatever I put in the second record. Layout of form: LogID (Auto Number) Auditor Date Shift Entered by Layout of subform: LogId (Number format) Round (First or Second) Stager (combo box listed above) Zone (combo box from ...

Help: need mac version of microsoft excel executable
I just updated my office from 10.0.0 to 10.1.5 (apply 10.1.2, 10.1.4 then 10.1.5), however, I did a mistake that excel was still open while I ran the updates. Despite the update installer told me the updates were successfully, my excel won't be able to start anymore. When I checked the version of my excel, it stayed at 10.0.0! I wonder if anyone can send me the excel executable of version 10.1.x. Thanks very much. Samuel In article <7718323c.0408020709.1b8fd690@posting.google.com>, samuelh@seed.net.tw (Shianmiin) wrote: > I just updated my office from 10.0.0 to 10.1.5 (apply ...

keyboard recognition has slowed down in excel, help/
When using excell my keyboard recognition slows down to the point I have to sit and wait for a few seconds. Does anyone have any idea why this is happening in Excell? ...

Help in Sales Analysis
Anybody Please help... Sorry again, in Northwind template 2007. I found something wrong in sales Analysis, but I dont know how to solve. Queries of sales analysis show below- MonthOfQuarter: (Month([Order Date]) Mod 3), in data sheet view oct = 1, Nov = 2, Dec = 0 and sales of Dec did not show up. I guess Dec should be 3, if im not wrong. What do you think and how to solve the problem. The sales of dec month did not show up...it shows no sales or 0 in quarter sales report summary. Thank you. -- Message posted via http://www.accessmonster.com If you are going to use MO...

In need of help with Submit function in Publisher 2004
Could someone please help me with the following: I'm trying to do is redirect a "Submitted" form that a users would fill out in a Web page (by the way the web page was published using MS Publisher 2003), onto a folder either on the Web Server or another Server on the same network. This is needed so that the administrator (the person who will be receiving the form) can go to a folder on the network and retrieve them. My question is, within the design view of Publisher 2003 (.PUB), there is a "Submit" button that has been created. And in Publisher (design view) you can ...

MS Money Will No Longer Update Accounts--HELP!
Have been doing well with updating about 8 accounts online in MSN money==not a hitch. However, earlier this week, it started updating a few of the accounts, and now will not download or upload transactions from the program for electronic processing. This is a bit bizare. Is anyone else having trouble connecting and downloading statements/transactions? Ho?w can I address this problem I am having the same problem. I open a case with Microsoft and they think the problem has to do with their connection with Yoodle. Cindy I've got the same problem. It will update my balance inf...

Simple Bar Charting Problem: Would Sure Appreciate Some Help On This
Hello, Boy, do I feel dumb in asking this, but, honest, I've been playing around with this for hours, and just can't get what I want. I'm new at Excel Charting, so let me blame it on that. Would be most appreciative for any help. All I want to do is to create a very simple Bar (or perhaps it is actually called a Column) type of chart from two columns of data. What I have in Column B is "Suggested Yearly Dues, $" and in Column C "No. Of Respondents". So, it looks like this: Suggested Yearly Dues, $ No. Of Respondents ...