473,657 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CString.FormatM essage and CString.Format difference

CString.FormatM essage 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 5232
" Hai Ly Hoang [MT00KSTN]" <Re**********@M ail.com> wrote in message
news:OV******** ******@TK2MSFTN GP10.phx.gbl...
CString.FormatM essage 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::Format Message 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.FormatM essage 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.FormatM essage 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 internationaliz ation 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
8109
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 got the arguments in an ArrayList (though i started withthem in a byte array along the lines of a safe array (numparams,len p1, p1, len p2, p2, ...)). the arguments are always string,but the number of arguments varies from call to call. i'mpretty...
6
3098
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, and sscanf. The "String" class in .NET is completely worthless to me, especially its so called "Format" method. In fact to just, harp on how "lacking" it is to me, in C++.NET, one can NOT do this:
3
688
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 know if cstring is a file and if so, where to find it.
0
2529
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 response XML file from the server. I was trying to use the WinInet MFC classes provided with Visual C++ 2005. The problem is, I have an XML file that I need to send via the post method in the Request to the server. However, I am new to this...
4
11032
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
5254
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 failing on the call to FormatMessage. Cannot marshal 'parameter #7': Pointers cannot reference marshaled structures. Use ByRef instead. how do I pass the argument ByRef and why is managed code involved in this api call? FormatMessage is an...
5
11887
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 message handler code here and/or call default CTime CurTime = CTime::GetCurrentTime(); m_sTime.Format ("%d,%d,%d", CurTime.GetHour(), CurTime.GetMinute(),CurTime.GetSecond());
9
7978
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 following format,
3
4868
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
8319
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8739
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8512
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8612
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2739
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.