//DWORD to CString
DWORD dwNumber = 1234;
CString csNumber;
csNumber.Format("%lu", dwNumber);
//CString to DWORD
DWORD dwNO;
CString csDwNumber="1234";
dwNO= atol((char*)(LPCTSTR)csDwNumber);
//DWORD to CString
DWORD dwNumber = 1234;
CString csNumber;
csNumber.Format("%lu", dwNumber);
//CString to DWORD
DWORD dwNO;
CString csDwNumber="1234";
dwNO= atol((char*)(LPCTSTR)csDwNumber);
/*Error 122 error LNK2019: unresolved external symbol "wchar_t * __stdcall _com_util::ConvertStringToBSTR(char const *)" (?ConvertStringToBSTR@_com_util@@YGPA_WPBD@Z
) referenced in function
"public: __thiscall _variant_t::_variant_t(char const *)"
(??0_variant_t@@QAE@PBD@Z)
Error 121 error LNK2019: unresolved external symbol "char * __stdcall _com_util::ConvertBSTRToString(wchar_t *)" (?ConvertBSTRToString@_com_util@@YGPADPA_W@Z)
referenced in function "public: char const * __thiscall _bstr_t::Data_t::GetString(void)const " (?GetString@Data_t@_bstr_t@@QBEPBDXZ)
*/
/*
Some Times when we are using COM lt will give above Linker Errors
To fix this add the following header file and library
*/
#include <comutil.h>
# pragma comment(lib, "comsuppwd.lib")
// Set a window position as a topmost window.
::SetWindowPos( GetSafeHwnd(),
HWND_TOPMOST,
0, 0, 0, 0,
SWP_NOMOVE | SWP_NOREDRAW | SWP_NOSIZE );
//To set a text in Textbox using Resource ID
//instead of CEdit member variable
::SetDlgItemText(GetSafeHwnd(), IDC_EDIT1, "username");
/*
when using CDHtmlDialog to navigate a page frequently
and changing content and refresh it will crash in
ieframe.dll or mshtml.dll.
To avoid crash check browser busy state
before navigating a file in CDHtmlDialog
*/
//sample code to navigating html file
void CMYDHtmlDialog::NavigateFile()
{
CString csFilePath;
csFilePath = "c:\\sample.html";
//wait for 1 second if not loaded or in busy state
if( FALSE == WaitTillLoaded (1000) )
return;
Navigate(csFilePath, NULL, NULL);
}
//sample code to wait till page lode in browser
BOOL CMYDHtmlDialog::WaitTillLoaded (int nTimeout)
{
READYSTATE result;
DWORD nFirstTick = GetTickCount ();
do
{
m_pBrowserApp->get_ReadyState (&result);
if (result != READYSTATE_COMPLETE)
Sleep (50);
if (nTimeout > 0)
{
if ((GetTickCount () - nFirstTick) > nTimeout)
break;
}
} while (result != READYSTATE_COMPLETE);
if (result == READYSTATE_COMPLETE)
return TRUE;
else
return FALSE;
}
To View all elements Please change the following settings [For Visual Studio 2008]:
1. Open the file "c:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\autoexp.dat" in notepad
2. Search for the line "[AutoExpand]" add the following line.
[AutoExpand]
CStringArray=size = <m_nSize> //Add this line
3. Search for the line "[Visualizer]" add the following line.
[Visualizer] //Add the below lines after this line
CStringArray{
children
(
#array
(
expr : ($e.m_pData[$i]),
size : ($e.m_nSize)
)
)
}
4. Save this file and close All Visual studio application and open again and try.
COleDateTime currdate;
COleDateTime prevdate;
COleDateTime nextday;
currdate = COleDateTime::GetCurrentTime();
CString csTime= currdate.Format(); //current date and time
COleDateTimeSpan span(1,0,0,0);
int nDay = currdate.GetDay(); //current day
prevdate = currdate - span;
nextday = currdate + span;
int nPrevDay = prevdate.GetDay(); //yesterday or Previous day
int nNextDay = nextday.GetDay(); //next day