IsBadWritePtr

本文介绍了IsBadWritePtr函数的功能及使用注意事项。该函数用于验证调用进程是否能写入指定内存区域。文章强调了其在多线程环境下的局限性,并推荐在使用时结合结构化异常处理。

类似于IsBadReadPtr. 该函数用来检查进程是否有权限写指定的内存块。以下注释转自MSDN:

 

Verifies that the calling process has write access to the specified range of memory.

Important  This function is obsolete and should not be used. Despite its name, it does not guarantee that the pointer is valid or that the memory pointed to is safe to use. For more information, see Remarks on this page.

 

Parameters

lp [in]

A pointer to the first byte of the memory block.

ucb [in]

The size of the memory block, in bytes. If this parameter is zero, the return value is zero.

Return Value

If the calling process has write access to all bytes in the specified memory range, the return value is zero.

If the calling process does not have write access to all bytes in the specified memory range, the return value is nonzero.

If the application is run under a debugger and the process does not have write access to all bytes in the specified memory range, the function causes a first chance STATUS_ACCESS_VIOLATION exception. The debugger can be configured to break for this condition. After resuming process execution in the debugger, the function continues as usual and returns a nonzero value This behavior is by design and serves as a debugging aid.

Remarks

This function is typically used when working with pointers returned from third-party libraries, where you cannot determine the memory management behavior in the third-party DLL.

Threads in a process are expected to cooperate in such a way that one will not free memory that the other needs. Use of this function does not negate the need to do this. If this is not done, the application may fail in an unpredictable manner.

Dereferencing potentially invalid pointers can disable stack expansion in other threads. A thread exhausting its stack, when stack expansion has been disabled, results in the immediate termination of the parent process, with no pop-up error window or diagnostic information.

If the calling process has write access to some, but not all, of the bytes in the specified memory range, the return value is nonzero.

In a preemptive multitasking environment, it is possible for some other thread to change the process's access to the memory being tested. Even when the function indicates that the process has write access to the specified memory, you should use structured exception handling when attempting to access the memory. Use of structured exception handling enables the system to notify the process if an access violation exception occurs, giving the process an opportunity to handle the exception.

IsBadWritePtr is not multithread safe. To use it properly on a pointer shared by multiple threads, call it inside a critical region of code that allows only one thread to access the memory being checked. Use operating system–level objects such as critical sections or mutexes or the interlocked functions to create the critical region of code.

#ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif namespace TreePropSheet { //------------------------------------------------------------------- // class CTreePropSheet //------------------------------------------------------------------- BEGIN_MESSAGE_MAP(CTreePropSheet, CPropertySheet) //{{AFX_MSG_MAP(CTreePropSheet) ON_WM_DESTROY() //}}AFX_MSG_MAP ON_MESSAGE(PSM_ADDPAGE, OnAddPage) ON_MESSAGE(PSM_REMOVEPAGE, OnRemovePage) ON_MESSAGE(PSM_SETCURSEL, OnSetCurSel) ON_MESSAGE(PSM_SETCURSELID, OnSetCurSelId) ON_MESSAGE(PSM_ISDIALOGMESSAGE, OnIsDialogMessage) ON_NOTIFY(TVN_SELCHANGINGA, s_unPageTreeId, OnPageTreeSelChanging) ON_NOTIFY(TVN_SELCHANGINGW, s_unPageTreeId, OnPageTreeSelChanging) ON_NOTIFY(TVN_SELCHANGEDA, s_unPageTreeId, OnPageTreeSelChanged) ON_NOTIFY(TVN_SELCHANGEDW, s_unPageTreeId, OnPageTreeSelChanged) ON_COMMAND(0x1, OnOk) ON_COMMAND(0x2, OnCancel) END_MESSAGE_MAP() IMPLEMENT_DYNAMIC(CTreePropSheet, CPropertySheet) const UINT CTreePropSheet::s_unPageTreeId = 0x7EEE; CTreePropSheet::CTreePropSheet() : CPropertySheet(), m_bPageTreeSelChangedActive(FALSE), m_bTreeViewMode(TRUE), m_bPageCaption(FALSE), m_bTreeImages(FALSE), m_nPageTreeWidth(200), m_pwndPageTree(NULL), m_pFrame(NULL) {} CTreePropSheet::CTreePropSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage) : CPropertySheet(nIDCaption, pParentWnd, iSelectPage), m_bPageTreeSelChangedActive(FALSE), m_bTreeViewMode(TRUE), m_bPageCaption(FALSE), m_bTreeImages(FALSE), m_nPageTreeWidth(200), m_pwndPageTree(NULL), m_pFrame(NULL) { } CTreePropSheet::CTreePropSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage) : CPropertySheet(pszCaption, pParentWnd, iSelectPage), m_bPageTreeSelChangedActive(FALSE), m_bTreeViewMode(TRUE), m_bPageCaption(FALSE), m_bTreeImages(FALSE), m_nPageTreeWidth(200), m_pwndPageTree(NULL), m_pFrame(NULL) { } CTreePropSheet::~CTreePropSheet() { } ///////////////////////////////////////////////////////////////////// // Operationen BOOL CTreePropSheet::SetTreeViewMode(BOOL bTreeViewMode /* = TRUE */, BOOL bPageCaption /* = FALSE */, BOOL bTreeImages /* = FALSE */) { if (IsWindow(m_hWnd)) { // needs to becalled, before the window has been created ASSERT(FALSE); return FALSE; } m_bTreeViewMode = bTreeViewMode; if (m_bTreeViewMode) { m_bPageCaption = bPageCaption; m_bTreeImages = bTreeImages; } return TRUE; } BOOL CTreePropSheet::SetTreeWidth(int nWidth) { if (IsWindow(m_hWnd)) { // needs to be called, before the window is created. ASSERT(FALSE); return FALSE; } m_nPageTreeWidth = nWidth; return TRUE; } void CTreePropSheet::SetEmptyPageText(LPCTSTR lpszEmptyPageText) { m_strEmptyPageMessage = lpszEmptyPageText; } DWORD CTreePropSheet::SetEmptyPageTextFormat(DWORD dwFormat) { DWORD dwPrevFormat = m_pFrame->GetMsgFormat(); m_pFrame->SetMsgFormat(dwFormat); return dwPrevFormat; } BOOL CTreePropSheet::SetTreeDefaultImages(CImageList *pImages) { if (pImages->GetImageCount() != 2) { ASSERT(FALSE); return FALSE; } if (m_DefaultImages.GetSafeHandle()) m_DefaultImages.DeleteImageList(); m_DefaultImages.Create(pImages); // update, if necessary if (IsWindow(m_hWnd)) RefillPageTree(); return TRUE; } BOOL CTreePropSheet::SetTreeDefaultImages(UINT unBitmapID, int cx, COLORREF crMask) { if (m_DefaultImages.GetSafeHandle()) m_DefaultImages.DeleteImageList(); if (!m_DefaultImages.Create(unBitmapID, cx, 0, crMask)) return FALSE; if (m_DefaultImages.GetImageCount() != 2) { m_DefaultImages.DeleteImageList(); return FALSE; } return TRUE; } CTreeCtrl* CTreePropSheet::GetPageTreeControl() { return m_pwndPageTree; } ///////////////////////////////////////////////////////////////////// // public helpers BOOL CTreePropSheet::SetPageIcon(CPropertyPage *pPage, HICON hIcon) { pPage->m_psp.dwFlags|= PSP_USEHICON; pPage->m_psp.hIcon = hIcon; return TRUE; } BOOL CTreePropSheet::SetPageIcon(CPropertyPage *pPage, UINT unIconId) { HICON hIcon = AfxGetApp()->LoadIcon(unIconId); if (!hIcon) return FALSE; return SetPageIcon(pPage, hIcon); } BOOL CTreePropSheet::SetPageIcon(CPropertyPage *pPage, CImageList &Images, int nImage) { HICON hIcon = Images.ExtractIcon(nImage); if (!hIcon) return FALSE; return SetPageIcon(pPage, hIcon); } BOOL CTreePropSheet::DestroyPageIcon(CPropertyPage *pPage) { if (!pPage || !(pPage->m_psp.dwFlags&PSP_USEHICON) || !pPage->m_psp.hIcon) return FALSE; DestroyIcon(pPage->m_psp.hIcon); pPage->m_psp.dwFlags&= ~PSP_USEHICON; pPage->m_psp.hIcon = NULL; return TRUE; } ///////////////////////////////////////////////////////////////////// // Overridable implementation helpers CString CTreePropSheet::GenerateEmptyPageMessage(LPCTSTR lpszEmptyPageMessage, LPCTSTR lpszCaption) { CString strMsg; strMsg.Format(lpszEmptyPageMessage, lpszCaption); return strMsg; } CTreeCtrl* CTreePropSheet::CreatePageTreeObject() { return new CTreeCtrl; } CPropPageFrame* CTreePropSheet::CreatePageFrame() { return new CPropPageFrameDefault; } ///////////////////////////////////////////////////////////////////// // Implementation helpers void CTreePropSheet::MoveChildWindows(int nDx, int nDy) { CWnd *pWnd = GetWindow(GW_CHILD); while (pWnd) { CRect rect; pWnd->GetWindowRect(rect); rect.OffsetRect(nDx, nDy); rect.bottom -= 50; ScreenToClient(rect); pWnd->MoveWindow(rect); pWnd->InvalidateRect(rect); pWnd = pWnd->GetNextWindow(); } } void CTreePropSheet::RefillPageTree() { if (!IsWindow(m_hWnd)) return; m_pwndPageTree->DeleteAllItems(); CTabCtrl *pTabCtrl = GetTabControl(); if (!IsWindow(pTabCtrl->GetSafeHwnd())) { ASSERT(FALSE); return; } const int nPageCount = pTabCtrl->GetItemCount(); // rebuild image list if (m_bTreeImages) { for (int i = m_Images.GetImageCount()-1; i >= 0; --i) m_Images.Remove(i); // add page images CImageList *pPageImages = pTabCtrl->GetImageList(); if (pPageImages) { for (int nImage = 0; nImage < pPageImages->GetImageCount(); ++nImage) { HICON hIcon = pPageImages->ExtractIcon(nImage); m_Images.Add(hIcon); DestroyIcon(hIcon); } } // add default images if (m_DefaultImages.GetSafeHandle()) { HICON hIcon; // add default images hIcon = m_DefaultImages.ExtractIcon(0); if (hIcon) { m_Images.Add(hIcon); DestroyIcon(hIcon); } hIcon = m_DefaultImages.ExtractIcon(1); { m_Images.Add(hIcon); DestroyIcon(hIcon); } } } // insert tree items for (int nPage = 0; nPage < nPageCount; ++nPage) { // Get title and image of the page CString strPagePath; TCITEM ti; ZeroMemory(&ti, sizeof(ti)); ti.mask = TCIF_TEXT|TCIF_IMAGE; ti.cchTextMax = MAX_PATH; ti.pszText = strPagePath.GetBuffer(ti.cchTextMax); ASSERT(ti.pszText); if (!ti.pszText) return; pTabCtrl->GetItem(nPage, &ti); strPagePath.ReleaseBuffer(); // Create an item in the tree for the page HTREEITEM hItem = CreatePageTreeItem(ti.pszText); ASSERT(hItem); if (hItem) { m_pwndPageTree->SetItemData(hItem, nPage); // set image if (m_bTreeImages) { int nImage = ti.iImage; if (nImage < 0 || nImage >= m_Images.GetImageCount()) nImage = m_DefaultImages.GetSafeHandle()? m_Images.GetImageCount()-1 : -1; m_pwndPageTree->SetItemImage(hItem, nImage, nImage); } } } } HTREEITEM CTreePropSheet::CreatePageTreeItem(LPCTSTR lpszPath, HTREEITEM hParent /* = TVI_ROOT */) { CString strPath(lpszPath); CString strTopMostItem(SplitPageTreePath(strPath)); // Check if an item with the given text does already exist HTREEITEM hItem = NULL; HTREEITEM hChild = m_pwndPageTree->GetChildItem(hParent); while (hChild) { if (m_pwndPageTree->GetItemText(hChild) == strTopMostItem) { hItem = hChild; break; } hChild = m_pwndPageTree->GetNextItem(hChild, TVGN_NEXT); } // If item with that text does not already exist, create a new one if (!hItem) { hItem = m_pwndPageTree->InsertItem(strTopMostItem, hParent); m_pwndPageTree->SetItemData(hItem, -1); if (!strPath.IsEmpty() && m_bTreeImages && m_DefaultImages.GetSafeHandle()) // set folder image m_pwndPageTree->SetItemImage(hItem, m_Images.GetImageCount()-2, m_Images.GetImageCount()-2); } if (!hItem) { ASSERT(FALSE); return NULL; } if (strPath.IsEmpty()) return hItem; else return CreatePageTreeItem(strPath, hItem); } CString CTreePropSheet::SplitPageTreePath(CString &strRest) { int nSeperatorPos = 0; while (TRUE) { nSeperatorPos = strRest.Find(_T("::"), nSeperatorPos); if (nSeperatorPos == -1) { CString strItem(strRest); strRest.Empty(); return strItem; } else if (nSeperatorPos>0) { // if there is an odd number of backslashes infront of the // seperator, than do not interpret it as separator int nBackslashCount = 0; for (int nPos = nSeperatorPos-1; nPos >= 0 && strRest[nPos]==_T('\\'); --nPos, ++nBackslashCount); if (nBackslashCount%2 == 0) break; else ++nSeperatorPos; } } CString strItem(strRest.Left(nSeperatorPos)); strItem.Replace(_T("\\::"), _T("::")); strItem.Replace(_T("\\\\"), _T("\\")); strRest = strRest.Mid(nSeperatorPos+2); return strItem; } BOOL CTreePropSheet::KillActiveCurrentPage() { HWND hCurrentPage = PropSheet_GetCurrentPageHwnd(m_hWnd); if (!IsWindow(hCurrentPage)) { ASSERT(FALSE); return TRUE; } // Check if the current page is really active (if page is invisible // an virtual empty page is the active one. if (!::IsWindowVisible(hCurrentPage)) return TRUE; // Try to deactivate current page PSHNOTIFY pshn; pshn.hdr.code = PSN_KILLACTIVE; pshn.hdr.hwndFrom = m_hWnd; pshn.hdr.idFrom = GetDlgCtrlID(); pshn.lParam = 0; if (::SendMessage(hCurrentPage, WM_NOTIFY, pshn.hdr.idFrom, (LPARAM)&pshn)) // current page does not allow page change return FALSE; // Hide the page ::ShowWindow(hCurrentPage, SW_HIDE); return TRUE; } HTREEITEM CTreePropSheet::GetPageTreeItem(int nPage, HTREEITEM hRoot /* = TVI_ROOT */) { // Special handling for root case if (hRoot == TVI_ROOT) hRoot = m_pwndPageTree->GetNextItem(NULL, TVGN_ROOT); // Check parameters if (nPage < 0 || nPage >= GetPageCount()) { ASSERT(FALSE); return NULL; } if (hRoot == NULL) { ASSERT(FALSE); return NULL; } // we are performing a simple linear search here, because we are // expecting only little data HTREEITEM hItem = hRoot; while (hItem) { if ((signed)m_pwndPageTree->GetItemData(hItem) == nPage) return hItem; if (m_pwndPageTree->ItemHasChildren(hItem)) { HTREEITEM hResult = GetPageTreeItem(nPage, m_pwndPageTree->GetNextItem(hItem, TVGN_CHILD)); if (hResult) return hResult; } hItem = m_pwndPageTree->GetNextItem(hItem, TVGN_NEXT); } // we've found nothing, if we arrive here return hItem; } BOOL CTreePropSheet::SelectPageTreeItem(int nPage) { HTREEITEM hItem = GetPageTreeItem(nPage); if (!hItem) return FALSE; return m_pwndPageTree->SelectItem(hItem); } BOOL CTreePropSheet::SelectCurrentPageTreeItem() { CTabCtrl *pTab = GetTabControl(); if (!IsWindow(pTab->GetSafeHwnd())) return FALSE; return SelectPageTreeItem(pTab->GetCurSel()); } void CTreePropSheet::UpdateCaption() { HWND hPage = PropSheet_GetCurrentPageHwnd(GetSafeHwnd()); BOOL bRealPage = IsWindow(hPage) && ::IsWindowVisible(hPage); HTREEITEM hItem = m_pwndPageTree->GetSelectedItem(); if (!hItem) return; CString strCaption = m_pwndPageTree->GetItemText(hItem); // if empty page, then update empty page message if (!bRealPage) m_pFrame->SetMsgText(GenerateEmptyPageMessage(m_strEmptyPageMessage, strCaption)); // if no captions are displayed, cancel here if (!m_pFrame->GetShowCaption()) return; // get tab control, to the the images from CTabCtrl *pTabCtrl = GetTabControl(); if (!IsWindow(pTabCtrl->GetSafeHwnd())) { ASSERT(FALSE); return; } if (m_bTreeImages) { // get image from tree int nImage; m_pwndPageTree->GetItemImage(hItem, nImage, nImage); HICON hIcon = m_Images.ExtractIcon(nImage); m_pFrame->SetCaption(strCaption, hIcon); if (hIcon) DestroyIcon(hIcon); } else if (bRealPage) { // get image from hidden (original) tab provided by the original // implementation CImageList *pImages = pTabCtrl->GetImageList(); if (pImages) { TCITEM ti; ZeroMemory(&ti, sizeof(ti)); ti.mask = TCIF_IMAGE; HICON hIcon = NULL; if (pTabCtrl->GetItem((int)m_pwndPageTree->GetItemData(hItem), &ti)) hIcon = pImages->ExtractIcon(ti.iImage); m_pFrame->SetCaption(strCaption, hIcon); if (hIcon) DestroyIcon(hIcon); } else m_pFrame->SetCaption(strCaption); } else m_pFrame->SetCaption(strCaption); } void CTreePropSheet::ActivatePreviousPage() { if (!IsWindow(m_hWnd)) return; if (!IsWindow(m_pwndPageTree->GetSafeHwnd())) { // normal tab property sheet. Simply use page index int nPageIndex = GetActiveIndex(); if (nPageIndex<0 || nPageIndex>=GetPageCount()) return; int nPrevIndex = (nPageIndex==0)? GetPageCount()-1 : nPageIndex-1; SetActivePage(nPrevIndex); } else { // property sheet with page tree. // we need a more sophisticated handling here, than simply using // the page index, because we won't skip empty pages. // so we have to walk the page tree HTREEITEM hItem = m_pwndPageTree->GetSelectedItem(); ASSERT(hItem); if (!hItem) return; HTREEITEM hPrevItem = NULL; if (hPrevItem=m_pwndPageTree->GetPrevSiblingItem(hItem)) { while (m_pwndPageTree->ItemHasChildren(hPrevItem)) { hPrevItem = m_pwndPageTree->GetChildItem(hPrevItem); while (m_pwndPageTree->GetNextSiblingItem(hPrevItem)) hPrevItem = m_pwndPageTree->GetNextSiblingItem(hPrevItem); } } else hPrevItem=m_pwndPageTree->GetParentItem(hItem); if (!hPrevItem) { // no prev item, so cycle to the last item hPrevItem = m_pwndPageTree->GetRootItem(); while (TRUE) { while (m_pwndPageTree->GetNextSiblingItem(hPrevItem)) hPrevItem = m_pwndPageTree->GetNextSiblingItem(hPrevItem); if (m_pwndPageTree->ItemHasChildren(hPrevItem)) hPrevItem = m_pwndPageTree->GetChildItem(hPrevItem); else break; } } if (hPrevItem) m_pwndPageTree->SelectItem(hPrevItem); } } void CTreePropSheet::ActivateNextPage() { if (!IsWindow(m_hWnd)) return; if (!IsWindow(m_pwndPageTree->GetSafeHwnd())) { // normal tab property sheet. Simply use page index int nPageIndex = GetActiveIndex(); if (nPageIndex<0 || nPageIndex>=GetPageCount()) return; int nNextIndex = (nPageIndex==GetPageCount()-1)? 0 : nPageIndex+1; SetActivePage(nNextIndex); } else { // property sheet with page tree. // we need a more sophisticated handling here, than simply using // the page index, because we won't skip empty pages. // so we have to walk the page tree HTREEITEM hItem = m_pwndPageTree->GetSelectedItem(); ASSERT(hItem); if (!hItem) return; HTREEITEM hNextItem = NULL; if (hNextItem=m_pwndPageTree->GetChildItem(hItem)) ; else if (hNextItem=m_pwndPageTree->GetNextSiblingItem(hItem)) ; else if (m_pwndPageTree->GetParentItem(hItem)) { while (!hNextItem) { hItem = m_pwndPageTree->GetParentItem(hItem); if (!hItem) break; hNextItem = m_pwndPageTree->GetNextSiblingItem(hItem); } } if (!hNextItem) // no next item -- so cycle to the first item hNextItem = m_pwndPageTree->GetRootItem(); if (hNextItem) m_pwndPageTree->SelectItem(hNextItem); } } ///////////////////////////////////////////////////////////////////// // Overridings BOOL CTreePropSheet::OnInitDialog() { if (m_bTreeViewMode) { // be sure, there are no stacked tabs, because otherwise the // page caption will be to large in tree view mode EnableStackedTabs(FALSE); // Initialize image list. if (m_DefaultImages.GetSafeHandle()) { IMAGEINFO ii; m_DefaultImages.GetImageInfo(0, &ii); if (ii.hbmImage) DeleteObject(ii.hbmImage); if (ii.hbmMask) DeleteObject(ii.hbmMask); m_Images.Create(ii.rcImage.right-ii.rcImage.left, ii.rcImage.bottom-ii.rcImage.top, ILC_COLOR32|ILC_MASK, 0, 1); } else m_Images.Create(16, 16, ILC_COLOR32|ILC_MASK, 0, 1); } // perform default implementation BOOL bResult = CPropertySheet::OnInitDialog(); if (!m_bTreeViewMode) // stop here, if we would like to use tabs return bResult; // Get tab control... CTabCtrl *pTab = GetTabControl(); if (!IsWindow(pTab->GetSafeHwnd())) { ASSERT(FALSE); return bResult; } // ... and hide it pTab->ShowWindow(SW_HIDE); pTab->EnableWindow(FALSE); // Place another (empty) tab ctrl, to get a frame instead CRect rectFrame; pTab->GetWindowRect(rectFrame); ScreenToClient(rectFrame); rectFrame.bottom -= 50; m_pFrame = CreatePageFrame(); if (!m_pFrame) { ASSERT(FALSE); AfxThrowMemoryException(); } m_pFrame->Create(WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS, rectFrame, this, 0xFFFF); m_pFrame->ShowCaption(m_bPageCaption); // Lets make place for the tree ctrl const int nTreeWidth = m_nPageTreeWidth; const int nTreeSpace = 5; CRect rectSheet; GetWindowRect(rectSheet); rectSheet.right+= nTreeWidth; SetWindowPos(NULL, -1, -1, rectSheet.Width(), rectSheet.Height()-50, SWP_NOZORDER|SWP_NOMOVE|SWP_NOACTIVATE); CenterWindow(); MoveChildWindows(nTreeWidth, 0); // Lets calculate the rectangle for the tree ctrl CRect rectTree(rectFrame); rectTree.right = rectTree.left + nTreeWidth - nTreeSpace; // calculate caption height CTabCtrl wndTabCtrl; wndTabCtrl.Create(WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS, rectFrame, this, 0x1234); wndTabCtrl.InsertItem(0, _T("")); CRect rectFrameCaption; wndTabCtrl.GetItemRect(0, rectFrameCaption); wndTabCtrl.DestroyWindow(); m_pFrame->SetCaptionHeight(rectFrameCaption.Height()); // if no caption should be displayed, make the window smaller in // height if (!m_bPageCaption) { // make frame smaller m_pFrame->GetWnd()->GetWindowRect(rectFrame); ScreenToClient(rectFrame); rectFrame.top+= rectFrameCaption.Height(); m_pFrame->GetWnd()->MoveWindow(rectFrame); // move all child windows up MoveChildWindows(0, -rectFrameCaption.Height()); // modify rectangle for the tree ctrl rectTree.bottom-= rectFrameCaption.Height(); // make us smaller CRect rect; GetWindowRect(rect); rect.top+= rectFrameCaption.Height()/2; rect.bottom-= rectFrameCaption.Height()-rectFrameCaption.Height()/2; if (GetParent()) GetParent()->ScreenToClient(rect); MoveWindow(rect); } // finally create tht tree control const DWORD dwTreeStyle = TVS_SHOWSELALWAYS|TVS_TRACKSELECT|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS; m_pwndPageTree = CreatePageTreeObject(); if (!m_pwndPageTree) { ASSERT(FALSE); AfxThrowMemoryException(); } // MFC7-support here (Thanks to Rainer Wollgarten) #if _MFC_VER >= 0x0700 { m_pwndPageTree->CreateEx( WS_EX_CLIENTEDGE|WS_EX_NOPARENTNOTIFY, WS_TABSTOP|WS_CHILD|WS_VISIBLE|dwTreeStyle, rectTree, this, s_unPageTreeId); } #else { m_pwndPageTree->CreateEx( WS_EX_CLIENTEDGE|WS_EX_NOPARENTNOTIFY, _T("SysTreeView32"), _T("PageTree"), WS_TABSTOP|WS_CHILD|WS_VISIBLE|dwTreeStyle, rectTree, this, s_unPageTreeId); } #endif if (m_bTreeImages) { m_pwndPageTree->SetImageList(&m_Images, TVSIL_NORMAL); m_pwndPageTree->SetImageList(&m_Images, TVSIL_STATE); } // Fill the tree ctrl RefillPageTree(); // Select item for the current page if (pTab->GetCurSel() > -1) SelectPageTreeItem(pTab->GetCurSel()); HTREEITEM hItem = m_pwndPageTree->GetChildItem(NULL); while ( hItem ) { m_pwndPageTree->Expand(hItem, TVE_EXPAND); hItem = m_pwndPageTree->GetNextSiblingItem( hItem ); } CRect rectok, rectcancel, rectDlg; GetDlgItem(IDOK)->GetWindowRect(&rectok); GetDlgItem(IDCANCEL)->GetWindowRect(&rectcancel); GetWindowRect(&rectDlg); rectok.top = rectDlg.bottom - 35; rectok.bottom = rectok.top + 25; rectcancel.top = rectDlg.bottom - 35; rectcancel.bottom = rectcancel.top + 25; ScreenToClient(&rectok); ScreenToClient(&rectcancel); GetDlgItem(IDOK)->MoveWindow(&rectok); GetDlgItem(IDCANCEL)->MoveWindow(&rectcancel); return bResult; } void CTreePropSheet::OnDestroy() { CPropertySheet::OnDestroy(); if (m_Images.GetSafeHandle()) m_Images.DeleteImageList(); delete m_pwndPageTree; m_pwndPageTree = NULL; delete m_pFrame; m_pFrame = NULL; } LRESULT CTreePropSheet::OnAddPage(WPARAM wParam, LPARAM lParam) { LRESULT lResult = DefWindowProc(PSM_ADDPAGE, wParam, lParam); if (!m_bTreeViewMode) return lResult; RefillPageTree(); SelectCurrentPageTreeItem(); return lResult; } LRESULT CTreePropSheet::OnRemovePage(WPARAM wParam, LPARAM lParam) { LRESULT lResult = DefWindowProc(PSM_REMOVEPAGE, wParam, lParam); if (!m_bTreeViewMode) return lResult; RefillPageTree(); SelectCurrentPageTreeItem(); return lResult; } LRESULT CTreePropSheet::OnSetCurSel(WPARAM wParam, LPARAM lParam) { LRESULT lResult = DefWindowProc(PSM_SETCURSEL, wParam, lParam); if (!m_bTreeViewMode) return lResult; SelectCurrentPageTreeItem(); UpdateCaption(); return lResult; } LRESULT CTreePropSheet::OnSetCurSelId(WPARAM wParam, LPARAM lParam) { LRESULT lResult = DefWindowProc(PSM_SETCURSEL, wParam, lParam); if (!m_bTreeViewMode) return lResult; SelectCurrentPageTreeItem(); UpdateCaption(); return lResult; } void CTreePropSheet::OnPageTreeSelChanging(NMHDR *pNotifyStruct, LRESULT *plResult) { *plResult = 0; if (m_bPageTreeSelChangedActive) return; else m_bPageTreeSelChangedActive = TRUE; NMTREEVIEW *pTvn = reinterpret_cast<NMTREEVIEW*>(pNotifyStruct); int nPage = m_pwndPageTree->GetItemData(pTvn->itemNew.hItem); BOOL bResult; if (nPage<0 || (unsigned)nPage>=m_pwndPageTree->GetCount()) bResult = KillActiveCurrentPage(); else bResult = SetActivePage(nPage); if (!bResult) // prevent selection to change *plResult = TRUE; // Set focus to tree ctrl (I guess that's what the user expects) m_pwndPageTree->SetFocus(); m_bPageTreeSelChangedActive = FALSE; return; } void CTreePropSheet::OnPageTreeSelChanged(NMHDR *pNotifyStruct, LRESULT *plResult) { *plResult = 0; UpdateCaption(); return; } LRESULT CTreePropSheet::OnIsDialogMessage(WPARAM wParam, LPARAM lParam) { MSG *pMsg = reinterpret_cast<MSG*>(lParam); if (pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_TAB && GetKeyState(VK_CONTROL)&0x8000) { if (GetKeyState(VK_SHIFT)&0x8000) ActivatePreviousPage(); else ActivateNextPage(); return TRUE; } return CPropertySheet::DefWindowProc(PSM_ISDIALOGMESSAGE, wParam, lParam); } void CTreePropSheet::OnOk() { //首先给各子窗口发送 IDOK 消息 for (long l = 0; l < m_pages.GetSize(); l++) { CPropertyPage *pPage = (CPropertyPage*)m_pages[l]; if( pPage != NULL && !::IsBadWritePtr(pPage, sizeof(CPropertyPage)) && pPage->GetSafeHwnd() ) { pPage->UpdateData(TRUE); pPage->OnOK(); } } ::DestroyWindow( m_hWnd ); } void CTreePropSheet::OnCancel() { //首先给各子窗口发送 CANCEL 消息 for (long l = 0; l < m_pages.GetSize(); l++) { CPropertyPage *pPage = (CPropertyPage*)m_pages[l]; if( pPage != NULL && !::IsBadWritePtr(pPage, sizeof(CPropertyPage)) && pPage->GetSafeHwnd() ) { pPage->OnCancel(); } } ::DestroyWindow( m_hWnd ); //EndDialog( IDCANCEL ); } void InitCassParam(CPara1Dlg &m_page1, CPara2Dlg &m_page2, CPara3Dlg &m_page3) { int nElecline=1,nWall=0,nWallSimbol=0,nXiepo=0,nComputeArea=3; double dHatchSpace=20.0,dDtm=10.0; TCHAR szMapInfo[255]=_T("\\CASS9.0\\system\\MapInfo.db"); TCHAR TkChdw[100]=_T("单位名称"),TkCtrq[100]=_T("2002年3月数字化制图."); TCHAR TkZbx[100]=_T("任意直角坐标系: 坐标起点以 地方 为原点起算."); TCHAR TkGcjz[100]=_T("1985国家高程基准,等高距为1米."),TkTushi[100]=_T("2006年版图式."); TCHAR TkSurvey[100]=_T(""),TkDraw[100]=_T(""),TkCheck[100]=_T(""),TkSecret[255]=_T(""); BOOL bCenterLine = FALSE, bHasCenterLine = FALSE, bMakeRegion = FALSE; HKEY rKey; int nTemp; int nHighBits = 2, g_nInmapType = 0, g_nOutmapType = 0, g_nBmsbClose = 1, g_nContinuous = 0, g_nXiepoline = 0, g_bRegenKzdzj, g_bRegenGcdzj,g_bRegenJzwzj; double g_dZdhHeight = 1, g_dJzwHeight = 1, g_dLsxStep = 1; int nInstru = 24000; //全站仪型号 int nParity = 1; //校验 int nByteSize = 1;//数据位 int nTimeOut = 1;//延时 int nPort = 1;//通讯口 int nStopBits = 1;//停止位 int nBaudRate = 1;//波特率 int nZhandian = 1;//展点类型 if (RegOpenKeyEx(HKEY_CURRENT_USER, CASS_REGSTER, 0, KEY_READ, &rKey)==ERROR_SUCCESS) { //地物绘制 CassQueryReg(rKey,_T("highbits"),g_nHighBits); //高程注记小数点位数 CassQueryReg(rKey,_T("elecline"),nElecline); //电力线电杆间是否连线 CassQueryReg(rKey,_T("wall"),nWall); //围墙端是否封口 CassQueryReg(rKey,_T("wallsimbol"),nWallSimbol); //围墙两线间符号 0--图块 1--短线 CassQueryReg(rKey,_T("xiepo"),nXiepo); //自然斜坡短线的长度 0--短 1--长 CassQueryReg(rKey,_T("hatchspace"),dHatchSpace); //填充间距 CassQueryReg(rKey,_T("kanhigh"),g_dKanHigh); //陡坎默认坎高 CassQueryReg(rKey,_T("dtm"),dDtm); //DTM三角形最小角 CassQueryReg(rKey,_T("inmaptype"),g_nInmapType); //生成交换文件选项 0--骨架线 1--图形元素 CassQueryReg(rKey,_T("outmaptype"),g_nOutmapType); //读入交换文件选项 0--骨架线 1--图形元素 CassQueryReg(rKey,_T("bmsbclose"),g_nBmsbClose); CassQueryReg(rKey,_T("continuous"),g_nContinuous); CassQueryReg(rKey,_T("xiepodi"),g_nXiepoline); CassQueryReg(rKey,_T("zdtype"),g_nZdType); CassQueryReg(rKey,_T("mapdbf"),szMapInfo); //图幅数据库名 CassQueryReg(rKey,_T("userpath"),g_szUsePath); //用户工作目录名 CassQueryReg(rKey,_T("gcdheight"),g_dGcdHeight); //高程点字高 CassQueryReg(rKey,_T("gcdwordstyle"),g_szWordStyle); //高程点注记字体 CassQueryReg(rKey,_T("zdhheight"),g_dZdhHeight); //展点号字高 CassQueryReg(rKey,_T("jzwheight"),g_dJzwHeight); //建筑物字高 CassQueryReg(rKey,_T("lsxstep"),g_dLsxStep); //流水线步长 CassQueryReg(rKey,_T("textfactor"),g_dTextFactor); //文字宽高比 CassQueryReg(rKey,_T("transect"),g_nTufaDeci); //土方计算小数位数 CassQueryReg(rKey,_T("computearea"),nComputeArea); //面积计算小数位数 CassQueryReg(rKey, _T("road_centerlinemake"), bCenterLine); //道路、桥梁、河流是否按中心线生成 CassQueryReg(rKey, _T("road_hascenterline"), bHasCenterLine); //道路、桥梁、河流生成中心线 CassQueryReg(rKey, _T("road_makeregion"), bMakeRegion); //道路、桥梁、河流生成面 CassQueryReg(rKey, _T("tufangdoukan"), g_bIfDouKan); CassQueryReg(rKey, _T("fgwhighbits"), g_nFgwHighDeci); //方格网土方格网高程注记位数 CassQueryReg(rKey,_T("hdmhighbits"),g_nHdmHighDeci); //横断面线高程注记位数 CassQueryReg(rKey,_T("hdmdistbits"),g_nHdmDistDeci); //横断面线距离注记位数 nTemp=1; CassQueryReg(rKey,_T("regenkzdzj"),nTemp); if ( 0 == nTemp ) g_bRegenKzdzj = FALSE; else g_bRegenKzdzj = TRUE; nTemp=1; CassQueryReg(rKey,_T("regengcdzj"),nTemp); if ( 0 == nTemp ) g_bRegenGcdzj = FALSE; else g_bRegenGcdzj = TRUE; nTemp=1; CassQueryReg(rKey,_T("regenjzwzj"),nTemp); if ( 0 == nTemp ) g_bRegenJzwzj = FALSE; else g_bRegenJzwzj = TRUE; CassQueryReg(rKey,_T("sc_enable"), m_page3.m_nEnableShortCuts); //是否启用快捷键 //电子平板 CassQueryReg(rKey,_T("totalstation"), nInstru); //全站仪型号 CassQueryReg(rKey,_T("parity"), nParity); //校验 CassQueryReg(rKey,_T("ByteSize"), nByteSize); //数据位 CassQueryReg(rKey,_T("timeout"), nTimeOut); //延时 CassQueryReg(rKey,_T("port"), nPort); //通讯口 CassQueryReg(rKey,_T("stopbits"), nStopBits); //停止位 CassQueryReg(rKey,_T("baudrate"),nTemp); nBaudRate = nTemp;//波特率 nZhandian=0; CassQueryReg(rKey,_T("dzpbzd"), nZhandian); //展点类型 ////图框参数 //CassQueryReg(rKey,_T("tk_chdw"),TkChdw); //CassQueryReg(rKey,_T("tk_ctrq"),TkCtrq); //CassQueryReg(rKey,_T("tk_zbx"),TkZbx); //CassQueryReg(rKey,_T("tk_gcjz"),TkGcjz); //CassQueryReg(rKey,_T("tk_tushi"),TkTushi); //CassQueryReg(rKey,_T("tk_survey"),TkSurvey); //CassQueryReg(rKey,_T("tk_draw"),TkDraw); //CassQueryReg(rKey,_T("tk_check"),TkCheck); //CassQueryReg(rKey,_T("tk_secret"),TkSecret); RegCloseKey(rKey); } //读出对话框 CAcModuleResourceOverride myResources; HWND hWndACAD = adsw_acadMainWnd(); m_page1.m_nGao = g_nHighBits-1; if (1 == nElecline) m_page1.m_nDian=0; else m_page1.m_nDian=1; m_page1.m_nWall = nWall; m_page1.m_nWallSimbol = nWallSimbol; m_page1.m_nXie = nXiepo; m_page1.m_dTian = dHatchSpace; m_page1.m_dKan = g_dKanHigh; m_page1.m_dGcd = g_dGcdHeight; m_page1.m_strWrdSty.Format(_T("%s"),g_szWordStyle); m_page1.m_dZdh = g_dZdhHeight; m_page1.m_dJzwHeight = g_dJzwHeight; m_page1.m_dLsxStep = g_dLsxStep; m_page1.m_nContinuous = g_nContinuous; m_page1.m_nXiepoline = g_nXiepoline; m_page1.m_bCenterLine = bCenterLine; m_page1.m_bHasCenterLine = bHasCenterLine; m_page1.m_bMakeRegion = bMakeRegion; m_page1.m_nZdType = g_nZdType; m_page1.m_dTextWidth = g_dTextFactor; m_page3.m_dDtm = dDtm; m_page3.m_nInmap = g_nInmapType; m_page3.m_nOutmap = g_nOutmapType; m_page3.m_nClose = g_nBmsbClose; m_page3.m_strUserdPath.Format(_T("%s"),g_szUsePath); m_page3.m_strMapinfo.Format(_T("%s"),szMapInfo); m_page3.m_nTransect = g_nTufaDeci; m_page3.m_nComputeArea = nComputeArea; m_page3.m_bKzdzj = g_bRegenKzdzj; m_page3.m_bGczj = g_bRegenGcdzj; m_page3.m_bJzwzj = g_bRegenJzwzj; m_page3.m_bIfDoukan = g_bIfDouKan; m_page3.m_nFGWGao = g_nFgwHighDeci; m_page3.m_nHgmDist = g_nHdmDistDeci; m_page3.m_nHgmGc = g_nHdmHighDeci; //电子平板 m_page2.m_nStation = nInstru; //全站仪型号 m_page2.m_nOvertime = nTimeOut; //延时 m_page2.m_nPort = nPort; //通讯口 m_page2.m_nCheck = nParity; //校验 m_page2.m_strBTL.Format(_T("%d"), nBaudRate); // if ( 2400 == nBaudRate ) m_page2.m_nBaud = 1; //波特率 // else if ( 4800 == nBaudRate )m_page2.m_nBaud = 2; // else if ( 9600 == nBaudRate ) m_page2.m_nBaud = 3; // else if (115200 == nBaudRate) m_page2.m_nBaud = 4; // else m_page2.m_nBaud = 0; if ( 7 == nByteSize ) m_page2.m_nData = 1; //数据位 else m_page2.m_nData = 0; if ( 2 == nStopBits ) m_page2.m_nStop = 1; //停止位 else m_page2.m_nStop = 0; m_page2.m_nZhandian = nZhandian; } void SetCassParam(CPara1Dlg &m_page1, CPara2Dlg &m_page2, CPara3Dlg &m_page3) { int nElecline=1,nWall=0,nWallSimbol=0,nXiepo=0,nTransect=1,nComputeArea=3; double dHatchSpace=20.0,dDtm=10.0; TCHAR szMapInfo[255]=_T("\\CASS9.0\\system\\MapInfo.db"); TCHAR TkChdw[100]=_T("单位名称"),TkCtrq[100]=_T("2002年3月数字化制图."); TCHAR TkZbx[100]=_T("任意直角坐标系: 坐标起点以 地方 为原点起算."); TCHAR TkGcjz[100]=_T("1985国家高程基准,等高距为1米."),TkTushi[100]=_T("2006年版图式."); TCHAR TkSurvey[100]=_T(""),TkDraw[100]=_T(""),TkCheck[100]=_T(""),TkSecret[255]=_T(""); BOOL bCenterLine = m_page1.m_bCenterLine, bHasCenterLine = m_page1.m_bHasCenterLine, bMakeRegion = m_page1.m_bMakeRegion; HKEY rKey; int nTemp; if ( false == seekdog() ) return; int nHighBits = 2, g_nInmapType = 0, g_nOutmapType = 0, g_nBmsbClose = 1, g_nContinuous = 0, g_nXiepoline = 0, g_bRegenKzdzj, g_bRegenGcdzj,g_bRegenJzwzj; double g_dZdhHeight = 1, g_dJzwHeight = 1, g_dLsxStep = 1; int nInstru = 24000; //全站仪型号 int nParity = 1; //校验 int nByteSize = 1;//数据位 int nTimeOut = 1;//延时 int nPort = 1;//通讯口 int nStopBits = 1;//停止位 int nBaudRate = 1;//波特率 int nZhandian = 1;//展点类型 //写入对话框 g_nHighBits = m_page1.m_nGao+1; if (0 == m_page1.m_nDian) nElecline=1; else nElecline=0; nWall = m_page1.m_nWall; nWallSimbol = m_page1.m_nWallSimbol; nXiepo = m_page1.m_nXie; dHatchSpace = m_page1.m_dTian; g_dKanHigh = m_page1.m_dKan; dDtm = m_page3.m_dDtm; g_dGcdHeight = m_page1.m_dGcd; _tcscpy(g_szWordStyle, m_page1.m_strWrdSty); g_dZdhHeight = m_page1.m_dZdh; g_dJzwHeight = m_page1.m_dJzwHeight; g_dLsxStep = m_page1.m_dLsxStep; g_nContinuous = m_page1.m_nContinuous; g_nXiepoline = m_page1.m_nXiepoline; g_nZdType = m_page1.m_nZdType; g_nInmapType = m_page3.m_nInmap; g_nOutmapType = m_page3.m_nOutmap; g_nBmsbClose = m_page3.m_nClose; _tcscpy(g_szUsePath, m_page3.m_strUserdPath); if ( '\\' != g_szUsePath[_tcslen(g_szUsePath)-1] ) _tcscat(g_szUsePath,_T("\\")); //2003.08.02 _tcscpy(szMapInfo, m_page3.m_strMapinfo); g_dTextFactor = m_page1.m_dTextWidth; g_nTufaDeci = m_page3.m_nTransect; nComputeArea = m_page3.m_nComputeArea; g_bRegenKzdzj = m_page3.m_bKzdzj; g_bRegenGcdzj = m_page3.m_bGczj; g_bRegenJzwzj = m_page3.m_bJzwzj; //电子平板 nInstru = m_page2.m_nStation; //全站仪型号 nTimeOut = m_page2.m_nOvertime; //延时 nPort = m_page2.m_nPort; //通讯口 nParity = m_page2.m_nCheck; //校验 nBaudRate = _ttoi(m_page2.m_strBTL); // if ( 1 == m_page2.m_nBaud ) nBaudRate = 2400; //波特率 // else if ( 2 == m_page2.m_nBaud ) nBaudRate = 4800; // else if ( 3 == m_page2.m_nBaud ) nBaudRate = 9600; // else if (4 == m_page2.m_nBaud) nBaudRate = 115200; // else nBaudRate = 1200; if ( 1 == m_page2.m_nData ) nByteSize = 7; //数据位 else nByteSize = 8; if ( 1 == m_page2.m_nStop ) nStopBits = 2; //停止位 else nStopBits = 0; nZhandian = m_page2.m_nZhandian; //展点 //写入注册表 DWORD result; if ( RegCreateKeyEx(HKEY_CURRENT_USER, CASS_REGSTER, 0, _T(""), REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &rKey, &result) != ERROR_SUCCESS) return; CassSetReg(rKey,_T("highbits"),g_nHighBits); //高程注记小数点位数 CassSetReg(rKey,_T("elecline"),nElecline); //电力线电杆间是否连线 CassSetReg(rKey,_T("wall"),nWall); //围墙端是否封口 CassSetReg(rKey,_T("wallsimbol"),nWallSimbol); //围墙端是否封口 CassSetReg(rKey,_T("xiepo"),nXiepo); //自然斜坡短线的长度 0--短 1--长 CassSetReg(rKey,_T("hatchspace"),dHatchSpace); //填充间距 CassSetReg(rKey,_T("kanhigh"),g_dKanHigh); //陡坎默认坎高 CassSetReg(rKey,_T("dtm"),dDtm); //DTM三角形最小角 CassSetReg(rKey,_T("inmaptype"),g_nInmapType); //生成交换文件选项 0--骨架线 1--图形元素 CassSetReg(rKey,_T("outmaptype"),g_nOutmapType); //读入交换文件选项 0--骨架线 1--图形元素 CassSetReg(rKey,_T("bmsbclose"),g_nBmsbClose); CassSetReg(rKey,_T("continuous"),g_nContinuous); CassSetReg(rKey,_T("xiepodi"),g_nXiepoline); CassSetReg(rKey,_T("zdtype"),g_nZdType); //展点注记选项 CassSetReg(rKey,_T("mapdbf"),szMapInfo); //图幅数据库名 CassSetReg(rKey,_T("userpath"),g_szUsePath); //用户工作目录名 CassSetReg(rKey,_T("gcdheight"),g_dGcdHeight); //高程点字高 CassSetReg(rKey,_T("gcdwordstyle"),g_szWordStyle); //高程点字高 CassSetReg(rKey,_T("zdhheight"),g_dZdhHeight); //展点号字高 CassSetReg(rKey,_T("jzwheight"),g_dJzwHeight); //建筑物字高 CassSetReg(rKey,_T("lsxstep"),g_dLsxStep); //流水线步长 CassSetReg(rKey,_T("textfactor"),g_dTextFactor); //文字宽高比 CassSetReg(rKey,_T("computearea"),nComputeArea); //面积计算小数位数 g_nFgwHighDeci = m_page3.m_nFGWGao; g_nHdmDistDeci = m_page3.m_nHgmDist; g_nHdmHighDeci = m_page3.m_nHgmGc; g_bIfDouKan = m_page3.m_bIfDoukan; CassSetReg(rKey, _T("tufangdoukan"), g_bIfDouKan); CassSetReg(rKey,_T("transect"),g_nTufaDeci); //土方量位数 CassSetReg(rKey,_T("fgwhighbits"),g_nFgwHighDeci); //方格网土方格网高程注记位数 CassSetReg(rKey,_T("hdmhighbits"),g_nHdmHighDeci); //横断面线高程注记位数 CassSetReg(rKey,_T("hdmdistbits"),g_nHdmDistDeci); //横断面线距离注记位数 if ( FALSE == g_bRegenGcdzj ) nTemp = 0; else nTemp = 1; CassSetReg(rKey,_T("regengcdzj"),nTemp); //重构高程点 if ( FALSE == g_bRegenKzdzj ) nTemp = 0; else nTemp = 1; CassSetReg(rKey,_T("regenkzdzj"),nTemp); //重构控制点 if ( FALSE == g_bRegenJzwzj ) nTemp = 0; else nTemp = 1; CassSetReg(rKey,_T("regenjzwzj"),nTemp); //重构建筑物注记 CassSetReg(rKey,_T("sc_enable"), m_page3.m_nEnableShortCuts); //是否启用快捷键 if (FALSE == bCenterLine) nTemp = 0; else nTemp = 1; CassSetReg(rKey, _T("road_centerlinemake"), nTemp); if (FALSE == bHasCenterLine) nTemp = 0; else nTemp = 1; CassSetReg(rKey, _T("road_hascenterline"), nTemp); if (FALSE == bMakeRegion) nTemp = 0; else nTemp = 1; CassSetReg(rKey, _T("road_makeregion"), nTemp); //电子平板 CassSetReg(rKey,_T("totalstation"), nInstru); //全站仪型号 nTemp = nBaudRate; CassSetReg(rKey,_T("baudrate"),nTemp); //波特率 CassSetReg(rKey,_T("parity"), nParity); //校验 CassSetReg(rKey,_T("ByteSize"), nByteSize); //数据位 CassSetReg(rKey,_T("timeout"), nTimeOut); //延时 CassSetReg(rKey,_T("port"), nPort); //通讯口 CassSetReg(rKey,_T("stopbits"), nStopBits); //停止位 CassSetReg(rKey,_T("dzpbzd"), nZhandian); //展点 //图框参数 /*CassSetReg(rKey,_T("tk_chdw"),TkChdw); CassSetReg(rKey,_T("tk_ctrq"),TkCtrq); CassSetReg(rKey,_T("tk_zbx"),TkZbx); CassSetReg(rKey,_T("tk_gcjz"),TkGcjz); CassSetReg(rKey,_T("tk_tushi"),TkTushi); CassSetReg(rKey,_T("tk_survey"),TkSurvey); CassSetReg(rKey,_T("tk_draw"),TkDraw); CassSetReg(rKey,_T("tk_check"),TkCheck); CassSetReg(rKey,_T("tk_secret"),TkSecret);*/ RegCloseKey(rKey); } void CTreePropSheet::ShowDongGuanSetUp() { CAcModuleResourceOverride myResources; //if( g_ThemeLib.IsAvailable() == FALSE) // { //g_ThemeLib.LoadLib(); // } #ifdef DONGGUAN #endif CDJParcelSetDlg wndPageZdt ; CMapFrameDlg mapframe ; CExplortToKMLdlg ProInfo; //投影参数 CGeoCrdDlg geocrd; CTextStyleSet textSet; CPara1Dlg param1; CPara2Dlg param2; CPara3Dlg param3; // disable help button wndPageZdt.m_psp.dwFlags&= ~PSP_HASHELP; mapframe.m_psp.dwFlags&= ~PSP_HASHELP; ProInfo.m_psp.dwFlags &= ~PSP_HASHELP; geocrd.m_psp.dwFlags &= ~PSP_HASHELP; textSet.m_psp.dwFlags &= ~PSP_HASHELP; param1.m_psp.dwFlags &= ~PSP_HASHELP; param2.m_psp.dwFlags &= ~PSP_HASHELP; param3.m_psp.dwFlags &= ~PSP_HASHELP; // set images CImageList DefaultImages, Images; DefaultImages.Create(IDB_DEFAULT, 16, 0, RGB(0x00, 0x80, 0x80)); Images.Create(IDB_IMAGES, 16, 0, RGB(0x00, 0x80, 0x80)); // TreePropSheet::CTreePropSheet::SetPageIcon( &wndPageZdt, Images, 0); TreePropSheet::CTreePropSheet::SetPageIcon( &mapframe, Images, 1); TreePropSheet::CTreePropSheet::SetPageIcon( &ProInfo, Images, 1); TreePropSheet::CTreePropSheet::SetPageIcon( &geocrd, Images, 1); TreePropSheet::CTreePropSheet::SetPageIcon( &textSet, Images, 1); TreePropSheet::CTreePropSheet sht(_T("CASS10综合设置")); InitCassParam(param1, param2, param3); sht.m_psh.dwFlags&= ~PSH_HASHELP; sht.AddPage( &wndPageZdt); sht.AddPage(&param1); sht.AddPage(&param2); sht.AddPage(&param3); sht.AddPage( &mapframe); sht.AddPage( &ProInfo); sht.AddPage( &geocrd); sht.AddPage(&textSet); sht.SetEmptyPageText(_T("请选择\"%s\"下任意一项,系统将为您设置所需信息.")); sht.SetTreeViewMode(TRUE, TRUE, TRUE); sht.SetTreeDefaultImages(&DefaultImages); sht.SetActivePage( &wndPageZdt); sht.SetTreeWidth(170); sht.DoModal(); DefaultImages.DeleteImageList(); Images.DeleteImageList(); SetCassParam(param1, param2, param3); //通知其他ARX struct resbuf *cmd,*res; cmd=ads_buildlist(RTSTR,_T("cassapara"),RTNONE); ads_invoke(cmd,&res); ads_relrb(cmd); ads_relrb(res); cmd=ads_buildlist(RTSTR,_T("landformpara"),RTNONE); ads_invoke(cmd,&res); ads_relrb(cmd); ads_relrb(res); cmd=ads_buildlist(RTSTR,_T("cass9para"),RTNONE); ads_invoke(cmd,&res); ads_relrb(cmd); ads_relrb(res); cmd=ads_buildlist(RTSTR,_T("djzdtpara"),RTNONE); ads_invoke(cmd,&res); ads_relrb(cmd); ads_relrb(res); ReadRegValue(); } //显示设置对话框 void CTreePropSheet::ShowSetUp() { #ifdef DONGGUAN ShowDongGuanSetUp(); return; #endif CAcModuleResourceOverride myResources; //if( g_ThemeLib.IsAvailable() == FALSE) // { //g_ThemeLib.LoadLib(); // } CDjParamDlg wndPageZdt ; CJzpParamDlg wndPageJzp ; // CDjReportParamDlg wndPageReport; #ifdef _XIANGTAN_KCSJY CTKSX95Dlg mapframe; #else CMapFrameDlg mapframe ; #endif CExplortToKMLdlg ProInfo; //投影参数 CGeoCrdDlg geocrd; CTextStyleSet textSet; CPara1Dlg param1; CPara2Dlg param2; CPara3Dlg param3; CParaXBLDlg xblpage; // disable help button wndPageZdt.m_psp.dwFlags&= ~PSP_HASHELP; wndPageJzp.m_psp.dwFlags&= ~PSP_HASHELP; //wndPageReport.m_psp.dwFlags&= ~PSP_HASHELP; mapframe.m_psp.dwFlags&= ~PSP_HASHELP; ProInfo.m_psp.dwFlags &= ~PSP_HASHELP; geocrd.m_psp.dwFlags &= ~PSP_HASHELP; textSet.m_psp.dwFlags &= ~PSP_HASHELP; param1.m_psp.dwFlags &= ~PSP_HASHELP; param2.m_psp.dwFlags &= ~PSP_HASHELP; param3.m_psp.dwFlags &= ~PSP_HASHELP; xblpage.m_psp.dwFlags &= ~PSP_HASHELP; // set images CImageList DefaultImages, Images; DefaultImages.Create(IDB_DEFAULT, 16, 0, RGB(0x00, 0x80, 0x80)); Images.Create(IDB_IMAGES, 16, 0, RGB(0x00, 0x80, 0x80)); // TreePropSheet::CTreePropSheet::SetPageIcon( &wndPageZdt, Images, 0); TreePropSheet::CTreePropSheet::SetPageIcon( &wndPageJzp, Images, 1); //TreePropSheet::CTreePropSheet::SetPageIcon( &wndPageReport, Images, 1); TreePropSheet::CTreePropSheet::SetPageIcon( &mapframe, Images, 1); TreePropSheet::CTreePropSheet::SetPageIcon( &ProInfo, Images, 1); TreePropSheet::CTreePropSheet::SetPageIcon( &geocrd, Images, 1); TreePropSheet::CTreePropSheet::SetPageIcon( &textSet, Images, 1); TreePropSheet::CTreePropSheet sht(_T("CASS10综合设置")); InitCassParam(param1, param2, param3); sht.m_psh.dwFlags&= ~PSH_HASHELP; sht.AddPage(&param1); sht.AddPage(&param2); sht.AddPage(&param3); sht.AddPage( &wndPageZdt); sht.AddPage( &wndPageJzp); //sht.AddPage( &wndPageReport); sht.AddPage( &mapframe); sht.AddPage( &ProInfo); sht.AddPage( &geocrd); sht.AddPage(&textSet); sht.AddPage(&xblpage); sht.SetEmptyPageText(_T("请选择\"%s\"下任意一项,系统将为您设置所需信息.")); sht.SetTreeViewMode(TRUE, TRUE, TRUE); sht.SetTreeDefaultImages(&DefaultImages); sht.SetActivePage( &param1); sht.SetTreeWidth(170); sht.DoModal(); DefaultImages.DeleteImageList(); Images.DeleteImageList(); SetCassParam(param1, param2, param3); //通知其他ARX struct resbuf *cmd,*res; cmd=ads_buildlist(RTSTR,_T("cassapara"),RTNONE); ads_invoke(cmd,&res); ads_relrb(cmd); ads_relrb(res); cmd=ads_buildlist(RTSTR,_T("landformpara"),RTNONE); ads_invoke(cmd,&res); ads_relrb(cmd); ads_relrb(res); cmd=ads_buildlist(RTSTR,_T("cass9para"),RTNONE); ads_invoke(cmd,&res); ads_relrb(cmd); ads_relrb(res); cmd=ads_buildlist(RTSTR,_T("djzdtpara"),RTNONE); ads_invoke(cmd,&res); ads_relrb(cmd); ads_relrb(res); ReadRegValue(); //if( g_ThemeLib.IsAvailable() == TRUE) { //g_ThemeLib.FreeLib(); } } } //namespace TreePropSheet
06-18
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值