WindoInfoDlg.cpp
资源名称:toolbar.rar [点击查看]
上传用户:rundaa
上传日期:2009-05-24
资源大小:44k
文件大小:4k
源码类别:
CAD
开发平台:
Visual C++
- // WindoInfoDlg.cpp : implementation file
- //
- #include "StdAfx.h"
- #include "StdArx.h"
- #include "resource.h"
- #include "WindoInfoDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- HTREEITEM htCur, htPrev;
- /////////////////////////////////////////////////////////////////////////////
- // CWindoInfoDlg dialog
- CWindoInfoDlg::CWindoInfoDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CWindoInfoDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CWindoInfoDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void CWindoInfoDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CWindoInfoDlg)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CWindoInfoDlg, CDialog)
- //{{AFX_MSG_MAP(CWindoInfoDlg)
- // NOTE: the ClassWizard will add message map macros here
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CWindoInfoDlg message handlers
- BOOL CWindoInfoDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- m_pTreeCtrl = (CTreeCtrl*)GetDlgItem(IDC_TREE1);
- m_imgList.Create(16, 15, FALSE, 9, 3);
- CBitmap* pBitmap = new CBitmap;
- pBitmap->LoadBitmap(IDB_WINDOW);
- m_nIdxWindow = m_imgList.Add(pBitmap, RGB(0, 0, 0));
- pBitmap->LoadBitmap(IDB_RECT);
- m_nIdxRect = m_imgList.Add(pBitmap, RGB(0, 0, 0));
- pBitmap->LoadBitmap(IDB_ARCH);
- m_nIdxArch = m_imgList.Add(pBitmap, RGB(0, 0, 0));
- pBitmap->LoadBitmap(IDB_APEX);
- m_nIdxApex = m_imgList.Add(pBitmap, RGB(0, 0, 0));
- pBitmap->LoadBitmap(IDB_WIDTH);
- m_nIdxWidth = m_imgList.Add(pBitmap, RGB(0, 0, 0));
- pBitmap->LoadBitmap(IDB_HEIGHT);
- m_nIdxHeight = m_imgList.Add(pBitmap, RGB(0, 0, 0));
- pBitmap->LoadBitmap(IDB_ROWS);
- m_nIdxRows = m_imgList.Add(pBitmap, RGB(0, 0, 0));
- pBitmap->LoadBitmap(IDB_COLS);
- m_nIdxCols = m_imgList.Add(pBitmap, RGB(0, 0, 0));
- pBitmap->LoadBitmap(IDB_STARTPT);
- m_nIdxStartPt = m_imgList.Add(pBitmap, RGB(0, 0, 0));
- m_pTreeCtrl->SetImageList(&m_imgList, TVSIL_NORMAL);
- delete pBitmap;
- AddTreeViewItems();
- HTREEITEM hRoot = m_pTreeCtrl->GetRootItem();
- m_pTreeCtrl->Expand(hRoot, TVE_EXPAND);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CWindoInfoDlg::AddTreeViewItems()
- {
- CString strItem("Window");
- htCur = AddOneItem((HTREEITEM)NULL, strItem, (HTREEITEM)TVI_ROOT, m_nIdxWindow, TRUE);
- switch(windInfo.m_nWindType)
- {
- case 0 :
- strItem = "Rect";
- htPrev = AddOneItem(htCur, strItem, NULL, m_nIdxRect, FALSE);
- break;
- case 1 :
- strItem = "Arch";
- htPrev = AddOneItem(htCur, strItem, NULL, m_nIdxArch, FALSE);
- break;
- case 2 :
- strItem = "Apex";
- htPrev = AddOneItem(htCur, strItem, NULL, m_nIdxApex, FALSE);
- break;
- }
- strItem.Format("W = %.2lf", windInfo.m_dWindWt);
- htPrev = AddOneItem(htCur, strItem, NULL, m_nIdxWidth, FALSE);
- strItem.Format("H = %.2lf", windInfo.m_dWindHt);
- htPrev = AddOneItem(htCur, strItem, NULL, m_nIdxHeight, FALSE);
- strItem.Format("Rows = %d", windInfo.m_nRows);
- htPrev = AddOneItem(htCur, strItem, NULL, m_nIdxRows, FALSE);
- strItem.Format("Cols = %d", windInfo.m_nCols);
- htPrev = AddOneItem(htCur, strItem, NULL, m_nIdxCols, FALSE);
- strItem.Format("SP = (%.2lf, %.2lf)", windInfo.m_startPt.x, windInfo.m_startPt.y);
- htPrev = AddOneItem(htCur, strItem, NULL, m_nIdxStartPt, FALSE);
- }
- HTREEITEM CWindoInfoDlg::AddOneItem( HTREEITEM hParent,
- CString szText, HTREEITEM hInsAfter, int iImage, BOOL bChildren)
- {
- HTREEITEM hItem; // return value
- TV_ITEM tvI; // item structure
- TV_INSERTSTRUCT tvIns; // item insert structure
- if(bChildren) // *** set tvI.mask member ***
- tvI.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_CHILDREN | TVIF_SELECTEDIMAGE; // item has children
- else // item has no children
- tvI.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- tvI.pszText = szText.GetBuffer(szText.GetLength()); // set text, text lenght, image
- tvI.cchTextMax = szText.GetLength();
- tvI.iImage = iImage;
- tvI.iSelectedImage = iImage;
- tvI.cChildren = 1; // allow one more level down
- // do the insert
- tvIns.item = tvI;
- tvIns.hInsertAfter = hInsAfter;
- tvIns.hParent = hParent;
- hItem = m_pTreeCtrl->InsertItem(&tvIns);
- return (hItem); // return (add error trap here)
- }