// Set a window position as a topmost window.
::SetWindowPos( GetSafeHwnd(),
HWND_TOPMOST,
0, 0, 0, 0,
SWP_NOMOVE | SWP_NOREDRAW | SWP_NOSIZE );
// 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
// MainFrm.h
CSplitterWnd m_splitwnd;
//MainFrm.pp
//Override OnCreateClient using properties in classview
//CLeftView and CRightView are the class should be derived from any of view class
//like CTreeView, CListView, CFormView
// Here CRightView derived from CListView
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// Add following Code
if(!m_splitwnd.CreateStatic(this,1,2))
return FALSE;
if(!m_splitwnd.CreateView(0,0,RUNTIME_CLASS(CLeftView),CSize(200,200),pContext) ||
!m_splitwnd.CreateView(0,1,RUNTIME_CLASS(CRightView),CSize(100,200),pContext) )
{
m_splitwnd.DestroyWindow();
return FALSE;
}
// End
return CFrameWndEx::OnCreateClient(lpcs, pContext);
}
// RightView.cpp : implementation file
//in CRightView Class add WM_CREATE message
int CRightView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CListView::OnCreate(lpCreateStruct) == -1)
return -1;
GetListCtrl().DeleteAllItems();
CListCtrl &mylist =this->GetListCtrl();
ModifyStyle(NULL, LVS_REPORT , 0);
mylist.SetExtendedStyle( mylist.GetExtendedStyle() |LVS_EX_CHECKBOXES| LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_EX_TWOCLICKACTIVATE | LVS_EX_SUBITEMIMAGES );
mylist.InsertColumn(0, _T("S.No"),LVCFMT_LEFT| LVCF_TEXT);
mylist.InsertColumn(1, _T("Name"), LVCFMT_LEFT| LVCF_TEXT);
mylist.InsertColumn(2, _T("Country"), LVCFMT_LEFT| LVCF_TEXT);
mylist.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
mylist.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER);
mylist.SetColumnWidth(2, 100);
/*
mylist.InsertItem( 0, _T(""));
mylist.SetItemText( 0, 0, _T("1") );
mylist.SetItemText( 0, 1, _T("John") );
mylist.SetItemText( 0, 2, _T("India") );
*/
return 0;
}
#include <vector>
#include <algorithm>
using namespace std;
// Add this header files
vector<CString> vNames;
vector<CString> ::iterator vItr;
CString csName;
vNames.push_back("John");
vNames.push_back("Victor");
vNames.push_back("Nancy");
vNames.push_back("William");
vNames.push_back("Nancy");
sort(vNames.begin(),vNames.end());
vNames.erase(unique(vNames.begin(),vNames.end()),vNames.end());
for(vItr=vNames.begin();vItr!=vNames.end();vItr++)
{
csName=(*vItr);
//TRACE(csName);
//AfxMessageBox(csName);
}