|
As a summary of what the others have written... using printf or its variants, how to prevent a crash if the wrong format specifier is used? The answer is simple:
You can't.
You will have to use IOStreams, or possibly as another person mentioned, boost. Using iostreams is probably the simplest alternate option. Either that, or make sure your format specifiers always match the data types!
Sometimes I feel like I'm a USB printer in a parallel universe.
|
|
|
|
|
Is there a possibility with the CFileDialog Classe to do a select folder dialog box?
Thank's for advance
|
|
|
|
|
ShBrowseForFolder should do the work if you only need folders.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Ok thank's... Can you help me about how can be the code to display it ?
|
|
|
|
|
In the CodeProject's search edit box (just below the title), type ShBrowseForFolder and you'll get a couple of good articles about it.
|
|
|
|
|
How to change the background color selected text from black to diffrent color in richeditctrl.
|
|
|
|
|
See the CHARFORMAT2 structure and the EM_SETCHARFORMAT message in MSDN.
Best regards,
Dominik
CHARFORMAT2
[This is preliminary documentation and subject to change.]
The CHARFORMAT2 structure contains information about character formatting in a rich edit control. CHARFORMAT2 is a rich edit 2.0 extension of the CHARFORMAT structure. Rich edit 2.0 allows you to use either structure with the EM_GETCHARFORMAT and EM_SETCHARFORMAT messages.
typedef struct _charformat2 {
UINT cbSize;
_WPAD _wPad1;
DWORD dwMask;
DWORD dwEffects;
LONG yHeight;
LONG yOffset;
COLORREF crTextColor;
BYTE bCharSet;
BYTE bPitchAndFamily;
WCHAR szFaceName[LF_FACESIZE];
_WPAD _wPad2;
WORD wWeight;
SHORT sSpacing;
COLORREF crBackColor;
LCID lcid;
DWORD dwReserved;
SHORT sStyle;
WORD wKerning;
BYTE bUnderlineType;
BYTE bAnimation;
BYTE bRevAuthor;
BYTE bReserved1;
} CHARFORMAT2;
Members
cbSize
Specifies the size, in bytes, of this structure. Before passing this structure to a rich edit control, set cbSize to the size of the CHARFORMAT or CHARFORMAT2 structure. If cbSize equals the size of a CHARFORMAT structure, the control uses only the CHARFORMAT members.
dwMask
Specifies the parts of the CHARFORMAT2 structure that contain valid information. The dwMask member can be a combination of the values from two sets of bit flags. One set indicates the structure members that are valid. Another set indicates the valid attributes in the dwEffects member.
Set the following values to indicate the valid structure members. Value Meaning
CFM_ANIMATION The bAnimation member is valid.
CFM_BACKCOLOR The crBackColor member is valid.
CFM_CHARSET The bCharSet member is valid.
CFM_COLOR The crTextColor member is valid unless the CFE_AUTOCOLOR flag is set in the dwEffects member.
CFM_FACE The szFaceName member is valid.
CFM_KERNING The wKerning member is valid.
CFM_LCID The lcid member is valid.
CFM_OFFSET The yOffset member is valid.
CFM_REVAUTHOR The bRevAuthor member is valid.
CFM_SIZE The yHeight member is valid.
CFM_SPACING The sSpacing member is valid.
CFM_STYLE The sStyle member is valid.
CFM_UNDERLINETYPE The bUnderlineType member is valid.
CFM_WEIGHT The wWeight member is valid.
Set the following values to indicate the valid attributes of the dwEffects member: Value Meaning
CFM_ALLCAPS The CFE_ALLCAPS value is valid.
CFM_BOLD The CFE_BOLD value is valid.
CFM_COLOR The CFE_AUTOCOLOR value is valid, or the crTextColor member is valid.
CFM_DISABLED The CFE_DISABLED value is valid.
CFM_EMBOSS The CFE_EMBOSS value is valid.
CFM_HIDDEN The CFE_HIDDEN value is valid.
CFM_IMPRINT The CFE_IMPRINT value is valid.
CFM_ITALIC The CFE_ITALIC value is valid.
CFM_LINK The CFE_LINK value is valid.
CFM_OUTLINE The CFE_OUTLINE value is valid.
CFM_PROTECTED The CFE_PROTECTED value is valid.
CFM_REVISED The CFE_REVISION value is valid.
CFM_SHADOW The CFE_SHADOW value is valid.
CFM_SMALLCAPS The CFE_SMALLCAPS value is valid.
CFM_STRIKEOUT The CFE_STRIKEOUT value is valid.
CFM_SUBSCRIPT The CFE_SUBSCRIPT and CFE_SUPERSCRIPT values are valid.
CFM_SUPERSCRIPT Same as CFM_SUBSCRIPT.
CFM_UNDERLINE. The CFE_UNDERLINE value is valid.
dwEffects
A set of bit flags that specify character effects. Some of the flags are included only for compatibility with Microsoft Text Object Model (TOM) interfaces; the rich edit control stores the value but does not use it to display text.
This member can be a combination of the following values. Value Meaning
CFE_ALLCAPS Characters are all capital letters. Does not affect the way the control displays the text.
CFE_AUTOCOLOR The text color is the return value ofGetSysColor (COLOR_WINDOWTEXT). If this flag is set, the crTextColor member is ignored.
CFE_BOLD Characters are bold.
CFE_DELETED Marks the characters as deleted.
CFE_EMBOSS Characters are embossed. Does not affect how the control displays the text.
CFE_HIDDEN Characters are not displayed. Does not affect how the control displays the text.
CFE_IMPRINT Characters are displayed as imprinted characters. Does not affect how the control displays the text.
CFE_ITALIC Characters are italic.
CFE_LINK A rich edit control can send EN_LINK notification messages when it receives mouse messages while the mouse pointer is over text with the CFE_LINK effect.
CFE_OUTLINE Characters are displayed as outlined characters. Does not affect how the control displays the text.
CFE_PROTECTED Characters are protected; an attempt to modify them will cause an EN_PROTECTED notification message.
CFE_REVISION Marks the characters as revised.
CFE_SHADOW Characters are displayed as shadowed characters. Does not affect how the control displays the text.
CFE_SMALLCAPS Characters are in small capital letters. Does not affect how the control displays the text.
CFE_STRIKEOUT Characters are struck out.
CFE_SUBSCRIPT Characters are subscript. The CFE_SUPERSCRIPT and CFE_SUBSCRIPT values are mutually exclusive. For both values, the control automatically calculates an offset and a smaller font size. Alternatively, you can use the yHeight and yOffset members to explicitly specify font size and offset for subscript and superscript characters.
CFE_SUPERSCRIPT Characters are superscript.
CFE_UNDERLINE Characters are underlined.
yHeight
Specifies the character height, in twips. A twip is 1/1440 of an inch, or 1/20 of a printer's point. To use this member, set the CFM_SIZE flag in the dwMask member.
yOffset
Specifies the character offset, in twips, from the baseline. If this member is positive, the character is a superscript; if it is negative, the character is a subscript. To use this member, set the CFM_OFFSET flag in the dwMask member.
crTextColor
Specifies the text color. To use this member, set the CFM_COLOR flag in the dwMask member. This member is ignored if the CFE_AUTOCOLOR character effect is specified.
bCharSet
Specifies the character set value, which can be one of the values specified for the lfCharSet member of theLOGFONT structure. To use this member, set the CFM_CHARSET flag in the dwMask member.
bPitchAndFamily
Specifies the font family and pitch. This member is the same as the lfPitchAndFamily member of the LOGFONT structure.
szFaceName
A null-terminated character array specifying the font face name. To use this member, set the CFM_FACE flag in the dwMask member.
wWeight
Specifies the font weight. This member is the same as the lfWeight member of the LOGFONT structure. To use this member, set the CFM_WEIGHT flag in the dwMask member.
sSpacing
Specifies the horizontal space, in twips, between letters. This value has no effect on the text displayed by a rich edit control; it is included for compatibility with Microsoft Text Object Model (TOM) interfaces. To use this member, set the CFM_SPACING flag in the dwMask member.
crBackColor
Specifies the background color. To use this member, set the CFM_BACKCOLOR flag in the dwMask member.
lcid
Specifies a 32-bit locale identifier that contains a language identifier in the lower word, and a sorting identifier and reserved value in the upper word. This member has no effect on the text displayed by a rich edit control, but spelling and grammar checkers can use it to deal with language-dependent problems. You can use theMAKELCID macro to create an LCID value. To use this member, set the CFM_LCID flag in the dwMask member.
dwReserved
Reserved; must be zero.
sStyle
Specifies a style handle. This value has no effect on the text displayed by a rich edit control; it is included for compatibility with Microsoft Text Object Model (TOM) interfaces. To use this member, set the CFM_STYLE flag in the dwMask member.
wKerning
Specifies the twip size above which to kern the character. This value has no effect on the text displayed by a rich edit control; it is included for compatibility with TOM interfaces. To use this member, set the CFM_KERNING flag in the dwMask member.
bUnderlineType
Specifies the underline type. To use this member, set the CFM_UNDERLINETYPE flag in the dwMask member. This member can be one of the following values. Value Meaning
CFU_CF1UNDERLINE Map CHARFORMAT's bit underline to CHARFORMAT2.
CFU_INVERT For IME composition fake a selection.
CFU_UNDERLINE Solid underline.
CFU_UNDERLINEDOTTED Dotted underlined text. The rich edit control displays the text with a solid underline.
CFU_UNDERLINEDOUBLE Double-underlined text. The rich edit control displays the text with a solid underline.
CFU_UNDERLINENONE No underline. This is the default.
CFU_UNDERLINEWORD Underline words only. The rich edit control displays the text with a solid underline.
bAnimation
Specifies the text animation. This value has no effect on the text displayed by a rich edit control; it is included for compatibility with TOM interfaces. To use this member, set the CFM_ANIMATION flag in the dwMask member.
bRevAuthor
Specifies an index that identifies the author making a revision. The rich edit control uses different text colors for each different author index. To use this member, set the CFM_REVAUTHOR flag in the dwMask member.
bReserved1
Reserved; must be zero.
QuickInfo
Windows NT: Requires version 4.0 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in richedit.h.
Unicode: Defined as Unicode and ANSI structures.
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
I'm trying to make a listview whith these properties:
when an item is inserted, the background is colored. you can select the "new" items and "clear" them, which recolors the item background to white. I've been reading posts and articles on doing this via CustomDraw or OwnerDraw, but i'm still confused about how to tell those functions which selected row(s) to change, and havnee't had luck getting them to jsut plain work either. I've been searchign through msdn, codeguru and code project for a solution, but so far I havne't gotten one.
I'm also implementing a custom listview for sorting, and class for dialog resize. Perhaps this is part of my problem, perhaps not.
If anyone has a custom ListView, or sample code, can you please point me in the right direction
Thanks for any help.
|
|
|
|
|
Is it possible to split the mainframe of a mDI application even if no document is opened ?
Thanks for your reply
Erick Girard
|
|
|
|
|
I dunno for sure offhand - try to Overload OnCreateClient in MainFrm instead of the Child frame. You may not be able to let the DocumentTemplate manage it, you would most likely have to manage the details yourself - after which it may not be considered an MDI app.
|
|
|
|
|
thanks for your reply, but it seems it is more complicated. Overloading OnCreateClient in MainFrm doesn't work.
|
|
|
|
|
Hi
are HINTERNET handles safe for multithreading ?
can i pass handles returned from InternetConnect or InternetOpen to many threads ? (in the CreateThread API)
what about windows handles in general ?
thank you in advance
|
|
|
|
|
I am parsing a file where each record is separeated by comma.
I am getting a minor problem here.
I am getting one extra empty field.
Here is the code.Pls help
CStdioFile myfile;
CString strRecord;
try
{
myfile.Open("C:\\YKUTANOOR\\VC++\\config.txt", CFile::modeRead );
myfile.SeekToBegin();
while(myfile.ReadString(strRecord)!=NULL)
{
CString resToken;
CString msgPromt;
int curPos= 0;
int countFields =0;
resToken= strRecord.Tokenize(",",curPos);
CString temp = resToken;
AfxMessageBox(resToken);
while (resToken != "")
{
resToken= strRecord.Tokenize(",",curPos);
}
}
}catch()
{
}
|
|
|
|
|
Do an additional test
CStdioFile myfile;
CString strRecord;
try
{
myfile.Open("C:\\YKUTANOOR\\VC++\\config.txt", CFile::modeRead );
myfile.SeekToBegin();
while(myfile.ReadString(strRecord)!=NULL)
{
CString resToken;
CString msgPromt;
int curPos= 0;
int countFields =0;
resToken= strRecord.Tokenize(",",curPos);
if(!resToken.IsEmpty())
{
CString temp = resToken;
AfxMessageBox(resToken);
while (resToken != "")
{
resToken= strRecord.Tokenize(",",curPos);
}
}
}catch()
{
}
}
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thnx for the modified code.
But if u observe that the last message box(after fields are shown) are coming empty)
I need to stop this.
If u try ...
take a file LIKE this and use the above code.
1000,Y,1
2000,N,1
3000,N,1
4000,N,2
|
|
|
|
|
This works:
CStdioFile myfile;
CString strRecord;
myfile.Open("C:\\config.txt", CFile::modeRead );
myfile.SeekToBegin();
while(myfile.ReadString(strRecord)!=NULL)
{
CString resToken;
CString msgPromt;
int curPos= 0;
int countFields =0;
while((curPos= strRecord.Find(",")) != -1)
{
resToken = strRecord.Left (curPos);
AfxMessageBox(resToken);
strRecord = strRecord.Mid (curPos + 1);
}
AfxMessageBox(strRecord);
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Retrieve your strings inside the while loop and just before the call to the Tokenize function.
int Position = 0;<br />
CString Token(strRecord.Tokenize(_T(","), Position));<br />
<br />
while (!Token.IsEmpty())<br />
{<br />
TRACE(_T("[%s]\n"), Token);<br />
Token = strRecord.Tokenize(_T(","), Position);<br />
}
With your example file, then I get:
[1000]
[Y]
[1]
[2000]
[N]
[1]
[3000]
[N]
[1]
[4000]
[N]
[2]
|
|
|
|
|
I have used CMapStringToString where I have to map a string to another string.
I want TO KNOW how different CMapStringToString is from Cache Memory.
Because I am reading from the file in read mode and storing all the contents in
CMapStringToString.
Or Do I have to write another program to cache it.
Pls clarify
|
|
|
|
|
Are you referring to the hashing that goes on automatically in the cache?
|
|
|
|
|
Yes,I am referring to the cache.
|
|
|
|
|
Well that clears it up - NOT
|
|
|
|
|
My idea is read from a file and load in to memory as my app prefers frequent searching.
I am doing it by taking CMapStringToString.
What my question "Is cache memory different from storing in a hash table like CMapStringToString ?
|
|
|
|
|
But then the question is, what "cache memory" are you refering to? MFC or C++ in general don't implement a cache. Are you refering to a hardware cache? Internet cache?
--
Joel Lucsy
|
|
|
|
|
hello all,
Is there any Win32 API avaliable to add a new button to IE toolbar. And i had previously checked the Codeprojects' WTL Toolbands and deskbands.
if there is any api plz say. it will be greatfull.
Thank u.
ComputerNewton
|
|
|
|
|
I believe what you are looking for is a BHO, Browser Helper Object. This is implemented using COM. So, no, no direct Win32 API.
--
Joel Lucsy
|
|
|
|