BOOL CRasterPropPage::OnInitDialog() { CPropertyPage::OnInitDialog(); if(!m_player) { return FALSE; } Geodatabase::IRasterDatasetPtr pRaster = m_player->GetDataObject(); Carto::CRasterLayer* pRasLayer = dynamic_cast<Carto::CRasterLayer*>(m_player); Carto::CRasterRGBRender* pRGBRender = dynamic_cast<Carto::CRasterRGBRender*>(pRasLayer->GetRender().get()); CRect rectPropList; m_wndPropListLocation.GetClientRect (&rectPropList); m_wndPropListLocation.MapWindowPoints (this, &rectPropList); m_wndPropList.Create (WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, rectPropList, this, (UINT)-1); m_wndPropList.EnableHeaderCtrl (TRUE,"属性","值"); //m_wndPropList.EnableDesciptionArea (); m_wndPropList.SetVSDotNetLook (TRUE); //m_wndPropList.MarkModifiedProperties (m_bMarkChanged); //m_wndPropList.SetAlphabeticMode (!m_bPropListCategorized); //m_wndPropList.SetShowDragContext (m_bShowDragContext); CBCGPProp* pGroup1 = new CBCGPProp (_T("基本属性")); CBCGPProp* pProp; // 图像大小 long lwidth,lheight; pRaster->GetSize(&lwidth,&lheight); CBCGPProp* pSize = new CBCGPProp (_T("图像大小"), 0, TRUE); pProp = new CBCGPProp (_T("宽"), (_variant_t) lwidth); pProp->AllowEdit (FALSE); pSize->AddSubItem (pProp); pProp = new CBCGPProp (_T("高"), (_variant_t) lheight); pProp->AllowEdit (FALSE); pSize->AddSubItem (pProp); pGroup1->AddSubItem(pSize); //像素大小 double dx,dy; pRaster->GetCellSize(&dx,&dy); CBCGPProp* pCellSize = new CBCGPProp (_T("像素大小"), 0, TRUE); pProp = new CBCGPProp (_T("X"), (_variant_t) dx); pProp->AllowEdit (FALSE); pCellSize->AddSubItem (pProp); pProp = new CBCGPProp (_T("Y"), (_variant_t) dy); pProp->AllowEdit (FALSE); pCellSize->AddSubItem (pProp); pGroup1->AddSubItem(pCellSize); //波段数 long lband =pRaster->GetBandCount(); CBCGPProp* pBand = new CBCGPProp (_T("波段数"), (_variant_t) lband); pGroup1->AddSubItem(pBand); //波段组合 pBand = new CBCGPProp (_T("波段组合"), (_variant_t) lband,TRUE); pBand->AllowEdit (FALSE); if (lband > 1&&pRGBRender) { pProp = new CBCGPProp (_T("红"), (_variant_t)pRGBRender->GetRedBandIndex(),_T("")); pProp->EnableSpinControl (TRUE, 1, lband); pBand->AddSubItem (pProp); pProp = new CBCGPProp (_T("绿"), (_variant_t)pRGBRender->GetGreenBandIndex(),_T("")); pProp->EnableSpinControl (TRUE, 1, lband); pBand->AddSubItem (pProp); pProp = new CBCGPProp (_T("蓝"), (_variant_t)pRGBRender->GetBlueBandIndex(),_T("")); pProp->EnableSpinControl (TRUE, 1, lband); pBand->AddSubItem (pProp); } pGroup1->AddSubItem(pBand); //数据类型 Geodatabase::BANDDATATYPE datatype= pRaster->GetBandDataType(1); CString strType; switch(datatype) { case Geodatabase::BDT_BYTE: { strType ="无符号8位"; break; } case Geodatabase::BDT_SHORT: { strType ="16位整型"; break; } case Geodatabase::BDT_USHORT: { strType ="无符号16位整型"; break; } case Geodatabase::BDT_LONG: { strType ="32位整型"; break; } case Geodatabase::BDT_FLOAT: { strType ="32位浮点型"; break; } case Geodatabase::BDT_DOUBLE: { strType ="64位浮点型"; break; } default: strType ="未知"; break; } pProp =new CBCGPProp (_T("数据类型"), (_variant_t) strType); pProp->AllowEdit (FALSE); pGroup1->AddSubItem(pProp); BYTE byRed[256]; BYTE byGreen[256]; BYTE byBlue[256]; if (pRaster->GetChannelPalette(1, byRed,byGreen,byBlue)) { CBCGPProp* pPalette = new CBCGPProp (_T("调色板")); pPalette->AllowEdit (FALSE); pGroup1->AddSubItem(pPalette); for (int i=0; i<256; i++) { CString str; str.Format("%d",i); CBCGPColorProp* pColorProp = new CBCGPColorProp(str, RGB(byRed[i],byGreen[i],byBlue[i]),NULL); pColorProp->EnableOtherButton (_T("Other...")); pColorProp->EnableAutomaticButton (_T("Default"), ::GetSysColor (COLOR_3DFACE)); pPalette->AddSubItem (pColorProp); } } m_wndPropList.AddProperty (pGroup1); m_wndPropList.ExpandAll(); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE }
void CPropertiesViewBar::InitPropList () { SetPropListFont (); m_wndPropList.EnableHeaderCtrl (FALSE); m_wndPropList.EnableDesciptionArea (); m_wndPropList.SetVSDotNetLook (); m_wndPropList.MarkModifiedProperties (); CBCGPProp* pGroup1 = new CBCGPProp (_T("Appearance")); pGroup1->AddSubItem (new CBCGPProp (_T("3D Look"), (_variant_t) false, _T("Specifies the dialog's font will be nonbold and controls will have a 3D border"))); CBCGPProp* pProp = new CBCGPProp (_T("Border"), _T("Dialog Frame"), _T("One of: None, Thin, Resizable, or Dialog Frame")); pProp->AddOption (_T("None")); pProp->AddOption (_T("Thin")); pProp->AddOption (_T("Resizable")); pProp->AddOption (_T("Dialog Frame")); pProp->AllowEdit (FALSE); pGroup1->AddSubItem (pProp); pGroup1->AddSubItem (new CBCGPProp (_T("Caption"), (_variant_t) _T("About BCGProTest"), _T("Specifies the text that will be displayed in the dialog's title bar"))); m_wndPropList.AddProperty (pGroup1); CBCGPProp* pSize = new CBCGPProp (_T("Window Size"), 0, TRUE); pProp = new CBCGPProp (_T("Height"), (_variant_t) 250l, _T("Specifies the dialog's height")); pProp->EnableSpinControl (TRUE, 0, 1000); pSize->AddSubItem (pProp); pProp = new CBCGPProp ( _T("Width"), (_variant_t) 150l, _T("Specifies the dialog's width")); pProp->EnableSpinControl (); pSize->AddSubItem (pProp); m_wndPropList.AddProperty (pSize); CBCGPProp* pGroup2 = new CBCGPProp (_T("Font")); LOGFONT lf; CFont* font = CFont::FromHandle ((HFONT) GetStockObject (DEFAULT_GUI_FONT)); font->GetLogFont (&lf); lstrcpy (lf.lfFaceName, _T("Arial")); pGroup2->AddSubItem (new CBCGPFontProp (_T("Font"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("Specifies the default font for the dialog"))); pGroup2->AddSubItem (new CBCGPProp (_T("Use System Font"), (_variant_t) true, _T("Specifies that the dialog uses MS Shell Dlg font"))); m_wndPropList.AddProperty (pGroup2); CBCGPProp* pGroup3 = new CBCGPProp (_T("Misc")); pProp = new CBCGPProp (_T("(Name)"), _T("IDD_ABOUT_BOX (dialog)")); pProp->Enable (FALSE); pGroup3->AddSubItem (pProp); CBCGPColorProp* pColorProp = new CBCGPColorProp (_T("Window Color"), RGB (210, 192, 254), NULL, _T("Specifies the default dialog color")); pColorProp->EnableOtherButton (_T("Other...")); pColorProp->EnableAutomaticButton (_T("Default"), ::GetSysColor (COLOR_3DFACE)); pGroup3->AddSubItem (pColorProp); static TCHAR BASED_CODE szFilter[] = _T("Icon Files (*.ico)|*.ico|All Files (*.*)|*.*||"); pGroup3->AddSubItem (new CBCGPFileProp (_T("Icon"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("Specifies the dialog icon"))); pGroup3->AddSubItem (new CBCGPFileProp (_T("Folder"), _T("c:\\"))); COleDateTime date = COleDateTime::GetCurrentTime (); pGroup3->AddSubItem (new CBCGPDateTimeProp (_T("Date"), date, _T("Set a date"), 0, CBCGPDateTimeCtrl::DTM_DATE)); pGroup3->AddSubItem (new CBCGPDateTimeProp (_T("Time"), date, _T("Set a time"), 0, CBCGPDateTimeCtrl::DTM_TIME)); m_wndPropList.AddProperty (pGroup3); CBCGPProp* pGroup4 = new CBCGPProp (_T("Hierarchy")); CBCGPProp* pGroup41 = new CBCGPProp (_T("First sub-level")); pGroup4->AddSubItem (pGroup41); CBCGPProp* pGroup411 = new CBCGPProp (_T("Second sub-level")); pGroup41->AddSubItem (pGroup411); pGroup411->AddSubItem (new CBCGPProp (_T("Item 1"), (_variant_t) _T("Value 1"), _T("This is a description"))); pGroup411->AddSubItem (new CBCGPProp (_T("Item 2"), (_variant_t) _T("Value 2"), _T("This is a description"))); pGroup411->AddSubItem (new CBCGPProp (_T("Item 3"), (_variant_t) _T("Value 3"), _T("This is a description"))); pGroup4->Expand (FALSE); m_wndPropList.AddProperty (pGroup4); }