CString question #4

Hello,


I have just one little question : if I use the followig code

CString mystring;
mystring = "HELLO";
myeditbox.SetWindowText(mystring.GetBuffer(0));

do I need, after that, to free or release the mystring variable, or can 
I use GetBuffer(0) just like this with nothing else ?

Thanks.

-- 
LA FINALITE DYNAMISE LES RESULTATS THEMATIQUES DES BENEFICIAIRES


0
email2105 (26)
7/27/2005 10:12:37 AM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
897 Views

Similar Articles

[PageSpeed] 24

You do not need to call GetBuffer. Just do :-

CString mystring = "HELLO";
myeditbox.SetWindowText(mystring);

-- 
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com


"ByB" <email@email.com> wrote in message 
news:mn.dadc7d57e8ba9326.13846@email.com...
> Hello,
>
>
> I have just one little question : if I use the followig code
>
> CString mystring;
> mystring = "HELLO";
> myeditbox.SetWindowText(mystring.GetBuffer(0));
>
> do I need, after that, to free or release the mystring variable, or can I 
> use GetBuffer(0) just like this with nothing else ?
>
> Thanks.
>
> -- 
> LA FINALITE DYNAMISE LES RESULTATS THEMATIQUES DES BENEFICIAIRES
>
> 


0
nish (347)
7/27/2005 10:18:16 AM
Si je n'�tais pas venu sur ce forum le 27/07/2005, aurai-je su que 
Nishant Sivakumar avait dit que
> You do not need to call GetBuffer. Just do :-
>
> CString mystring = "HELLO";
> myeditbox.SetWindowText(mystring);
>
>
OK, but this was just an example to know if I need to do something else 
after calling GetBuffer or not ...


-- 
L'ordinateur ob�it � vos ordres, pas � vos intentions. [Anonyme]


0
email2105 (26)
7/27/2005 11:14:08 AM
> Hello,
>
>
> I have just one little question : if I use the followig code
>
> CString mystring;
> mystring = "HELLO";
> myeditbox.SetWindowText(mystring.GetBuffer(0));
>
> do I need, after that, to free or release the mystring variable, or can I 
> use GetBuffer(0) just like this with nothing else ?
>

Call "mystring.ReleaseBuffer( );" afterward.

Simon


0
7/27/2005 11:30:44 AM
Bien que tout le monde le sache d�ja, remercions Simon d'avoir pens� � 
�crire que
>> Hello,
>>
>>
>> I have just one little question : if I use the followig code
>>
>> CString mystring;
>> mystring = "HELLO";
>> myeditbox.SetWindowText(mystring.GetBuffer(0));
>>
>> do I need, after that, to free or release the mystring variable, or can I 
>> use GetBuffer(0) just like this with nothing else ?
>>
>
> Call "mystring.ReleaseBuffer( );" afterward.
>
> Simon

Thank you


-- 
Si tu ne peux pas battre ton ordinateur aux �checs, essaie le 
kickboxing ![Anonyme]


0
email2105 (26)
7/27/2005 1:36:21 PM
As mentioned already, you do need to call "ReleaseBuffer(...)" after a
call to "GetBuffer(...)".  However, I will point out that calling
"GetBuffer( 0 )" is a bad habit to get into, unless to know exactly
what is going on.

GetBuffer(...) resizes the current CString's buffer (actually, it
allocates new memory and leaved the shared data object alone) if
required.  But if you specify a size of "0", any buffer currently in
the CString will be returned.  This causes lots of problems when people
try to write into that buffer.  A more interesting situation is when
the CString is still empty (set to "AfxEmptyString", on VC++ 6.0), and
someone formats into that CString's buffer.  That can corrupt the value
of AfxEmptyString, and now all current and future empty CString objects
are no longer "empty".

Moral: Do not use "GetBuffer( 0 )"...! :)

Peace!

-=- James.

0
spam9311 (30)
7/28/2005 11:35:14 AM
Reply:

Similar Artilces:

Calendar Archive question
I seem to be able to archive a calendar before a selected date (the info is in the archived file) but that material is not deleted from the calendar file. What am I doing wrong? Note: I'm using a "sub" calendar folder, not the main calendar. Thank you. Do the items in question actually make it to the archive PST? "its_my_dime" <its_my_dime@yahoo.com.spam (hold the .spam)> wrote in message news:O0bH2BiJGHA.1032@TK2MSFTNGP11.phx.gbl... >I seem to be able to archive a calendar before a selected date (the info is > in the archived file) but that materi...

4 Days NDR ... explained
In my org LAN the clients use the outlook (pop3) to connect and download the email on their own computer ... in exchange there is no storage limits ... i want the the exchange server to keep email for 4 days and after that NDR should be send to sender ... how can i do that ??????????? you cant. if this is a LAN, why are you using pop3? "Feelings" <Feelings@discussions.microsoft.com> wrote in message news:4CA22332-46CA-4C58-85F5-F3C8D805981E@microsoft.com... > In my org LAN the clients use the outlook (pop3) to connect and download > the > email on their own co...

question?
I have recently switched to a new computer at my office. I was able to set up my email in outlook. I wanted to transfer the email messages from my old computer to my ne w computer. Does anyone know how to do this??? locate and copy the file called *.pst Then in Outlook open it. "Cliff" <c-sharp@chc-group.com> wrote in message news:03fe01c3a88d$8cbbf850$a301280a@phx.gbl... > I have recently switched to a new computer at my office. > I was able to set up my email in outlook. I wanted to > transfer the email messages from my old computer to my ne > w computer. Doe...

volume question
Hi, I have a potential project with that pre-requisits : Users 100 => Fine 300 000 Customers and 1 000 000 contacts Do you think, MS CRM can manage that configuration correctly (i.e. corect response time, ...) ? Is ther somebody with a similar configuration who can send me a feedback ? Who has a large db whit such records and how many to get an idea ? Thanks in advance for your help, regards. Dominique Szczudlak Dominique, I found a case study for a large-scale implementation of CRM 1.2. It includes the hardware configuration used. One conclusion is that some tuning of the SQL ind...

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...

How to questions
Where would I go to configure a schedule depreciation entry to process each month? Where would I go to fix the check alignment when printing checks? Randall randyf@nbsys.com First, it would be helpful if you'd use the subject line to identify the topic. Based on your first question, it does not appear you are using the Fixed Assets module. So, I think you're asking about scheduling a recurring GL entry. Based on that, you create a batch in GL and set the frequency to monthly. You enter the journal entries in the batch. If I'm way off of what you're asking, please el...

Sumif Question
I need help with a sumif formula. I have two spreadsheets. On my report spreadsheet I want to use a sumif function that looks at two columns in the other spreadsheet and give me a total based on the following criteria. 1. Look at the date in F2 and compare to the date in C2. Count if the date in F2 is greater than C2. OR 2. If F2 is blank, and today's date is greater than C2, count. Do you mean =SUMPRODUCT(--((F2:F20>C2:C20)+((F2:F20="")*(TODAY()>C2:C20)))) -- HTH Bob "stevestr" <stevestr@discussions.microsoft.com...

Formula Question
Can someone tell me what a " mark in this formula means? Example: =IF(G40:G52)>0,SUM(G40:G52),"") -- clacount Where in FrontPage are you doing this? -- Tom [Pepper] Willett Microsoft MVP - FrontPage Since 1997 --------------------------- "clacount" <clacount@discussions.microsoft.com> wrote in message news:A43C132B-76C3-4B43-862A-6A36718E9E08@microsoft.com... : Can someone tell me what a " mark in this formula means? : : Example: =IF(G40:G52)>0,SUM(G40:G52),"") : -- : clacount Nothing to do with FrontPage, but i...

CString
How can I covert argv[0] to LPCSTR? Hi, Shouldn't CString(argv[0]) do the trick? Sander Verhagen [ Verhagen@nonono.Sander.com ] "Oliver Young" <please@no.spam.com> wrote in message news:er3JuEogDHA.616@TK2MSFTNGP11.phx.gbl... > > How can I covert argv[0] to LPCSTR? > > > Shouldn't CString(argv[0]) do the trick? OK. And how can I convert CString into LPCSTR? I need LPCSTR. I need to convert from char** ( argv[0] ) into LPCSTR. Please, forget CString, and MFC if possible. > How can I covert argv[0] to LPCSTR? LPCSTR...

Native .NET Object Serialization Question
Hello All, I have written a small sample application that serializes an object using the XmlSerializer class. Looks great and I understand how to control some of the serialization processing using attributes. My question is, I need greater control over the use of XML attributes. The XmlSerializer, by default, serializes everything to elements. If I had a simple class such as: public class Person { private string mFirstName = "John"; private string mLastName = "Doe"; public string FirstName { get{ return( mFirstName ); } set{ mFirstName...

Sweep Account Within an Investment Account question?
I can't figure out how I should be recording the monthly dividend paid by a money market fund, when used as the sweep fund, in an Investment Account I have with setup Ameritrade. Ameritrade's OFX server and my M03 client model this as the 'Sweep Account Within an Investment Account' option -- the sweep transactions in and out of the sweep money market fund are not downloaded to my M03 client, only the total quantity of shares is adjusted, and M03 creates an entry of 'Add Shares' in Investment Name for the proper amount. So, in my case the dividends paid by the ...

Question about RPC over HTTP
I have this working 90% but I am getting the exchange server is unavailable message. I can connect to the https:///server.domain.com/rpc successfully and there are no error messages. My question is does my GC have to be running Windows Server 2003? Thanks, Noel Haydon MCSE MCDBA CNE Yes. http://www.microsoft.com/technet/prodtechnol/Exchange/guides/E2k3RPCHTTPDep/5417d8c0-15d4-4520-986c-047d1221ffb2.mspx On Wed, 29 Dec 2004 07:19:05 -0800, "nhaydon" <nhaydon@discussions.microsoft.com> wrote: >I have this working 90% but I am getting the exchange server is unavailable...

how do i add my own style boder to pic. style gallery 4 quick repe
i write several reports a week for work that include photos, to keep the presentation looking clean i like to border them. however the default styles in office i don't like. i can make one i like but it is time consuming, having to right click picture format and then mutiple clicks from there to get it right. is there a way i can do it once and save it to the gallery for quick repeted use simply scan your custom border as a jpg or tif then insert the image in the document. then set its properties so that text appears through the image. -- db·´¯`&...

Access 2007 Question.
In the new Access 2007 can I save an .mdb file as an .mdb file instead of the new format? Jeff- Thanks in advance. Yes. -- -Larry- -- "jeff" <jeff@jeffscomputerservices.com> wrote in message news:0D6C4E48-D356-4905-98B8-6E43CA5C9A20@microsoft.com... > In the new Access 2007 can I save an .mdb file as an .mdb file instead of > the new format? > > Jeff- > > Thanks in advance. > ...

Windows Vista recovery disk making question.
Sorry if this is the wrong place to ask this but I am desperate. The wife has a box with 64bit Vista and someone ran a registery cleaner on it and cleaned the registery so clean that the system would not start windows. It went through the screen that gave the choices for set-up, recovery, etc then the safe, normal, etc start screen and regardless of what chose it would go dark and windows would never start but the activity light would keep flickering showing it was trying to do something. I took it in and repair used the recovery disk to set it back to factory setup!! :-( Que...

IF THEN QUESTION???
Perhaps this has been discussed in the past. I have 30 worksheets in an EXCEL file. The #1 worksheet is the main informational sheet. I'm trying to obtain the formula that would allow me to retrieve a specific data from any of the given worksheet. Example: If J7 is 2, I would like for the system to go to worksheet #2 and obtain the number from cell d39. If tomorrow I change J7 to 25, I would like it to go to worksheet #25 and obtain the number from d39. Your assistance is greatly appreciated Thanks in advance, Mike Have a look at the INDIRECT function to create this formula ...

SIMPLE question re Tent Fold Card from a Newbie
Hi I am TRYING unsuccessfully to do the following Using Publisher 2002 I want to set up my own template to print Happy Easter at the bottom right hand corner of a tent card ... Card is: 20 cm wide and 19 cm high when OPEN ...20 cm wide and 10 cm high When FOLDED. I would like wording Happy Easter at the Bottom of the ront on the right hand side ( to start approx 1cm in from teh right hand edge and cover area of approx 6 cms.. I have managed to do this and print this on an A4 page with crop marks BUT I am wanting to use ready made card blanks... HoW can I get his to work I see under p...

CString (again)
I have a class: class TestClass{ public: TestClass(){}; virtual ~TestClass(){}; BOOL CalcArea(double * pArea); void ReversePoints(); void OrderFromLowest(); std::vector<CoordinateClass> Pts; double OrientationType; BOOL XFlip; BOOL YFlip; double LTilt; double RTilt; double Buffer; int Style; CString Name; }; 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 CString::AssignCopy() How do i fix this? Can't seem to reproduce this ...

Advanced Calendar Question
I would like to set up a Thursday 11AM meeting in Exchange that sends invitations to people on a list Monday at 10AM. The list will contain a number of users, around 15, but I want the meeting to close after 6 people accept the invitation. Is this possible? Thanks. Outlook has nothing like that built in -- neither sending invitations at = a particular time, nor rejecting acceptances.=20 --=20 Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for=20 Administrators, ...

Backup question from MCSE
Hello folks, I had recently appeared for Exchange server exam...I don t know answer for this question....I will be happy if you answer this question The ServiceLevelAgreement for a company requires Failed Exchange Mail store must be online with in 1 hour or less. It also says all email data should be retained for atleast one year. The company uses 2 mail box store named MBX1 and MBX2. Both mailboxes reside in Storage Area Network. MBX 1 is 25 GB. MBX 2 is 22 GB. There is 153 GB available disk space in the storage area network. You back up and restore the company mailat a rate of 12 G...

Odd question about .pst's and journaling..
I have setup journaling on my server and send out to a third party archiving solution and it works like a champ. My question is this, if I have users with older .pst's that I would like to get journaled/archived is there any way to do it? I was trying to figure something out but didn't really see a good way to preserve the integrity of the message as it would most likely have to run through the exchange engine again, be categorized again, stamped with a new header, etc., et., Anyway, if there's anything out there that can take a .pst and get it into my journal I'd love...

Word Search is "too complex" Question
"The Find What text contains a Pattern Match expression which is too complex." What is the rule for being too complex? I can't determine the rule just by playing with it. It's not character limited (other than 255), and it doesn't seem to be "item" limited (like no more than ten []{} pairing). Can you post what the pattern is? George Lee wrote: >"The Find What text contains a Pattern Match expression which is too complex." > >What is the rule for being too complex? I can't determine the rule just by >playing with it...

std::string vs Cstring
Hello, 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 drawbacks? 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, - MR On Thu, 30 Dec 2004 23:25:21 -0000, "Mark Randall" <strike@rapiercom.freeserve.co.uk> wrote: >Hello, > >I have recently been encouraged to utilise String classes, as opposed to C >type cha...

OWA question
Hello - I'm looking into setting up OWA and have a question regarding admin/config/security: Is it possible to provide logging of account access via OWA to users? -- i.e. when a user access their account via OWA and does work off-site and then when they return to the office at a later time, they have a summery available of the messages they sent (w/o digging through "sent items", login history, new appointments made? This may seem odd, but I've been asked to look into it, because users will do extensive work "off site" and want a quick refresher so to speak an...

Recovery Mode #4
I had to delete my exisitng information store and build a new one. Now whenever I open Outlook I get a prompt to connect or workoff line. It says Exchange is in reocvery mode? How can I fix this? Thx ! http://www.microsoft.com/technet/prodtechnol/exchange/guides/UseE2k3RecStorGrps/cd4cae6c-c944-4699-b63f-4e53aab0ed00.mspx -- Ben Winzenz Exchange MVP "TJ" <jpcsinc@insightbb.com> wrote in message news:u8zc5bBJFHA.2936@TK2MSFTNGP15.phx.gbl... >I had to delete my exisitng information store and build a new one. Now > whenever I open Outlook I get a prompt to conne...