When we convert a module done in lower versions(ie: VC6 to VS2003) to VS2005 or above in C++, there's a possibility of an error like this. This occurs because of the difference in return types used in older versions of Visual Studio. To make it run, you need to change the return-type UINT to an LRESULT and things should be fine.
UINT CStaticLink::OnNcHitTest(CPoint point)
{
return HTCLIENT;
}
Replace UINT with LRESULT :)
Wednesday, October 28, 2009
Tuesday, March 17, 2009
CCommandLineInfo
CCommandLineInfo is a MFC class that can be used to parse the command line of the executable. This is a very useful one and is easy to impliment.
If you create a MFC application with the application wizard you will get the lines CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
in the app class´s InitInstance method.
ParseCommandLine will call ParseParam in CCommandLineInfo. To parse your own command line params, derive a class from CCommandLineInfo and override ParseParam method:
void CTestCommandLineInfo::ParseParam( LPCTSTR lpszParam, BOOL bFlag, BOOL bLast ){
if(bFlag)
{
if(lpszParam .strCompareNoCase('sumtext')
{
//some code to deal with the string value associated with lpszParam )
}
state = _0;
}
}
CCommandLineInfo::ParseParam( lpszParam, bFlag, bLast );
}
If you need to parse flags only, you do not need to invent a state system. Then it is enough to ask for bFlag and set some static variable for the parameter given in lpszParam. But if you want to handle parameters with values, you need to set a private state variable if the parameter name is parsed and set the appropriate static variable if the actual value is parsed .
If you create a MFC application with the application wizard you will get the lines CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
in the app class´s InitInstance method.
ParseCommandLine will call ParseParam in CCommandLineInfo. To parse your own command line params, derive a class from CCommandLineInfo and override ParseParam method:
void CTestCommandLineInfo::ParseParam( LPCTSTR lpszParam, BOOL bFlag, BOOL bLast ){
if(bFlag)
{
if(lpszParam .strCompareNoCase('sumtext')
{
//some code to deal with the string value associated with lpszParam )
}
state = _0;
}
}
CCommandLineInfo::ParseParam( lpszParam, bFlag, bLast );
}
If you need to parse flags only, you do not need to invent a state system. Then it is enough to ask for bFlag and set some static variable for the parameter given in lpszParam. But if you want to handle parameters with values, you need to set a private state variable if the parameter name is parsed and set the appropriate static variable if the actual value is parsed .
Labels:
CCommandlineInfo,
command line argument,
Praveen Raj,
using,
vc++
Subscribe to:
Posts (Atom)
