CString::Format misinterpreting managed String as parameter

I'm mixing managed and unmanaged code in my VC++ projects 
and using CString and String classes at the same time. 
Following code-snippet worked without problems in 
VC++ .NET 2002:
CString strTemp;
String *sManaged = "anything";
strTemp.Format("%s", sManaged );
SetWindowText(strTemp);

The result was, of course, "anything" on the screen.

The same snippet, when compiled under VC++.NET 2003 and 
started in release mode or with Ctrl+F5 in debug mode 
reproduces unreadable output. However, it worls when 
debugging..
Any idea of what's going on here?


0
10/17/2003 10:53:49 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
577 Views

Similar Articles

[PageSpeed] 59

"Vedran Brnicevic" <vbrnicevic@ekobit.hr> schrieb im Newsbeitrag
news:28cc01c3949c$f2338ea0$7d02280a@phx.gbl...
> CString strTemp;
> String *sManaged = "anything";
> strTemp.Format("%s", sManaged );

If you write"%s", Format expects an LPCTSTR and not a String.
The compiler does not interpret the format string, so the string-object is
passed to the format function.



0
10/17/2003 11:54:30 AM
>
>If you write"%s", Format expects an LPCTSTR and not a 
String.
>The compiler does not interpret the format string, so 
the string-object is
>passed to the format function.
>
Thorsten, thanks for the answer, although I was aware of 
that. The thing is, why would smth like this work in 
VC++ .NET 2002 compiler both in debug and release mode 
and NOT in VC++ .NET 2003 compiler? Maybe MS changed 
CString::Format method (I didn't check it) or is it a 
change in compiler or runtime itself?
0
10/20/2003 7:48:02 AM
Reply:

Similar Artilces:

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

User Manager 05-26-06
Hello Newsgroup: Scenario: One DC, one Exchange, one SQL and a seperate server for Microsoft CRM03 all W2K3. Installation straight from the installation guide, CRM seems ok, I can add users to the crmserver via the website, only mistake: in the usermanager there are the added user in the rihgt window, but I cannot add users from the AD, they just don�t show up in the left window the applikation stopps somehow . Thanks for tips Bernd ...

Email reply format in Outlook 2000
When ever I reply to an email, the left edge is not aligned with the original message. It's farther left than the original message. Even if it's a email with many different users replying. All of their replies are lined up on the left edge. Mine does not line up. For example, My reply xxxxxx Original message xxxxxxxxx Instead of the left edge lining up, it is shifted to the left. Any ideas on why this does not work for me but does work for others? Thanks, Jasper "Jasper Recto" <jrecto99@yahoo.com> wrote in message news:eG9hv3FMJHA.3080@TK2...

Query wants parameter value
I have a tools database which been used for over 12 months on a network at work. Just lately I have noticed that on the main tools query, when I open it to do some filtering for locations or tools, I am asked for a parameter. If I just click ok, and not enter anything, the query runs. It didn't used to ask for a parameter, so I don't understand why it is doing so now. This query is used to select the different tool types from a combo box in the main form, so I don't want to change anything that would stop the selection working. The SQL for the said query is below:...

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

Sorting On a custom date format
I have a spreadsheet that I copied from a webpage, that has a date field in a custom format, mmm-dd-yyyy (ie, "Jul-12-2003"). I created a custom format for the column that contains the custom date. When I sort on the column containing the custom date format, Excel does a straight alphabetic sort. Jul-12-2003 comes long after Aug-31-2003, and Dec-01-2002. How can I create a custom date format that I can use for sorting by date? Chuck Paranoia comes from experience - and is not necessarily a bad thing. Hi this works for me. You may try the following - select your data - goto '...

how can i get the date & time format 2010/02/17 12:05 in excel
I would like to share my knowledge by improving & clearing my doubts. Right click the cell>Format cells>Click Custom and enter the below format yyyy/mm/dd hh:mm Now try entering a date in that cell. To enter todays date use the short key Ctrl + ; -- Jacob "NarenSelva" wrote: > I would like to share my knowledge by improving & clearing my doubts. Try =SUMPRODUCT((TEXT(I3:I71,"mmyyyy")="032010")*(H3:H71)) -- Jacob "NarenSelva" wrote: > I would like to share my knowledge by improving & clearing...

Format Painter
Hi, I am using Word with Outlook 2003 but I would like to use Word's Format Painter with Outlook. Is this possible? I do not see it in Outlook and I've tried to customize Outlook's toolbar but do not see the Format Painter anywhere in Outlook. Tony Do you use Word 2003 SudharsonA ----------------------------------------------------------------------- Posted via http://www.mcse.m ----------------------------------------------------------------------- View this thread: http://www.mcse.ms/message413656.htm Yes, I think if I didn't I could then not use Word with Outlook...

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

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

Format string using regular expression
Nov 15, 2009 Hi all I want to format a string using regular expression. Regular Expression "[A-Z/]{4} [0-9]{6} [0-9]{1}" Should format "AAAA1234567" as "AAAA 123456 7" I have tried Regex.Replace Dim mRegEx As Regex Dim mRegString As String = "" mRegEx = New Regex("[A-Z/]{4} [0-9]{6} [0-9]{1}") mRegString = Regex.Replace("AAAA1234567", "[A-Z/]{4} [0-9]{6} [0-9]{1}", "") MsgBox(mRegString) Thanks Mike TI MikeTI wrote: > I want to format ...

Formatting cell questions
1) I copy/paste numbers from Access table into a w/sheet. I try to calculte the sum and I cannot. I format the cells to numbers and still cannot get a total. Why? 2) After copy/paste a green triangle appears on the upper- left corner of the cells. I can't find anything about it. Thx!! Hi Philippe Copy a empty cell Select the cells with text numbers Right click on the selection Choose Paste Special Check Add Ok http://office.microsoft.com/assistance/offhelp/offxp/excel/xlmain10/html/TrianglesInCells.htm Background error checking in Excel 2002 is controlled by Tools, Options, Error C...

Requisition Management -- Requisition Approver Role
I am trying to set up a Hierarchy on Requisition Management, where the Requisition Approver Role has an unlimited approval limit, and user not attached to the Requisition Approver role can approve only up to $500. Does the system require an approver to have the requisition approver role to do any type of approvals? If so, can you copy this role and use the copied role to allow a user limited to the 500 role? ------=_NextPart_0001_40856399 Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi again Christin, I just updated your other Approval Limit / Hierarchy question. I believe th...

Data format
I am trying to run a query between 2 tables based on an account number. The problem I am having is that in one table, the account number is listed as ###-####, where as in the other, the account number is simple a string of 7 numbers. How do I either remove the dash in the first table or run a query that will allow me to match the 2 account numbers even though they are in different forms. I also need to match 2 other tables on account numbers. The problem here is that one field reads, for example, "C 123 4567 2.50 01/10/2007" where as the other reads 1234567. I need to ma...

MS Query: Can't use parameters and totals simultaneously
In MS Query, I can set up a query with parameters (and pass them from Excel) and I can also use the totals function (Max) to retrieve the record with the latest date, but I cannot do both at the same time. This in not an issue in MS Access where you set up your parameter prompts and then add the totals row but there is no totals row in MS Query, only a button to Cycle Through Totals once you select the desired column. When I try to do both, I get the following Message: Invalid column name 'Enter LotCode'. Invalid column name 'Enter ActionCode'. Invalid column name &#...

Formatting Question 02-04-08
I'm need to change the results of an Option Box in a report. In other words, the option box returns 1, 2, or 3 and I would like it to say "Red", "Yellow", or "Green" in the report. Is the code done in the 'Detail' section? Also, I've tried a basic If Then statement but it doesn't like it. Any help would be greatly appreciated!! Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) If QueueStatus = 1 Then QueueStatus = "Green" ElseIf QueueStatus = 2 Then QueueStatus = "Yellow" etc. En...

How do I change Excel format to pdf format?
How do I change Excel format to pdf format? See this post in Google from a couple of days ago for some ideas http://tinyurl.com/4xhtn -- HTH RP (remove nothere from the email address if mailing direct) "William Haskovec" <William Haskovec@discussions.microsoft.com> wrote in message news:C33520CB-289A-4B7E-90E3-C4C9741B62E7@microsoft.com... > How do I change Excel format to pdf format? ...

Format cells to display truncated values?
I would like to display numbers rounded or truncated by 1000 - eg $254,123 would be displayed as $254K. I do not want to change the underlying value, and I do not want to add an additional column with a calculated value Use a custom number format of $0,K -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Mike" <Mike@discussions.microsoft.com> wrote in message news:06C70E35-F87D-4DF7-8494-A46F0E93B507@microsoft.com... >I would like to display numbers rounded or truncated by 1000 - >eg $254,123 > would be displ...

Format Ticket Number
Hi, I want to format the ticket numbers in the following way: dd-mm-yy-N where dd is the day of the creation of the case, mm is the month, yy is the year and N is a correlative that identifies the case. Thanks. Hi there, I would like to be able to do this also. Does anyone know if it cane be done? Cheers, Mark Irene Prieto wrote: > Hi, I want to format the ticket numbers in the following way: > dd-mm-yy-N > where dd is the day of the creation of the case, mm is the month, yy is the > year and N is a correlative that identifies the case. > > Thanks. ...

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. joe On Mon, 30 Jun 2003 04:33:56 -0700, "julych" <julych@msn.com> wrote: >How to covert CString to TCHAR and CString to LPCWSTR? >Where can I read about this? Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http://www.flounder.com 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. Bob Curry BSTR bstrValue; CString szValue; szValue = (LPCWSTR)bstrValue; Sreeram. 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...

convert text "20100315" to date format
Hi, I have some data exported from a system, the date is a text displayed as "20100315" which should read yyyymmdd. I need to convert this text to another date format showing mm/dd/yyyy in text for importing into another system. As the text format yyyymmdd does not contain any "/" or "-" so using text to column will be a difficulty. Please advise how could I handle this. Thanks a lot. Best Regards, Terry =TEXT(DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2)),"mm-dd-yyyy") and copy paste special-values. -- Regards Dave Hawle...

format cell for figures
1. How can I format a cell or range of cells so that the actual figure I entered will get automaticall converted in lakhs e.g. the actual figure 64646587.646664 entered in A1 cell should convert in lakhs as 6464.6587646664. 2. How can I make Excel to move along the cell A1, A2, A3 (press Enter button)then B1, B2, B3 (press Enter button) then C1,C2, C3 and so on.. Ajit -- Knowldege is Power 1. Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range("A1:H10")) Is Nothing Then ...

User Manager -> Adding Users
Has anyone else seen the case where each Active Directory user is listed twice in the Import Users Wizard in the Deployment manager? Rick. ...

office format palette
does anyone know how to fix the strange disappearance of the format=20 palatte on office for mac? it opens entirely off the screen and i'm=20 unable to click on it to move it to an area where it is visible. how = did it=20 get there in the first place? strange! thanks, eilie In article <077101c3af7e$7d3ff730$3101280a@phx.gbl>, "eilie" <anonymous@discussions.microsoft.com> wrote: > does anyone know how to fix the strange disappearance of the format > palatte on office for mac? it opens entirely off the screen and i'm > unable to click on it to mov...