|
completly or partially ?
This signature was proudly tested on animals.
|
|
|
|
|
Maximilien wrote: other than that, I don't see much use.
That is wrong, so are you partially or completely wrong? You will have to answer that for yourself.
I'm outa here, have a great weekend!
|
|
|
|
|
Well, I caved myself in.
This signature was proudly tested on animals.
|
|
|
|
|
Hi all,
i tried of a calendar control always focusing on month
but if we change the year/date, while getting back focus again on year/date
but actually i need the focus on month
i tried using SetCaretPos(); method but i didn't get the result
is there any other way to handle it
Thanks in advance,
Jeeva
|
|
|
|
|
Hi,
In my apllication , iam having a propertypage
In that I hide the Help,Ok,CANCEL and APPLY Button. (GetDlgItem(ID_APPLY_NOW)->ShowWindow(SW_HIDE); …)
But I cant do like this in “x” close button ,which was in propertypage TitleBar Right.
Through Net I got the help for Enable the “x” button , but iwant to hide it.
Give u’r suggestion for remove the “x” close button from property page.
Thanks in Advanc
Regards
shakumar
shakumar
|
|
|
|
|
Try removing the WS_SYSMENU[^] style from the window you want to hide the 'X' of using CWnd::ModifyStyle[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Thanks for u'r Reply
I tryied like this
PreCreateWindow(CREATESTRUCT& cs)
{
if ( !CSampleDlg::PreCreateWindow(cs) )
return FALSE;
// Remove the system menu style bit from the window
cs.style &= ~WS_SYSMENU;
return TRUE;
}
then also it is not remove the "X" Close Button.
Give any suggestion on this.
shakumar
|
|
|
|
|
Are you sure your PreCreateWindow actually gets called? Also you can try using ModifyStyle in PreSubclassWindow AFTER you have called the 'super version' or right after you have created your window using CreateWindow (if you did)...where did you hide the buttons you wanted to get rid of? Also, are you sure you are trying to modify the style of the correct window?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I am attempting to do the following:
template <class T>
class Measure {
public:
double Value;
T::UnitList Units;
virtual const T& Convert(const T::UnitList destUnits) = 0;
};
class Length : public Measure<Length> {
public:
enum UnitList {
METERS,
MILES,
};
}; Now, when I try to compile, I am getting the message,
"warning C4346: 'T::UnitList': dependent name is not a type"
which leads to the following error:
"error C2146: syntax error : missing ';' before identifier 'Units'"
I am getting all kinds of warnings/errors like this every time I refer to T::UnitList, which I believe are due to the fact that the compiler is attempting to resolve the template parameter prior to declaring the class. More specifically, I think that once the compiler begins interpreting "public Unit<length>", all that it knows about "Length" is that it is a class. The fact that the Length class contains an enum called "UnitList" is unknown to the compiler (I think). My question is, how can I go about strongly typing the "Units" variable to T::UnitList (I'm trying to avoid accepting the ambiguous int or unsigned int types)? Any help is greatly appreciated.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Replace
T::UnitList Units;
with
typename T::UnitList Units;
You need to tell the compiler that T::UnitList is actually the name of a type.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you for your quick reply. That did resolve the errors/warnings I mentioned in my initial post, but I am still getting exceptions related to the underlying problem. The new exception is:
"error C2039: 'UnitList' : is not a member of 'Length'"
I believe this is related to the order in which the code is compiled, as mentioned in my original post, but am not entirely certain.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
I think the g++ error messages are clearer - given a file b.cpp:
template <class T>
class Measure
{
public:
double Value;
typename T::UnitList Units;
virtual const T& Convert(const typename T::UnitList destUnits) = 0;
};
class Length : public Measure<Length>
{
public:
enum UnitList
{
METERS,
MILES,
};
virtual const Length& Convert(const UnitList destUnits)
{
}
};
I get these error messages
b.cpp: In instantiation of ‘Measure<Length>’:
b.cpp:12: instantiated from here
b.cpp:5: error: invalid use of undefined type ‘class Length’
b.cpp:12: error: forward declaration of ‘class Length’
b.cpp:7: error: invalid use of undefined type ‘class Length’
b.cpp:12: error: forward declaration of ‘class Length’
It's trying to instantiate the base class before defining Length . But that requires the compiler to have a definition for Length::UnitList ...but it can't have that until Length is defined. Which can't happen until Measure<Length> is defined!
So yeah, that's not gonna work!
You can use the CRTP[^] idiom for static polymorphism, like this - Measure will call the Flip method of the template parameter. It's really useful for implementing mix-ins[^], as used by ATL and WTL.
template <class T>
class Measure
{
public:
double Value;
virtual const T& Convert(const int destUnits)
{
static_cast<T*>(this)->Flip();
}
};
class Length : public Measure<Length>
{
public:
enum UnitList
{
METERS,
MILES,
};
virtual const Length& Convert(const UnitList destUnits)
{
Measure<Length>::Convert(1);
}
void Flip() {}
};
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Once again, thank you for your help. Your responses inspired the following solution, although it is not as clean of a solution as I would like:
template <class Derived, class UnitType>
class Measure {
public:
double Value;
UnitType Units;
virtual const Derived& Convert(const UnitType destUnits) = 0;
};
class LengthUnits {
public:
enum List {
METERS,
MILES,
};
};
class Length : public Measure<Length, LengthUnits> {
public:
};
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
One other thing...are you deriving classes from Length? If not, you're probably better off using static polymorphism (like I showed in my earlier e-mail) than dynamic polymorphism (virtual methods) if only because it could be a tad more efficient.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for the advice... I never knew there was an efficiency difference between virtual vs. static casting methods.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
I've got a code segment below that converts the block of chars read in from an RSS XML file and converts it to the unicode equivalent using a code page (the code page ID is determined beforehand by scanning for the the encoding ID in the XML).
Sometimes it works, sometimes it crashes the application. I'm using the buffer requirement returned by 'MultiByteToWideChar' to allocate the buffer required (+1 because the block of chars I'm passing does not include the 0 terminator). What's really odd is that on small strings it works fine, but on a 216 character string it crashes. If I extend the buffer allocation by 1 then it works all the time. I should not have to kludge buffer allocation to make things work.
int nSizeReq = MultiByteToWideChar(m_nCPID,0,(const char* m_pChars,nBlockLength,0,0);
TCHAR* pszConverted = new TCHAR[nSizeReq+1];
_tcsnset(pszConverted,0,nSizeReq+1);
MultiByteToWideChar(m_nCPID, 0, (const char*)m_pChars,nBlockLength, pszConverted, nSizeReq);
//up to here it always works, but the next step crashes because pszConverted has damage
//past its memory allocation
CString strConverted = pszConverted
Any ideas why this could be happening?
ps. it runs just great in debug, and if I run it in release mode whilst in visual studio it also works. Run the release by itself and *boom*
[edit]
Coded in C++ (MFC application) using Visual Studio 2008
Unicode is defined
Testing on Vista.
modified on Friday, March 13, 2009 10:51 AM
|
|
|
|
|
First thing I notice is the code you posted does not check the return value of MultiByteToWideChar. Therefore your next operations are running on blind faith. This is not usually considered a Software Development Best Practice.
|
|
|
|
|
Yep, you make a good point, I updated the code to check the value:
int nSizeReq = MultiByteToWideChar(m_nCPID,0,(const char* m_pChars,nBlockLength,0,0);
TCHAR* pszConverted = new TCHAR[nSizeReq+1];
_tcsnset(pszConverted,0,nSizeReq+1);
int nConverted = MultiByteToWideChar(m_nCPID, 0, (const char*)m_pChars,nBlockLength, pszConverted, nSizeReq);
int nTest = wcslen(pszConverted);
the results: nConverted = 214. nSizeReq = 214, but nTest = 206. Weird.
|
|
|
|
|
RichardBrock wrote: Weird.
What are you compiling to?
Try
int nTest = _tcslen(pszConverted);
|
|
|
|
|
The project outputs a 32 bit Windows executable (target platforms are XP and Vista), MFC linked is static.
I tried _tcslen as you suggested, same result. I'm testing from a live RSS feed, so the news item length has changed but here's the latest output from my outputdebugstring placed just after the 2nd MultiByteToWideChar call.
'return value = 140 (wcslen is 308) nSizeReq = 140 nBlockLength = 140'
so you can see the function call returns 140, the buffer allocated was 140 and the block length read from the file is 140. But the converted string is 308 in length, obviously overruning memory allocated to it.
Do you think compiler optimization could be causing a problem? I'm compiling with 'Enable link-time code generation (/GL)'.
Btw, a previous call for the preceding news item yields:
'return value = 121 (wcslen is 121) nSizeReq = 121 nBlockLength = 121'
|
|
|
|
|
You did not answer my question, I guess I didn't make it clear but I assumed you had some knowledge about what you were doing.
led mike wrote: What are you compiling to?
Since the subject of this discussion is character sets that's what that question is about. Are you compiling to _UNICODE or what?
You should check out the example of MultiByteToWideChar in this article[^]
Try to look for the differences in your code, there an obvious difference. Next I strongly urge you to study this subject thoroughly before you attempt your implementation. My experience is that working with conversion requires a sound understanding of this subject. I believe there are great articles here on Code Project that cover this topic well.
|
|
|
|
|
How are you calculating this nBlockLength?
prvn
|
|
|
|
|
I have a file open using CreateFile, I use ReadFile to locate the start and end tags in the XML file for the field, e.g. <description>.....</description> (Internet RSS news feed in Arabic). The nBlockLength indicates the number of characters extracted between > and <, the m_pChars buffer holds the actual character data.
|
|
|
|
|
Hi,
I want to know how can i get the font of system and modify it with an other and apply it again.
the problem that the control is related to system font (ActiveX)specialy a WebBrowser.
So, how can you help me please ?
|
|
|
|
|
Try something like:
LOGFONT logFont;
my_control.GetFont()->GetLogFont(&logFont);
_tcscpy(logFont.lfFaceName, _T("the_name_of_my_favourite_font"));
my_controls_font.CreateFontIndirect(&logFont);
my_control.SetFont(&my_controls_font);
Of course, add nice error checks and such as you like.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|