青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

MFC+D3D+ToolKitPro

MFC+D3D+ToolKitPro

C++博客 首頁 新隨筆 聯(lián)系 聚合 管理
  3 Posts :: 0 Stories :: 9 Comments :: 0 Trackbacks

2008年8月21日 #

由于最近寫工具要使用xml來存儲腳本,所以看了一些xml的c++相關(guān)內(nèi)容
網(wǎng)上好多關(guān)于tinyxml的文檔看了好多總是覺得比較麻煩,所以決定自己寫一個類來封裝它
這個類封裝的不是很全面,但已經(jīng)基本夠我使用了,有興趣的朋友可以再繼續(xù)完善他,
讓不懂xml內(nèi)部原理的朋友們也可以方便使用xml格式文件存儲數(shù)據(jù)

這是測試項目,vc71版本,我喜歡用2003,哈哈
/Files/hwawai/CXML_vc71.7z
如果大家有什么更好的代碼來處理xml希望踴躍交流

頭文件
#pragma once
#include<string>
#include "tinyxml.h"
using namespace std;
class CXML
{
public:
 CXML(void);
 ~CXML(void);
 
 bool ParseXmlFile(const char* xmlFile);
 TiXmlElement* GetElement(const char* parentTitle,const char* title);//此函數(shù)需一層一層遞進
 bool getElementAttributeValue(TiXmlElement* Element,const char* AttributeName,string& reslut);
 bool getFirstElementValue(const char* title,string& result);
 bool getNextElementValue(const char* title,string& result);
 TiXmlElement* getRootElement();
 void Clear();
 //////////////////////////////////////////////////////////////////////////
 TiXmlElement* addXmlRootElement(const char* title);
 TiXmlElement* addXmlChildElement(TiXmlElement* pElement,const char* title);
 void addXmlAttribute(TiXmlElement* pElement,const char* name,const char* value);
 void addXmlDeclaration(const char* vesion="1.0",const char* encoding="gb2312",const char* standalone="");
 void addElementValue(TiXmlElement* pElement,const char* value);
 void addXmlComment(TiXmlElement* pElement,const char* Comment);
 void saveFile(const char* file);
protected:
 TiXmlDocument m_xml;
 TiXmlElement* pElement;   // 獲取NextElementValue使用,屬臨時變量
 TiXmlElement* getFirstElement(const char* ElementMark,TiXmlElement* pcrElement);
};

源文件
#include "StdAfx.h"
#include ".\xml.h"

CXML::CXML(void)
{
}

CXML::~CXML(void)
{
}

bool CXML::ParseXmlFile(const char* xmlFile)
{
 return m_xml.LoadFile(xmlFile)?1:0;
}

TiXmlElement* CXML::GetElement(const char* parentTitle,const char* title)
{
 TiXmlNode* _=m_xml.FirstChildElement(parentTitle);
 for(_=_->FirstChild();_;_=_->NextSibling())
 {
  if (!strcmp(title,_->Value()))
  {
   return _->ToElement();
  }
 }
 return 0;
}

bool CXML::getElementAttributeValue(TiXmlElement* Element,const char* AttributeName,string& reslut)
{
 if(Element->Attribute(AttributeName))
 {
  reslut=Element->Attribute(AttributeName);
  return 1;
 }
 return 0;
}

bool CXML::getFirstElementValue(const char* title,string& result)
{
 if(!title)
  return 0;
 TiXmlElement* _(0);
 _=m_xml.RootElement();
 _=getFirstElement(title,_);
 if(_)
 {
  pElement=_;
  result=pElement->GetText();
  return 1;
 }
 return 0;
}

bool CXML::getNextElementValue(const char* title,string& result)
{
 result="";
 pElement=pElement->NextSiblingElement(title);
 if(pElement)
 {
  result=pElement->GetText();
  return 1;
 }
 return 0;
}

TiXmlElement* CXML::getRootElement()
{
 return m_xml.RootElement();
}

void CXML::Clear()
{
 m_xml.Clear();
}

//////////////////////////////////////////////////////////////////////////
TiXmlElement* CXML::addXmlRootElement(const char* title)
{
 TiXmlElement* _=new TiXmlElement(title);
 m_xml.LinkEndChild(_);
 return _;
}

TiXmlElement* CXML::addXmlChildElement(TiXmlElement* pElement,const char* title)
{
 if(pElement)
 {
  TiXmlElement* _=new TiXmlElement(title);
  pElement->LinkEndChild(_);
  return _;
 }
 return 0;
}

void CXML::addXmlAttribute(TiXmlElement* pElement,const char* name,const char* value)
{
 if(pElement)
 {
  pElement->SetAttribute(name,value);
 }
}

void CXML::addXmlDeclaration(const char* vesion,const char* encoding,const char* standalone)
{
 TiXmlDeclaration *_=new TiXmlDeclaration(vesion,encoding,standalone);
 m_xml.LinkEndChild(_);
}

void CXML::addElementValue(TiXmlElement *pElement,const char* value)
{
 if(pElement)
 {
  TiXmlText *_=new TiXmlText(value);
  pElement->LinkEndChild(_);
 }
}
 
void CXML::addXmlComment(TiXmlElement* pElement,const char* Comment)
{
 if(pElement)
 {
  TiXmlComment *_=new TiXmlComment(Comment);
  pElement->LinkEndChild(_);
 }
}

void CXML::saveFile(const char* file)
{
 m_xml.SaveFile(file);
}

//////////////////////////////////////////////////////////////////////////
TiXmlElement* CXML::getFirstElement(const char* ElementMark,TiXmlElement* pcrElement)
{
 TiXmlElement* _=pcrElement; 
 while(_)
 {
  if(strcmp(_->Value(),ElementMark)==0)
  {
   //printf("%s\r\n",pElementtmp->Value());
   return _;
  }
  else
  {
   TiXmlElement* nextElement=_->FirstChildElement();
   while(nextElement)
   {
    //printf("%s\r\n",nextElement->Value());
    if(strcmp(nextElement->Value(),ElementMark)==0)
    {
     return nextElement;
    }
    else
    {
     TiXmlElement* reElement=NULL;
     reElement=getFirstElement(ElementMark,nextElement);
     if(reElement)
     {
      return reElement;
     }
    }
    nextElement=nextElement->NextSiblingElement();
   }
  }
  _=_->NextSiblingElement();
 }
 return NULL;
}


stdafx文件
#pragma once
#include <iostream>
#include <tchar.h>

用來測試的主cpp文件
#include "stdafx.h"
#include "tinyxml//XML.h"
#include <iostream>

void createXML()
{
 CXML xml;
 xml.addXmlDeclaration("1.0","gb2312","");
 TiXmlElement* root=xml.addXmlRootElement("fields");
 TiXmlElement* pElement=xml.addXmlChildElement(root,"pos");
 xml.addXmlAttribute(pElement,"x","100");
 xml.addXmlAttribute(pElement,"y","200.1");
 xml.addXmlAttribute(pElement,"z","0.123");

 TiXmlElement* pElement2=xml.addXmlChildElement(root,"dest");
 xml.addXmlAttribute(pElement2,"x","一二三");
 xml.addXmlAttribute(pElement2,"y","一二");
 xml.addXmlAttribute(pElement2,"z","一");
 xml.saveFile("1.xml");
}

void CreateXML1()
{
 CXML xml;
 xml.addXmlDeclaration();
    TiXmlElement* root=xml.addXmlRootElement("fields");
 xml.addXmlComment(root,"AAAAAAA");
 TiXmlElement* pElement=xml.addXmlChildElement(root,"pos_x");
 xml.addElementValue(pElement,"1.3");
 pElement=xml.addXmlChildElement(root,"pos_x");
 xml.addElementValue(pElement,"30.1");
 pElement=xml.addXmlChildElement(root,"pos_x");
 xml.addElementValue(pElement,"30ssss.1");
 xml.saveFile("2.xml");
}


void LoadXML()
{
 CXML xml;
 xml.ParseXmlFile("1.xml");
 string a;
 TiXmlElement* pElement=xml.GetElement("fields","dest");
   xml.getElementAttributeValue(pElement,"x",a);
  cout<<a<<endl;
  xml.getElementAttributeValue(pElement,"y",a);
  cout<<a<<endl;
  xml.getElementAttributeValue(pElement,"z",a);
  cout<<a<<endl;
}

void LoadXML1()
{
 CXML xml;
 xml.ParseXmlFile("2.xml");
 string a;
 xml.getFirstElementValue("pos_x",a);
 cout<<a<<endl;
 xml.getNextElementValue("pos_x",a);
  cout<<a<<endl;
 xml.getNextElementValue("pos_x",a);
 cout<<a<<endl;
}

int _tmain(int argc, _TCHAR* argv[])
{
//  createXML();
//  LoadXML(); 
  CreateXML1();
  LoadXML1(); 
 getchar();
 return 0;
}


生成的xml文件
1.xml
<?xml version="1.0" encoding="gb2312" ?>
<fields>
    <pos x="100" y="200.1" z="0.123" />
    <dest x="一二三" y="一二" z="一" />
</fields>

2.xml
<?xml version="1.0" encoding="gb2312" ?>
<fields>
    <!--AAAAAAA-->
    <pos_x>1.3</pos_x>
    <pos_x>30.1</pos_x>
    <pos_x>30ssss.1</pos_x>
</fields>

posted @ 2008-08-21 15:45 hwawai 閱讀(3181) | 評論 (6)編輯 收藏

2008年8月19日 #

最近做了個模型查看器使用了ToolKitPro
中的屬性表組件









覺得這個組件太適合寫一些游戲工具之類的了。
posted @ 2008-08-19 13:51 hwawai 閱讀(1197) | 評論 (0)編輯 收藏


這篇是好久之前自己最初貼在cdsn上的帖子,現(xiàn)在也挪到這里算是開篇吧




 




這是根據(jù)原代碼例子改的中文版界面,主要是在OnInitDialog里面的代碼我都寫了注釋,有興趣大家一起研究一下

BOOL CPropGridDlg::OnInitDialog()
{
 //  CDialog::OnInitDialog();
 CPropertyGridDlgBase::OnInitDialog();

 // 將\“關(guān)于...\”菜單項添加到系統(tǒng)菜單中。

 // IDM_ABOUTBOX 必須在系統(tǒng)命令范圍內(nèi)。
 ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
 ASSERT(IDM_ABOUTBOX < 0xF000);

 CMenu* pSysMenu = GetSystemMenu(FALSE);
 if (pSysMenu != NULL)
 {
  CString strAboutMenu;
  strAboutMenu.LoadString(IDS_ABOUTBOX);
  if (!strAboutMenu.IsEmpty())
  {
   pSysMenu->AppendMenu(MF_SEPARATOR);
   pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  }
 }

 // 設(shè)置此對話框的圖標。當應(yīng)用程序主窗口不是對話框時,框架將自動
 //  執(zhí)行此操作
 SetIcon(m_hIcon, TRUE);   // 設(shè)置大圖標
 SetIcon(m_hIcon, FALSE);  // 設(shè)置小圖標

 // TODO: 在此添加額外的初始化代碼
 //////////////////////////////////////////////////////////////////////////
 // 獲得圖片框矩形
 CRect rc;
 m_wndPlaceHolder.GetWindowRect( &rc );
 // 轉(zhuǎn)為窗口坐標
 ScreenToClient( &rc );
 // 建立屬性表
 if ( m_wndPropertyGrid.Create( rc, this, IDC_PROPERTY_GRID  ) )
 {
  m_wndPropertyGrid.SetVariableItemsHeight(TRUE);
  // 獲取邏輯字體
  LOGFONT lf;
  GetFont()->GetLogFont( &lf );
  // create document settings category.
  // 建立分類
  CXTPPropertyGridItem* pSettings        = m_wndPropertyGrid.AddCategory(_T("Document Settings"));
  // 設(shè)置TOOLTIP
  pSettings->SetTooltip(_T("Document Settings Category"));

  // add child items to category.
  // 建立bool內(nèi)容
  CXTPPropertyGridItem* pItemSaveOnClose = pSettings->AddChildItem(new CXTPPropertyGridItemBool(_T("SaveOnClose"), TRUE));
  // 建立字體內(nèi)容
  pSettings->AddChildItem(new CXTPPropertyGridItemFont(_T("WindowFont"), lf));
  // 建立size內(nèi)容
  pSettings->AddChildItem(new CXTPPropertyGridItemSize(_T("WindowSize"), CSize(100, 100)));
  
  // 展開
  pSettings->Expand();
  // 選擇
  pItemSaveOnClose->Select();

  // create global settings category.
  // 建立分類
  CXTPPropertyGridItem* pGlobals      = m_wndPropertyGrid.AddCategory(_T("Global Settings"));

  // add child items to category.
  // 建立只讀字符串內(nèi)容
  CXTPPropertyGridItem* pItemGreeting = pGlobals->AddChildItem(new CXTPPropertyGridItem(_T("Greeting Text"), _T("Welcome to your application!")));
  pItemGreeting->SetReadOnly(TRUE);
  // 建立整數(shù)內(nèi)容
  pGlobals->AddChildItem(new CXTPPropertyGridItemNumber(_T("ItemsInMRUList"), 4));
  // 設(shè)置說明
  CXTPPropertyGridItem* pItemRate     = pGlobals->AddChildItem(new CXTPPropertyGridItemNumber(_T("MaxRepeatRate"), 10));
  pItemRate->SetDescription(_T("The rate in milliseconds that the text will repeat."));
  // 建立color內(nèi)容
  pGlobals->AddChildItem(new CXTPPropertyGridItemColor(_T("ToolbarColor"), RGB(255, 192,128)));

  
  
  //////////////////////////////////////////////////////////////////////////
  // Version category.
  // 建立分類
  CXTPPropertyGridItem* pVersion      = m_wndPropertyGrid.AddCategory(_T("Version"));

  // add child items to category.
  // 建立只讀字符串內(nèi)容
  CXTPPropertyGridItem* pItemVersion  = pVersion->AddChildItem(new CXTPPropertyGridItem(_T("AppVersion"), _T("1.0")));
  pItemVersion->SetReadOnly(TRUE);
  // 使用資源建立字符串內(nèi)容
  CXTPPropertyGridItem* pItemLanguage = pVersion->AddChildItem(new CXTPPropertyGridItem(ID_ITEM_VERSION_LANGUAGE, _T("English (United States)")));
  // 展開分類
  pVersion->Expand();

  // 將combo連接到字符串內(nèi)容中
  // 測試結(jié)果 只要不是只讀的字符串內(nèi)容就可連接combo 步驟如下
  // 獲取item的Constraints
  CXTPPropertyGridItemConstraints* pList = pItemLanguage->GetConstraints();
  // 添加combo內(nèi)容
  pList->AddConstraint(_T("Neutral"));
  pList->AddConstraint(_T("Arabic"));
  pList->AddConstraint(_T("German"));
  pList->AddConstraint(_T("Chinese(Taiwan)"));
  pList->AddConstraint(_T("English (United Kingdom)"));
  pList->AddConstraint(_T("English (United States)"));
  pList->AddConstraint(_T("France"));
  pList->AddConstraint(_T("Russian"));
  pList->AddConstraint(_T("簡體中文"));
  pList->AddConstraint(_T("英文"));
  pList->AddConstraint(_T("日文"));
  // 設(shè)置combo為可編輯組合框
  pItemLanguage->SetFlags(xtpGridItemHasComboButton | xtpGridItemHasEdit);

  //////////////////////////////////////////////////////////////////////////
  // Dynamic Options
  // 建立分類
  CXTPPropertyGridItem* pCategoryDynamic = m_wndPropertyGrid.AddCategory(_T("Dynamic Options"));
  // 建立bool內(nèi)容
  // 這是第2種方式 強制轉(zhuǎn)換指針方式
  CXTPPropertyGridItemBool* pItemBool = (CXTPPropertyGridItemBool*)pCategoryDynamic->AddChildItem(
   new CXTPPropertyGridItemBool(_T("Advanced"), FALSE));
  // 設(shè)置ID
  pItemBool->SetID(501);
  // 設(shè)置checkbox樣式
  pItemBool->SetCheckBoxStyle();
  // 建立bool內(nèi)容checkbox樣式并隱藏
  pItemBool = (CXTPPropertyGridItemBool*)pCategoryDynamic->AddChildItem(
   new CXTPPropertyGridItemBool(_T("Option 1"), FALSE));
  pItemBool->SetHidden(TRUE);
  pItemBool->SetCheckBoxStyle();
  // 建立bool內(nèi)容checkbox樣式并隱藏
  pItemBool = (CXTPPropertyGridItemBool*)pCategoryDynamic->AddChildItem(
   new CXTPPropertyGridItemBool(_T("Option 2"), FALSE));
  pItemBool->SetHidden(TRUE);
  pItemBool->SetCheckBoxStyle();
  // 建立bool內(nèi)容checkbox樣式并隱藏
  pItemBool = (CXTPPropertyGridItemBool*)pCategoryDynamic->AddChildItem(
   new CXTPPropertyGridItemBool(_T("Option 3"), FALSE));
  pItemBool->SetHidden(TRUE);
  pItemBool->SetCheckBoxStyle();
  // 建立bool內(nèi)容checkbox樣式并隱藏和只讀
  pItemBool = (CXTPPropertyGridItemBool*)pCategoryDynamic->AddChildItem(
   new CXTPPropertyGridItemBool(_T("Option 4"), TRUE));
  pItemBool->SetHidden(TRUE);
  pItemBool->SetCheckBoxStyle();
  pItemBool->SetReadOnly();

  // create standard items category.
  // 建立分類
  CXTPPropertyGridItem* pStandard   = m_wndPropertyGrid.AddCategory(_T("Standard Items"));
  // 建立字符串內(nèi)容
  pStandard->AddChildItem(new CXTPPropertyGridItem(_T("String item")));
  // 建立多行字符串下拉框 幫助文件中沒有
  pStandard->AddChildItem(new CXTPPropertyGridItemMultilineString(_T("Multiline String item"), _T("1\r\n2")));
  // 建立整數(shù)內(nèi)容
  pStandard->AddChildItem(new CXTPPropertyGridItemNumber(_T("Integer item")));
  // 建立double內(nèi)容并設(shè)置初始值和數(shù)據(jù)格式
  pStandard->AddChildItem(new CXTPPropertyGridItemDouble(_T("Double item"),0,"%0.3f"));
  // 建立顏色bool字體
  pStandard->AddChildItem(new CXTPPropertyGridItemColor(_T("Color item")));
  pStandard->AddChildItem(new CXTPPropertyGridItemBool(_T("Bool item")));
  pStandard->AddChildItem(new CXTPPropertyGridItemFont(_T("Font item"), lf));
  // mfc時間類COleDateTime
  COleDateTime dates(1981, 1, 26, 0, 0, 0 );
  // 使用COleDateTime建立時間內(nèi)容
  pStandard->AddChildItem(new CXTPPropertyGridItemDate(_T("Date item"), dates));
  // 建立size內(nèi)容
  pStandard->AddChildItem(new CXTPPropertyGridItemSize(_T("Size item")));
  // 建立enum內(nèi)容
  CXTPPropertyGridItem* pItem = pStandard->AddChildItem(new CXTPPropertyGridItemEnum(_T("Enum item"), 1));
  // 添加enum記錄到enum內(nèi)容呈combo樣式
  pItem->GetConstraints()->AddConstraint(_T("Windows 98"), 1);
  pItem->GetConstraints()->AddConstraint(_T("Windows 2000"), 2);
  pItem->GetConstraints()->AddConstraint(_T("Windows XP"), 3);

  // 建立flag內(nèi)容 第2個參數(shù)"1+2"為初始值 即"Windows 98"和"Windows 2000"為真
  // 且flag的元素數(shù)值需為1,2,4,8,16,32...
  pItem = pStandard->AddChildItem(new CXTPPropertyGridItemFlags(_T("Flag item"), 1 + 2));
  pItem->GetConstraints()->AddConstraint(_T("All Windows"), 1 + 2 + 4);
  pItem->GetConstraints()->AddConstraint(_T("Windows 98"), 1);
  pItem->GetConstraints()->AddConstraint(_T("Windows 2000"), 2);
  pItem->GetConstraints()->AddConstraint(_T("Windows XP"), 4); 

  //////////////////////////////////////////////////////////////////////////
  // 建立分類
  CXTPPropertyGridItem* pButtons   = m_wndPropertyGrid.AddCategory(_T("Standard Buttons"));
  // 建立bool內(nèi)容
  pItem = pButtons->AddChildItem(new CXTPPropertyGridItemBool(_T("Combo Button")));
  // 設(shè)置為combo樣式
  pItem->SetFlags(xtpGridItemHasComboButton);
  // 建立字符串內(nèi)容
  pItem = pButtons->AddChildItem(new CXTPPropertyGridItem(_T("Expand Button")));
  // 設(shè)置為可編輯并帶有擴展按鈕樣式
  pItem->SetFlags(xtpGridItemHasEdit | xtpGridItemHasExpandButton);
  // 建立字符串內(nèi)容
  pItem = pButtons->AddChildItem(new CXTPPropertyGridItem(_T("2 Buttons")));
  // 設(shè)置ID
  pItem->SetID(510);
  // 設(shè)置為可編輯并帶有擴展按鈕樣式和combo
  pItem->SetFlags(xtpGridItemHasEdit | xtpGridItemHasComboButton | xtpGridItemHasExpandButton);
  // 添加combo內(nèi)容
  pItem->GetConstraints()->AddConstraint(_T("Windows 2000"), 1);
  pItem->GetConstraints()->AddConstraint(_T("Windows 98"), 2);
  // 建立字符串內(nèi)容
  pItem = pButtons->AddChildItem(new CXTPPropertyGridItem(_T("Text Button")));
  // 添加按鈕到字符串內(nèi)容行尾
  CXTPPropertyGridInplaceButton* pButton = pItem->GetInplaceButtons()->AddButton(new CXTPPropertyGridInplaceButton(1));
  // 設(shè)置按鈕文本
  pButton->SetCaption(_T("Find"));
  // 設(shè)置按鈕寬度
  pButton->SetWidth(100);
  // 建立字符串內(nèi)容
  pItem = pButtons->AddChildItem(new CXTPPropertyGridItem(_T("Image Button")));
  // 添加按鈕到字符串內(nèi)容行尾
  pButton = pItem->GetInplaceButtons()->AddButton(new CXTPPropertyGridInplaceButton(1));
  // 設(shè)置按鈕圖標索引
  pButton->SetIconIndex(100);
  // UINT數(shù)組  估計是一個臨時存儲單元用于添加圖標到按鈕
  // 上面的100和下面的100以及設(shè)置圖標語句中的btnFilter是相聯(lián)系的
  UINT btnFilter[] = {100};
  // 設(shè)置圖標
  m_wndPropertyGrid.GetImageManager()->SetIcons(IDB_BITMAP_FILTER, btnFilter, 1, 0);
  // 設(shè)置ToolTip在圖標上
  pButton->SetTooltip(_T("Set Filter for item"));
  // 建立整形內(nèi)容
  pItem = pButtons->AddChildItem(new CXTPPropertyGridItemNumber(_T("Spin And Slider"), 60));
  // 默認0-100暫時沒有找到設(shè)置范圍的方法
  // 添加水平滑塊連接到整形內(nèi)容
  pItem->AddSliderControl();
  // 添加上下按鈕連接到整形內(nèi)容
  pItem->AddSpinButton();

  //////////////////////////////////////////////////////////////////////////
  // 建立分類
  CXTPPropertyGridItem* pMetrics   = m_wndPropertyGrid.AddCategory(_T("Custom Metrics"));
  // 建立字符串內(nèi)容
  pItem = pMetrics->AddChildItem(new CXTPPropertyGridItem(_T("Value Colors"), _T("")));
  // 設(shè)置文字顏色 可以采用RGB宏或DWORD
  // 文字和背景顏色會呈現(xiàn)混合效果
  pItem->GetValueMetrics()->m_clrFore = 0x00ff00;
  // 設(shè)置背景顏色
  pItem->GetValueMetrics()->m_clrBack = RGB(255, 0, 255);
  // 建立字符串內(nèi)容
  pItem = pMetrics->AddChildItem(new CXTPPropertyGridItem(_T("Caption Colors"), _T("")));
  // 設(shè)置文字顏色
  pItem->GetCaptionMetrics()->m_clrFore = 0xFF0000;
  // 設(shè)置背景顏色
  pItem->GetCaptionMetrics()->m_clrBack = RGB(235, 235, 235);
  // 建立enum內(nèi)容
  pItem = pMetrics->AddChildItem(new CXTPPropertyGridItemEnum(_T("Images"), 2));
  // 內(nèi)加enum記錄并帶有圖片
  pItem->GetConstraints()->AddConstraint(_T("Green"), 0, 0);
  pItem->GetConstraints()->AddConstraint(_T("Red"), 1, 1);
  pItem->GetConstraints()->AddConstraint(_T("Yellow"), 2, 2);
  pItem->GetConstraints()->AddConstraint(_T("Blue"), 3, 3);
  // 設(shè)置enum內(nèi)容的內(nèi)容圖片
  pItem->GetValueMetrics()->m_nImage = 2;
  // 設(shè)置enum內(nèi)容的標題圖片
  pItem->GetCaptionMetrics()->m_nImage = 4;
  // 設(shè)置mask顏色
  m_wndPropertyGrid.GetImageManager()->SetMaskColor(0xC0C0C0);
  // 設(shè)置圖標
  m_wndPropertyGrid.GetImageManager()->SetIcons(IDB_BITMAP_CONSTRAINTS, 0, 5, CSize(20, 14));
  // 建立字符串內(nèi)容
  pItem = pMetrics->AddChildItem(new CXTPPropertyGridItem(_T("Variable Height"), _T("Item")));
  // 建立內(nèi)容塊高度
  pItem->SetHeight(32);
  // 設(shè)置為combo樣式
  pItem->SetFlags(xtpGridItemHasComboButton);
  // 建立多行字符串內(nèi)容
  // 貌似在多行中無法真正的多行編輯 沒有找到讓文本換行即支持文本回車的方式
  pItem = pMetrics->AddChildItem(new CXTPPropertyGridItem(_T("MultiLine"), _T("Codejock Software\r\n428 Corunna Avenue\r\nOwosso, Michigan 48867 USA")));
  // 設(shè)置能見得文本行數(shù)
  pItem->SetMultiLinesCount(3);

 

  // create custom items category.
  // 建立分類
  // 以下為自定義類型 代碼見CustomItems.h
  CXTPPropertyGridItem* pCustom   = m_wndPropertyGrid.AddCategory(_T("Custom Items"));
  // add child items to category.
  // 建立icon內(nèi)容
  CXTPPropertyGridItem* pItemIcon = pCustom->AddChildItem(new CCustomItemIcon(_T("Icon"), m_hIcon));
  pItemIcon->SetDescription(_T("This sample shows how to override draw function"));
  // 建立DockPadding內(nèi)容
  // DockPadding為4個數(shù)的組合
  CXTPPropertyGridItem* pItemDock = pCustom->AddChildItem(new CCustomItemChilds(_T("DockPadding"), CRect(100, 20, 400, 50)));
  pItemDock->SetDescription(_T("This sample shows how to add item with childs"));
  // 建立顏色內(nèi)容
  pCustom->AddChildItem(new CCustomItemColor(_T("CustomCombolist"), RGB(0xFF, 0x80, 0x40)));
  // 建立打開對話框內(nèi)容
  pCustom->AddChildItem(new CCustomItemFileBox(_T("File Box")));
  // 建立字符串內(nèi)容
  CXTPPropertyGridItem* pItemMaskEdit = pCustom->AddChildItem(new CXTPPropertyGridItem(_T("Mask Edit"), _T("Phone No: (816) 220-0000")));
  // 設(shè)置字符串MASK
  pItemMaskEdit->SetMask(_T("Phone No: (000) 000-0000"), _T("Phone No: (___) ___-____"));
  // 建立字符串內(nèi)容
  CXTPPropertyGridItem* pItemPassword = pCustom->AddChildItem(new CXTPPropertyGridItem(_T("Password"), _T("Text")));
  // 設(shè)置字符串Password
  pItemPassword->SetPasswordMask();
  // 建立日期內(nèi)容
  COleDateTime date(1981, 1, 26, 0, 0, 0 );
  pCustom->AddChildItem(new CXTPPropertyGridItemDate(_T("Date"), date));
  // 建立大寫字母內(nèi)容
  pCustom->AddChildItem(new CCustomItemUpperCase(_T("UpperCase")));
  // 建立ip地址內(nèi)容
  pCustom->AddChildItem(new CCustomItemIPAddress(_T("IP Address")));  
  // 建立PopupMenu內(nèi)容
  pCustom->AddChildItem(new CCustomItemMenu(_T("Popup Menu")));
  // 建立字符串內(nèi)容
  pCustom->AddChildItem(new CCustomItemEdit(_T("Output"), _T("Debug")));

  // add multi level tree node.
  // 建立樹形內(nèi)容
  CXTPPropertyGridItem* pCategoryOne    = pCustom->AddChildItem(new CXTPPropertyGridItemCategory(_T("First Sub Category")));
  CXTPPropertyGridItem* pCategoryTwo    = pCategoryOne->AddChildItem(new CXTPPropertyGridItemCategory(_T("Second Sub Category 1")));
  pCategoryTwo->AddChildItem(new CXTPPropertyGridItem(_T("Third Level 1"), _T("")));
  pCategoryTwo->AddChildItem(new CXTPPropertyGridItem(_T("Third Level 2"), _T("")));
  CXTPPropertyGridItem* pCategoryTwo2   = pCategoryOne->AddChildItem(new CXTPPropertyGridItemCategory(_T("Second Sub Category 2")));
  pCategoryTwo2->AddChildItem(new CXTPPropertyGridItem(_T("Third Level 1"), _T("")));
  // 建立樹形內(nèi)容
  CXTPPropertyGridItem* pItemOne    = pCustom->AddChildItem(new CXTPPropertyGridItem(_T("First Level"), _T("")));
  CXTPPropertyGridItem* pItemTwo    = pItemOne->AddChildItem(new CXTPPropertyGridItem(_T("Second Level"), _T("")));
  CXTPPropertyGridItem* pItemThird     = pItemTwo->AddChildItem(new CXTPPropertyGridItem(_T("Third Level"), _T("")));
  pItemThird->AddChildItem(new CXTPPropertyGridItem(_T("Fourth Level 1"), _T("")));
  pItemThird->AddChildItem(new CXTPPropertyGridItem(_T("Fourth Level 2"), _T("")));


  // create custom items category.
  // 建立分類
  pCustom   = m_wndPropertyGrid.AddCategory(_T("Custom Butons"));
  // 建立上下按鈕內(nèi)容
  CXTPPropertyGridItem* pItemSpin = pCustom->AddChildItem(new CCustomItemSpin(_T("SpinButton")));
  pItemSpin->SetDescription(_T("This sample shows how to add new button type"));
  // 建立水平滑塊內(nèi)容
  pCustom->AddChildItem(new CCustomItemSlider(_T("Slider")));
  // 建立CheckBox內(nèi)容
  CCustomItemCheckBox* pItemCheckBox = (CCustomItemCheckBox*)pCustom->AddChildItem(new CCustomItemCheckBox(_T("Check Box")));
  pItemCheckBox->SetValue(_T("agree with conditions"));
  pItemCheckBox->SetBool(TRUE);
  // 建立自定義按鈕
  pCustom->AddChildItem(new CCustomItemButton(_T("Left Origin"), FALSE, TRUE));
  pCustom->AddChildItem(new CCustomItemButton(_T("Right Origin"), FALSE, TRUE));
  pCustom->AddChildItem(new CCustomItemButton(_T("Pointer"), TRUE, TRUE));
  pCustom->AddChildItem(new CCustomItemButton(_T("Gradient"), TRUE, FALSE));
 }


 m_groupAppearance.SubclassDlgItem(IDC_GBOX_APPEAR, this);
 m_groupSort.SubclassDlgItem(IDC_GBOX_SORT, this);
 m_groupColor.SubclassDlgItem(IDC_GBOX_COLOR, this);

 // Set control resizing.
 SetResize(IDC_PROPERTY_GRID, SZ_TOP_LEFT, SZ_BOTTOM_RIGHT);
//
  SetResize(IDC_GBOX_APPEAR,       SZ_TOP_RIGHT, SZ_TOP_RIGHT);
    SetResize(IDC_CHK_TOOLBAR,       SZ_TOP_RIGHT, SZ_TOP_RIGHT);
  SetResize(IDC_CHK_HELP,          SZ_TOP_RIGHT, SZ_TOP_RIGHT);
 SetResize(IDC_CHK_VERBS,         SZ_TOP_RIGHT, SZ_TOP_RIGHT);
 SetResize(IDC_CHK_DOUBLE,        SZ_TOP_RIGHT, SZ_TOP_RIGHT);
 SetResize(IDC_CHK_TABITEMS,      SZ_TOP_RIGHT, SZ_TOP_RIGHT);
  SetResize(IDC_CHK_HIGHLIGHT,     SZ_TOP_RIGHT, SZ_TOP_RIGHT);
 SetResize(IDC_COMBO_THEME,       SZ_TOP_RIGHT, SZ_TOP_RIGHT);
   SetResize(IDC_GBOX_SORT,         SZ_TOP_RIGHT, SZ_TOP_RIGHT);
    SetResize(IDC_SORT_CATEGORIES,   SZ_TOP_RIGHT, SZ_TOP_RIGHT);
 SetResize(IDC_SORT_ALPHABETICAL, SZ_TOP_RIGHT, SZ_TOP_RIGHT);
  SetResize(IDC_SORT_NOSORT,       SZ_TOP_RIGHT, SZ_TOP_RIGHT);
    SetResize(IDC_GBOX_COLOR,        SZ_TOP_RIGHT, SZ_TOP_RIGHT);
  SetResize(IDC_CHK_CUSTOMCOLORS,  SZ_TOP_RIGHT, SZ_TOP_RIGHT);
  SetResize(IDC_BUTTON_SWITCHSTATE,  SZ_TOP_RIGHT, SZ_TOP_RIGHT);
  SetResize(IDC_COMBO_BORDER,      SZ_TOP_RIGHT, SZ_TOP_RIGHT);
   SetResize(IDC_CHECK_SHOWBUTTONS, SZ_TOP_RIGHT, SZ_TOP_RIGHT);
   SetResize(IDC_CHK_RIGHTTOLEFT, SZ_TOP_RIGHT, SZ_TOP_RIGHT);

 // Load window placement
 AutoLoadPlacement(_T("PropertyGridSample"));

  m_cmbTheme.AddString(_T("xtpGridThemeDefault"));
  m_cmbTheme.AddString(_T("xtpGridThemeNativeWinXP"));
  m_cmbTheme.AddString(_T("xtpGridThemeOffice2003"));
  m_cmbTheme.AddString(_T("xtpGridThemeCool"));
  m_cmbTheme.AddString(_T("xtpGridThemeSimple"));
  m_cmbTheme.AddString(_T("xtpGridThemeDelphi"));
  m_cmbTheme.AddString(_T("xtpGridThemeWhidbey"));
  m_cmbTheme.AddString(_T("xtpGridThemeOfficeXP"));
  m_cmbTheme.AddString(_T("xtpGridThemeOffice2007"));
  m_cmbTheme.SetCurSel(0);
 
  m_cmbBorder.AddString(_T("xtpGridBorderNone"));
  m_cmbBorder.AddString(_T("xtpGridBorderFlat"));
  m_cmbBorder.AddString(_T("xtpGridBorderStaticEdge"));
  m_cmbBorder.AddString(_T("xtpGridBorderClientEdge"));
  m_cmbBorder.SetCurSel(3);

 return TRUE;  // 除非設(shè)置了控件的焦點,否則返回 TRUE

posted @ 2008-08-19 13:37 hwawai 閱讀(4119) | 評論 (3)編輯 收藏

僅列出標題  
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲国产精品视频一区| 欧美精品色综合| 欧美视频不卡| 久久久久免费视频| 性娇小13――14欧美| 亚洲欧美在线一区| 性刺激综合网| 久久久www成人免费精品| 久久精品视频亚洲| 久久视频在线视频| 欧美日韩二区三区| 国产日韩精品一区二区浪潮av| 狠狠色丁香婷婷综合久久片| 亚洲国产成人av| 亚洲影院色在线观看免费| 久久福利影视| 免费在线亚洲欧美| 亚洲视频一二三| 久久久噜噜噜久久人人看| 欧美日韩国内自拍| 红桃视频国产精品| 亚洲视频在线二区| 久久免费精品视频| 亚洲国产精品久久91精品| 中文日韩电影网站| 另类成人小视频在线| 国产精品捆绑调教| 伊人婷婷久久| 午夜精品国产| 亚洲国产另类 国产精品国产免费| 亚洲香蕉伊综合在人在线视看| 在线视频免费在线观看一区二区| 久久福利视频导航| 亚洲欧洲日产国码二区| 欧美一区二区在线播放| 欧美日韩久久久久久| 国产专区综合网| 国产精品欧美久久久久无广告| 精品99一区二区| 亚洲欧美999| 亚洲欧洲在线免费| 久久天天狠狠| 国产精品色一区二区三区| 亚洲免费电影在线| 久久在精品线影院精品国产| 亚洲二区视频在线| 久久精品一二三| 国产精品99久久不卡二区| 欧美aa在线视频| 亚洲国产精品黑人久久久| 久久久国产一区二区| 亚洲在线1234| 国产精品久久久久久久9999| 一区二区三区视频在线看| 亚洲东热激情| 免费观看成人网| 亚洲黄网站在线观看| 欧美va亚洲va香蕉在线| 久久一区亚洲| 亚洲国产日韩在线| 韩国免费一区| 久久国产欧美精品| 午夜精品www| 欧美成人亚洲成人| 久久九九电影| 在线观看亚洲专区| 久久久美女艺术照精彩视频福利播放 | 国产午夜亚洲精品不卡| 午夜精品久久久久久久久| av成人动漫| 国产日韩精品在线播放| 久久久人人人| 免费亚洲一区二区| 一个色综合av| 亚洲一区二区三区视频| 国内不卡一区二区三区| 亚洲国产精品成人久久综合一区| 欧美精品一区二区三区在线看午夜| 一区二区久久| 亚洲欧美综合国产精品一区| 激情视频一区二区| 欧美激情精品| 国产精品高潮粉嫩av| 欧美在线黄色| 久久亚洲视频| 中文在线不卡| 久久久99爱| 美女成人午夜| 亚洲性线免费观看视频成熟| 欧美一区二区三区久久精品茉莉花| 在线不卡中文字幕播放| 亚洲欧洲另类国产综合| 国产精品天天看| 免费日韩精品中文字幕视频在线| 欧美国产视频在线观看| 性欧美激情精品| 麻豆免费精品视频| 先锋影音国产一区| 欧美成人一区二区在线| 欧美一区二区三区免费观看| 免费视频最近日韩| 欧美主播一区二区三区| 欧美寡妇偷汉性猛交| 欧美夜福利tv在线| 欧美剧在线免费观看网站| 久久综合亚州| 国产欧美一区视频| 一区二区欧美精品| 亚洲国产毛片完整版| 亚洲一区二区三区视频播放| 亚洲欧洲精品一区二区精品久久久 | 国产一区二区精品| 亚洲精品国产视频| 在线欧美亚洲| 欧美在线高清| 亚洲午夜精品网| 玖玖视频精品| 奶水喷射视频一区| 久久久久久国产精品一区| 在线亚洲激情| 欧美精品xxxxbbbb| 亚洲第一页中文字幕| 伊大人香蕉综合8在线视| 亚洲在线第一页| 亚洲午夜精品一区二区| 欧美精品色综合| 国产午夜精品久久久久久免费视| 国产精品国产三级国产| 免费久久99精品国产自在现线| 国产午夜精品久久久| 夜久久久久久| 在线看片第一页欧美| 亚洲一区精品在线| 亚洲一区在线观看视频| 欧美日韩高清在线一区| 欧美高清在线视频| 在线日本成人| 久久精品国产第一区二区三区最新章节 | 国语自产精品视频在线看抢先版结局 | 国产日韩欧美中文在线播放| 一区二区日韩精品| 亚洲欧美日韩第一区| 国产精品乱人伦中文| 中文高清一区| 午夜在线精品| 国产欧美在线看| 午夜国产精品视频| 久久亚洲私人国产精品va| 国产婷婷97碰碰久久人人蜜臀| 亚洲午夜精品久久久久久app| 午夜精品亚洲一区二区三区嫩草| 国产欧美精品| 欧美诱惑福利视频| 欧美黄在线观看| 亚洲天堂偷拍| 国产一区二区主播在线| 麻豆精品91| 日韩亚洲综合在线| 欧美亚洲综合久久| 亚洲福利精品| 国产精品成人v| 亚洲在线网站| 欧美激情一区二区三区四区| 日韩午夜精品| 国产一区二区三区四区老人| 欧美高清视频一二三区| 日韩天堂在线视频| 久久久久久久91| 亚洲第一视频| 国产精品另类一区| 蜜臀av在线播放一区二区三区| 国产亚洲成人一区| 欧美 日韩 国产精品免费观看| 亚洲视频免费在线| 久久婷婷综合激情| 中国成人黄色视屏| 亚洲电影av| 国产亚洲精品bv在线观看| 欧美经典一区二区三区| 欧美一区不卡| 亚洲精品自在久久| 快播亚洲色图| 在线看不卡av| 国产精品自在线| 欧美国产日韩xxxxx| 欧美一区二区三区在线看| 99精品欧美一区二区蜜桃免费| 欧美成人免费在线视频| 久久精品国产精品 | 亚洲大胆美女视频| 在线视频免费在线观看一区二区| 精品盗摄一区二区三区| 国产日产亚洲精品| 欧美日韩免费观看一区| 欧美成人四级电影| 久久亚洲色图| 久久在线免费观看视频| 欧美一区二区免费观在线| 亚洲视频999| 亚洲少妇自拍|