|
Actually This is I am using as testing program.
But the structure in my actual program is predefined.
that is
typedef struct _charformat
{
UINT cbSize;
DWORD dwMask;
DWORD dwEffects;
LONG yHeight;
LONG yOffset;
COLORREF crTextColor;
BYTE bCharSet;
BYTE bPitchAndFamily;
char szFaceName[LF_FACESIZE];
} CHARFORMATA;
I am using an instance for that typedef.
Thanks for reply.
|
|
|
|
|
-change char szFaceName[32] to TCHAR szFaceName[32];;
|
|
|
|
|
I know that. Please check my previous reply.
That was predefined. Just here I wrote sample program.
Any way. Thanks for your reply.
|
|
|
|
|
If you want to write code that can be compiled both in MBCS and Unicode you need to:
- Define all your char arrays as TCHAR arrays (e.g., TCHAR szFaceName[32])
- Write all char and string literals using _T macro (e.g., _T("Wingdings 3"))
Additionally, for the Unicode build, you need to:
- Define both UNICODE and _UNICODE
- Remove the define for MBCS
- Set in the linker settings wWinMainCRTStartup as the entry point
That being said, the struct ABCAAA is actually the CHARFORMAT structure, right? Take a look at richedit.h in the VS include files. You'll see a CHARFORMATA (defining szFaceName as a char[]), and a CHARFORMATW (defining szFaceName as a WCHAR[]). Then, you'll see CHARFORMAT defined as follows:
#if (_RICHEDIT_VER >= 0x0200)
#ifdef UNICODE
#define CHARFORMAT CHARFORMATW
#else
#define CHARFORMAT CHARFORMATA
#endif // UNICODE
#else
#define CHARFORMAT CHARFORMATA
#endif // _RICHEDIT_VER >= 0x0200
So, it seems that CHARFORMATA is used even for Unicode builds, unless you also define _RICHEDIT_VER to 0x200 or more. See the following link for info about Rich Edit controls and their versions:
About Rich Edit Controls[^]
Then, if you are going to target 1.0 version, you'll keep using the CHARFORMATA struct, so your sample code should be written as follows:
void CAbcDlg::OnMyButton()
{
CHARFORMAT cf;
int nMaxNameLen = (sizeof(cf.szFaceName)/sizeof(cf.szFaceName[0]))-1;
strncpy(cf.szFaceName, "Wingdings 3", nMaxNameLen);
cf.szFaceName[nMaxNameLen] = '\0';
AfxMessageBox(A2T(cf.szFaceName));
}
This code should work in either MBCS or Unicode builds, for RichEdit version 1.0.
For RichEdit version 2.0 and higher, the code should be:
void CAbcDlg::OnMyButton()
{
CHARFORMAT cf;
int nMaxNameLen = (sizeof(cf.szFaceName)/sizeof(cf.szFaceName[0]))-1;
lstrcpyn(cf.szFaceName, _T("Wingdings 3"), nMaxNameLen);
cf.szFaceName[nMaxNameLen] = _T('\0');
AfxMessageBox(cf.szFaceName);
}
and that should again work for either Unicode or MBCS builds.
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
i am getting error in following code please help
see the function below
i get date as "Sep-05-2005" which i initially read in smonth
after that take from it smonth as Sep and using switch nmonth as 9
now after taking month and removing it from string -05-2005 is left then
comes day
nday=05
now 05-2005 is left
but when 05 is removed instead of -2005 only -20 is left
this error occurs when first time this function is called on exit
for 2, 3 or ___ no error occurs we get complete -2005
i find this in debug mode
BOOL CXmlData::FnCheckForValidDates(CString szEndDate)
{
//Get Current date
CTime TodayDate=CTime::GetCurrentTime();
int nYear,nMonth,nDay;
CString sMonth;
//date format MM-DD-YYYY
//Extract Month
sMonth=(szEndDate.Left(szEndDate.Find('-')));
//remove the month from String
szEndDate.Replace(szEndDate.Left(szEndDate.Find('-')),""); //-05-2005
//Replace Extra '-'
szEndDate.TrimLeft('-');
//code to get int month from string smonth
if(sMonth == "Jan" )
{
nMonth=1;
}
else if(sMonth == "Feb" )
{
nMonth=2;
}
else if(sMonth == "Mar" )
{
nMonth=3;
}
else if(sMonth == "Apr" )
{
nMonth=4;
}
else if(sMonth == "May" )
{
nMonth=5;
}
else if(sMonth == "Jun" )
{
nMonth=6;
}
else if(sMonth == "Jul" )
{
nMonth=7;
}
else if(sMonth == "Aug" )
{
nMonth=8;
}
else if(sMonth == "Sep" )
{
nMonth=9;
}
else if(sMonth == "Oct" )
{
nMonth=10;
}
else if(sMonth == "Nov" )
{
nMonth=11;
}
else if(sMonth== "Dec")
{
nMonth=12;
}
//Extract Day
nDay=_ttoi(szEndDate.Left(szEndDate.Find('-')));
//remove the day from String//05-2005
szEndDate.Replace(szEndDate.Left(szEndDate.Find('-')),""); but here -20 is left
//Replace Extra '-'
szEndDate.TrimLeft('-');
//Extract year
nYear=_ttoi(szEndDate);
//Expiry date
CTime ExpiryDate(nYear,nMonth,nDay,0,0,0);
//comparison Routine
//first Check year
//comparing todays date with expirey date
if(TodayDate>ExpiryDate)
return FALSE;
#ifdef MYDEBUG
AfxOutputDebugString("Returning True");
#endif
return TRUE;
}
Ankit Aneja
|
|
|
|
|
|
thanks done
but i do not understand why was it giving error that way
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
Ankit Aneja wrote:
i do not understand why was it giving error that way
Because there are two 05 in the string
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
thanks ,very clever
but this was not my code
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
Ankit Aneja wrote:
this was not my code
then whose code is this
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
it is not good to tell person name publiculy because that
person is having good reputation on code project
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
In programming world ppl do not go by their reputation of a good person in codeproject, If s/he writes bad code it means s/he writes bad code plus the ppl in codeproject dont take programming mistakes too personally.
Your comments probably help the dev to understand his mistake.
-prakash
|
|
|
|
|
Hello everybody,
Does anybody know how I can use the method ExecWB of the WebBrowser control for opening a file on the local machine:
ExecWB(OLECMDID_OPEN, OLECMDEXECOPT_DODEFAULT, ?, ?);
I don't know the use of parameters 3 and 4.
I Also don't want to use Navigate method because of the download prompting.
thanks in advance
Roozbeh.
-- modified at 4:14 Saturday 3rd September, 2005
|
|
|
|
|
I wanna to know about this syntax
istream& getline(char *buffer, int length, char terminal_char);
& operator before getline ,what it represent?
Or sometime instead of & there is * also.
What it represent?
Rupal
|
|
|
|
|
hum, i think you need some basic notions about C++.
in such declaration syntax, operator & represent the declaration of a reference, and operator * represent the declaration of a pointer...
in you example, getline get as paramater a pointer to char (buffer), an int (length) and a char (terminal_char). it returns then a reference to an istream instance.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
|
return back the reference of an object
|
|
|
|
|
Rupali Sarda wrote:
What it represent?
Please don't mind, you need read this book, it's contain all the basic concept of c++ Plus it free online http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
hello
I have a dialog based application where i am popping a modeless dialog from the OnInitDialog() of this dialog.I alos have a menu in the parent dialog.What i want is that if user clicks on red cross button and calls OnClose()(WM_CLOSE)then only he should be able to create another modeless dialog through menu.How should i override the OnClose and menu handler.I tried to set a variable of my parent dialog in OnClose of modeless dialog and then check it in OnMenu(0 handler but this is not working.Can somebody expalin to me what happens when we click on red cross button of modeless dialog.Do i need to call destroyWindow()?
please help
thanks in advance
|
|
|
|
|
sayup wrote:
How should i override the OnClose and menu handler.I tried to set a variable of my parent dialog in OnClose of modeless dialog and then check it in OnMenu(0 handler but this is not working.
You have to notify the Parent by sending Some Sort of Custom Window Messages! look for WM_APP and WM_USER messages in your locla copy of MSDN
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
When I compiled my project,I got the error messages below:
<br />
fatal error C1001: INTERNAL COMPILER ERROR<br />
(compiler file 'msc1.cpp', line 1786) <br />
Please choose the Technical Support command on the Visual C++ <br />
Help menu, or open the Technical Support help file for more information<br />
I have checked this error number in MSDN,but I can't solve this problem.
So can anybody here do me a favor?
Appreciate.
Oh,by the way,my environment is VC6.0.
Never understand
radical version!
|
|
|
|
|
The compiler cannot generate correct code for a construct, probably due the combination of an expression and an optimization option. Try removing one or more optimization options and recompiling the function containing the line indicated in the error message.
|
|
|
|
|
ILoveCS wrote:
ILoveCS
as your name suggest you love C-Sharp, what are you doing with VC
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
In your eyes,"CS"just means C sharp.
In fact,it can have many kinds of explanation.
For example,Computer Science.
I love C Sharp.
And I love c++ too.
C sharp and C++ don't mind sharing my loves with each other.
hei,guy,maybe you can give me some advice on my problem?
Never understand
radical version!
|
|
|
|