Click here to Skip to main content
16,018,202 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
PinnedHOW TO ANSWER A QUESTION PinPopular
Chris Maunder12-Jul-09 22:37
cofounderChris Maunder12-Jul-09 22:37 
PinnedHOW TO ASK A QUESTION PinPopular
Chris Maunder12-Feb-09 17:19
cofounderChris Maunder12-Feb-09 17:19 
QuestionHow to get the title of CPropertyPage ? Pin
Eugene Pustovoyt6-Oct-24 9:10
Eugene Pustovoyt6-Oct-24 9:10 
AnswerRe: How to get the title of CPropertyPage ? Pin
Victor Nijegorodov6-Oct-24 21:57
Victor Nijegorodov6-Oct-24 21:57 
GeneralRe: How to get the title of CPropertyPage ? Pin
Eugene Pustovoyt7-Oct-24 1:57
Eugene Pustovoyt7-Oct-24 1:57 
GeneralRe: How to get the title of CPropertyPage ? Pin
Victor Nijegorodov7-Oct-24 2:55
Victor Nijegorodov7-Oct-24 2:55 
GeneralRe: How to get the title of CPropertyPage ? Pin
David Crow7-Oct-24 7:14
David Crow7-Oct-24 7:14 
Questionbuild4ARM Pin
wa!724-Sep-24 18:05
wa!724-Sep-24 18:05 
QuestionRe: build4ARM Pin
CPallini24-Sep-24 19:52
mveCPallini24-Sep-24 19:52 
AnswerRe: build4ARM Pin
wa!725-Sep-24 4:08
wa!725-Sep-24 4:08 
QuestionReading HID Bluetooth devices' buffer on Win32 Pin
GIANISM_JUSTICE22-Sep-24 4:04
GIANISM_JUSTICE22-Sep-24 4:04 
QuestionGUI Freezes randomly /MFC /C++ Pin
Zishan Ud78720-Sep-24 8:56
Zishan Ud78720-Sep-24 8:56 
AnswerRe: GUI Freezes randomly /MFC /C++ Pin
Richard Andrew x6420-Sep-24 10:07
professionalRichard Andrew x6420-Sep-24 10:07 
GeneralRe: GUI Freezes randomly /MFC /C++ Pin
jeron120-Sep-24 10:47
jeron120-Sep-24 10:47 
GeneralRe: GUI Freezes randomly /MFC /C++ Pin
Zishan Ud78720-Sep-24 23:11
Zishan Ud78720-Sep-24 23:11 
GeneralRe: GUI Freezes randomly /MFC /C++ Pin
Zishan Ud78720-Sep-24 23:16
Zishan Ud78720-Sep-24 23:16 
AnswerRe: GUI Freezes randomly /MFC /C++ Pin
Dave Kreskowiak20-Sep-24 13:53
mveDave Kreskowiak20-Sep-24 13:53 
QuestionRe: GUI Freezes randomly /MFC /C++ Pin
David Crow23-Sep-24 2:05
David Crow23-Sep-24 2:05 
QuestionCharacter set Pin
Calin Negru12-Sep-24 23:03
Calin Negru12-Sep-24 23:03 
AnswerRe: Character set Pin
CPallini12-Sep-24 23:19
mveCPallini12-Sep-24 23:19 
GeneralRe: Character set Pin
Calin Negru12-Sep-24 23:46
Calin Negru12-Sep-24 23:46 
GeneralRe: Character set Pin
Mircea Neacsu13-Sep-24 0:06
Mircea Neacsu13-Sep-24 0:06 
GeneralRe: Character set Pin
trønderen13-Sep-24 9:33
trønderen13-Sep-24 9:33 
GeneralRe: Character set Pin
Mircea Neacsu13-Sep-24 17:17
Mircea Neacsu13-Sep-24 17:17 
GeneralRe: Character set Pin
trønderen14-Sep-24 7:25
trønderen14-Sep-24 7:25 
Mircea Neacsu wrote:
Quote:So you cannot deduce the number of print positions from the length of the UTF-16 string - not even after considering control characters.
Why would that be interesting from a programming point of view?
If you code anything that is to be presented to a user, you will frequently have to relate to the physical space available, whether a 16 char single line display on an embedded device, or a field in a form on a desktop PC.

If you just send it the entire string, leaving to the display unit to discard what won't fit, for one: You may upset the display device. Second: Maybe it is obvious to you that the first 'n' characters are displayed, but don't trust it: Many small-display devices display a rolling text, so the last 'n' characters are displayed. In either case, your customer may be less than satisfied with your solution. If you present floating point values with the number of decimal positions less than the internal precision (which is almost always the case), you may want to consider rounding the last displayed digit - don't expect a pure UI module to have any concept of floating point rounding! (Besides, it may want the values as separate digits, not as an FP value.)

Even if a value is not presented to a human user, it may be exchanged with another software module in textual format. The receiver may provide a limited size text buffer, or may require a minimum number of (valid) characters (possibly converted to 7-bit ASCII with zero parity, if it is an old *nix application!)

If your software has nothing at all to do with a user interface, you may still be handling data that you handle over to some software doing the UI. This software may put restrictions on the lengths of both prompt strings and data values. You may have to make decisions about what to display, either by some form of abbreviation (Initial only, ellipsis, ...), leaving (semi-)optional parts out, etc.

I certainly can think of specific programming tasks that are completely unrelated to character string length. But to me, those are special cases. The main rule is that the printable length, both in number of positions and the typographical length (when using variable width fonts) can be essential, and you should be prepared to handle it. You ask a Unicode handling library function for the number of positions when you need it. You ask a UI typography library function for the typographical length if that is what you need e.g. to shorten the string to fit into a field.
Religious freedom is the freedom to say that two plus two make five.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.