我要做一个,MFC多文档MDI项目:左侧显示一个窗口,里面放一个树控件;底部显示一个窗口,里面放一个列表控件,在左侧窗口和底部窗口交界处放一个小的窗口,如图圈起来的地方(我要达到这样的效果)。
前面是我的要求,目前做到了左侧显示一个窗体,底部一个窗体,但是存在两个问题:
1、为什么左侧窗口中的树无法显示?
2、怎么画那个交界处的小窗口。稍后把我的工程链接放上去,欢迎大家先来支招 啊
前面是我的要求,目前做到了左侧显示一个窗体,底部一个窗体,但是存在两个问题:
1、为什么左侧窗口中的树无法显示?
2、怎么画那个交界处的小窗口。稍后把我的工程链接放上去,欢迎大家先来支招 啊
1、为什么左侧窗口中的树无法显示?
这个在我的项目中实现好了的,知识实现的很复杂,我看不懂,想自己做个,程序已经发出来了
http://download.csdn.net/download/xuying123456/3753984
2、怎么画那个交界处的小窗口。
这个是我现在要做的,要实时收取数据显示在上面
先上下分,然后将上面的再左右分,再将最左边的再上下分即可
http://download.csdn.net/download/xuying123456/3753984
VS2010直接集成了BCG界面库。
BOOL CCoolDialogBar::Create(CWnd* pParentWnd, CDialog *pDialog, CString &pTitle, UINT nID, DWORD dwStyle)
{
ASSERT_VALID(pParentWnd); // must have a parent
ASSERT (!((dwStyle & CBRS_SIZE_FIXED) && (dwStyle & CBRS_SIZE_DYNAMIC)));
// save the style -- AMENDED by Holger Thiele - Thankyou
m_dwStyle = dwStyle & CBRS_ALL; // create the base window
CString wndclass = AfxRegisterWndClass(CS_DBLCLKS, LoadCursor(NULL, IDC_ARROW),
m_brushBkgd, 0);
if (!CWnd::Create(wndclass, pTitle, dwStyle, CRect(0,0,0,0),
pParentWnd, 0))
return FALSE; // create the child dialog
m_cDialog = pDialog;
m_cDialog->Create(nID, this);
m_cDialog->ShowWindow(SW_SHOW);
// use the dialog dimensions as default base dimensions
CRect rc;
m_cDialog->GetWindowRect(rc);
m_sizeHorz = m_sizeVert = m_sizeFloat = rc.Size();
m_sizeHorz.cy += m_cxEdge + m_cxBorder;
m_sizeVert.cx += m_cxEdge + m_cxBorder; return TRUE;
}
//缺:
m_cDialog->ShowWindow(SW_SHOW);
// CCresDlg 消息处理程序
void CCresDlg::TreeInit()
{
TCHAR buf[255];
TCHAR computer[255];
//Read logical drive into buf
::GetLogicalDriveStrings(255,buf);
//Parse the buf
CStringArray DriveList;
for(int len=0;buf[len]!=0;)
{
DriveList.Add(&buf[len]);
len=len+_tcslen(&buf[len])+1;
}
TVINSERTSTRUCT tvis;
tvis.hParent = TVI_ROOT;//=NULL,root of this tree control
tvis.hInsertAfter = TVI_LAST;// TVI_SORT ,TVI_FIRST;
tvis.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_CHILDREN;//|TVIF_STATE;
tvis.item.pszText= computer;
tvis.item.cchTextMax = MAX_PATH;
tvis.item.cChildren=1;// has child show "+"
//Use the IMalloc to allocate memory for ITEMIDLIST structure.
LPMALLOC lpMalloc;
HRESULT hr=::SHGetMalloc(&lpMalloc);
if(FAILED(hr)) return ;
//Get the PIDL of a special folder
LPITEMIDLIST lpidl;
::SHGetSpecialFolderLocation(NULL,CSIDL_DRIVES,&lpidl);
SHFILEINFO shgfi;
//Use lpidl to get file info.
SHGetFileInfo((LPCTSTR)lpidl,0,&shgfi,sizeof(SHFILEINFO),SHGFI_PIDL |
SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
tvis.item.iImage=shgfi.iIcon;
_tcscpy(computer,shgfi.szDisplayName);
SHGetFileInfo((LPCTSTR)lpidl,0,&shgfi,sizeof(SHFILEINFO),SHGFI_PIDL |
SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_OPENICON);
tvis.item.iSelectedImage = shgfi.iIcon; HTREEITEM hti=m_treeCtrl.InsertItem(&tvis);
tvis.hParent = hti;
if(FAILED(hti))return;
//Send message to enable image of folder
HIMAGELIST hImageList=(HIMAGELIST)SHGetFileInfo((LPCTSTR)lpidl,0,&shgfi,sizeof(SHFILEINFO),SHGFI_PIDL |
SHGFI_SYSICONINDEX | SHGFI_SMALLICON );
m_treeCtrl.SendMessage(TVM_SETIMAGELIST,(WPARAM)TVSIL_NORMAL,(LPARAM)hImageList);
//Insert all the items of my computer
int index=0;
CString DriveName=DriveList[index];
do
{
SHGetFileInfo(DriveName,FILE_ATTRIBUTE_DIRECTORY,&shgfi,sizeof(shgfi),
SHGFI_DISPLAYNAME | SHGFI_USEFILEATTRIBUTES | SHGFI_TYPENAME);
tvis.hParent =hti ;//TVI_ROOT;
tvis.item.pszText = shgfi.szDisplayName;
tvis.item.cChildren=1;
HTREEITEM hTreeItemDrive = m_treeCtrl.InsertItem(&tvis);
tvis.hParent = hTreeItemDrive;
index++;
if(index>=DriveList.GetSize()) break;
DriveName=DriveList[index];
}while(DriveName);
lpMalloc->Free(lpidl);
lpMalloc->Release();
}
//
BOOL CCresDlg::OnInitDialog()
{
CDialog::OnInitDialog(); // TODO: 在此添加额外的初始化
TreeInit();
//
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}