473,407 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

CString.FormatMessage and CString.Format difference

CString.FormatMessage and CString.Format has the same parameters and they
seems to have to outcome. However, they coexist !. There must be some subtle
different between they.
Can you tell me the difference ?

Thank a lot
Nov 16 '05 #1
2 5199
" Hai Ly Hoang [MT00KSTN]" <Re**********@Mail.com> wrote in message
news:OV**************@TK2MSFTNGP10.phx.gbl...
CString.FormatMessage and CString.Format has the same parameters and they
seems to have to outcome. However, they coexist !. There must be some subtle different between they.
Can you tell me the difference ?


CString::FormatMessage calls the API FormatMessage using the
FORMAT_MESSAGE_FROM_STRING flag, which I believe uses a special set of
insert escape sequences and allows you to number which insert is used with
which argument.
--
Jeff Partch [VC++ MVP]
Nov 16 '05 #2
> CString.FormatMessage and CString.Format has the same parameters and
they seems to have to outcome. However, they coexist !. There must be
some subtle different between they.
Can you tell me the difference ?


CString.FormatMessage calls the FormatMessage API

The main difference is the fact that numbers can be associated to parameters:
"You just deleted %d files from the %s folder"
will become
"You just deleted %!1!d files from the %!2!s folder"
The %d %s is also supported.

The FormatMessage is better from internationalization perspective.
In some languages the order in the sentence may require changing the order
of the parameters, like for instance some "Yoda speach":
"From the %s folder %d files you just deleted"
or
"From the %!2!s folder %!1!d files you just deleted"

The first variant is not going to work, since this will require you
to change the order of the parameters.
But the ideal is to keep the code language independent.
FormatMessage does it.

--
Mihai
-------------------------
Replace _year_ with _ to get the real email
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Andy Robinson via .NET 247 | last post by:
i'm trying to call FormatMessage and supply some arguments for itto substitute into the message string. i can get it to grab themessage, but i can't convince it to substitute the arguments. i've...
6
by: ATS | last post by:
INF: Has anyone made a CString, sprintf, and sscanf for .NET? Please help, I want to code with PURE .NET (i.e. pure CLR). No MFC, No ATL, no C-Run Time Library. But I want CString, sprintf,...
3
by: Xiaoshen Li | last post by:
Dear All, I saw some people using #include <string.h> some people using #include <cstring> What is the difference between the two? I can find the file string.h at /usr/include. I don't...
0
by: skysurf | last post by:
Hello, I have been placed on a new project involving development for Windows CE using Visual C++. I have to send an XML file via a SSL connection to a server followed by receiving a corresponding...
4
by: Cactus | last post by:
How to convert unsigned char* to CString: I wrote some function: u_char_ =55; u_char_ =66; u_char_ =77; .........=ii...... Convert_to_CS(u_char_);
4
by: Steve Richter | last post by:
I have a C++ forms project that I am adding some unmanaged code to. I have a member function of the Form1 class that returns a String^ holding the text of the last win32 error. The code is...
5
by: ProgMaster | last post by:
I've used the Cstring format to convernt a CTime into a a CString, yet I get an error message, here's the code: void CTimerDlg::OnTimer(UINT_PTR nIDEvent) { CString m_sTime; // TODO: Add your...
9
by: Donos | last post by:
I have a CString with 100 characters. Now i want to make that to 2 lines. For example, CString str = "This is just a test to find out how to break a cstring"; I want this CString in the...
3
by: Carl Forsman | last post by:
how to compare a CString? the following does not seem to work. CString id = PictureEntries.attribute("id").value(); if (id.Compare("2222") == 1){ cout << id << endl; }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.