积木

No sub title

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  140 Posts :: 1 Stories :: 11 Comments :: 0 Trackbacks

常用链接

留言簿(1)

我参与的团队

搜索

  •  

最新评论

阅读排行榜

评论排行榜

#

原文转自:http://chenfeie.st.dprktimes.com/vc/_mfc_ctreectrl.3a3a.create.htm

CTreeCtrl::Create

BOOL Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID );

返回值

Nonzero if initialization was successful; otherwise 0.

如果初始化成功则返回非零值;否则返回0

参数说明

dwStyle

Specifies the tree view control’s style. Apply any combination of tree view control styles to the control.

指定tree view控件的风格。可以对这个控件使用tree view控件风格的任意组合。

rect

Specifies the tree view control’s size and position. It can be either a CRect object or a RECT structure.

指定tree view控件的尺寸和位置。此参数可以是一个CRect对象或一个RECT结构。

pParentWnd

Specifies the tree view control’s parent window, usually a CDialog. It must not be NULL.

指定tree view控件的父窗口,通常是一个CDialog。它不能是NULL。

nID

Specifies the tree view control’s ID.

指定tree view控件的ID。

备注

If you specify the tree control in a dialog box template, or if you are using CTreeView, your tree control is created automatically when the dialog box or view is created. If you want to create the tree control as a child window of some other window, use the Create member function. If you create the tree control using Create, you must pass it WS_VISIBLE, in addition to other tree view styles.

You construct a CTreeCtrl in two steps. First call the constructor, then call Create, which creates the tree view control and attaches it to the CTreeCtrl object.

构造一个CTreeCtrl要分两步。首先调用构造函数,然后调用Create来创建这个tree view控件并将它与该CTeeCtrl对象连接

The following styles can be applied to a tree view control:

下面的风格可以应用到一个tree view控件

  • TVS_HASLINES   The tree view control has lines linking child items to their corresponding parent items.

    TVS_HASLINES tree view控件的子项与它们的父项之间用线连接。
  • TVS_LINESATROOT   The tree view control has lines linking child items to the root of the hierarchy.

    TVS_LINESATROOT tree view控件用线连接子项和根项。
  • TVS_HASBUTTONS   The tree view control adds a button to the left of each parent item.

    TVS_HASBUTTONS tree view在每一个父项的左边添加一个按钮。
  • TVS_EDITLABELS   The tree view control allows the user to edit the labels of tree view items.

    TVS_EDITLABELS tree view控件允许用户编辑tree view项的标签。
  • TVS_SHOWSELALWAYS   Causes a selected item to remain selected when the tree-view control loses focus.

    TVS_SHOWSELALWAYS 当tree view失去焦点时,使被选择的项仍然保持被选择
  • TVS_DISABLEDRAGDROP   The tree-view control is prevented from  sending TVN_BEGINDRAG notification messages.

    TVS_DISABLEDRAGDROP 该tree view控件被禁止发送TVN_BEGINDRAG通知消息。
  • TVS_NOTOOLTIPS   The tree view control uses no tooltips.

    TVS_NOTOOLTIPS tree view控件使用工具提示。
  • TVS_SINGLEEXPAND   When this style is enabled, changing the selection in the tree view will automatically cause the item being selected to expand and the item being unselected to collapse. If the mouse is used to single-click the selected item and that item is closed, it will be expanded. If the selected item is single-clicked when it is open, it will be collapsed.

    TVS_SINGLEEXPAND 当使用这个风格时,改变在tree view中的选择将导致正被选择的项展开,而没有被选择的项收缩。如果用鼠标单击被选择的项,并且该项是关闭的,则该项就会展开。如果该被选择的项被单击时是打开的,则它就会收缩。
posted @ 2011-10-01 18:44 Jacc.Kim 阅读(3105) | 评论 (0)编辑 收藏

原文参考自:http://blog.csdn.net/tulun/article/details/6320502

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
在PreCreateWindow(CREATESTRUCT& cs)中,添加如下语句:
cs.style &= ~FWS_ADDTOTITLE;
//* 查了下MSDN它是设定框架窗口的标题。上那句,则是去除掉该样式属性。
//* 然后可以主框架的
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
事件中添加如下设置标题的语句:
this->SetWindowText(_T("This is an application title."));
posted @ 2011-09-30 10:15 Jacc.Kim 阅读(707) | 评论 (0)编辑 收藏

      c++本来就已经够让人头痛了,没想到学了c++"还没办法"用于项目开发。因为还需要熟悉开发环境。在此,简要记录下初次探索MFC架构的一点心得体会。

      要想利用vs开发项目,我们必需要了解MFC的架构以及它们间的相互依赖关系。
      1) 应用程序程序实例: theApp; 
      它其实就是我们所启动的程序实例。是全局的。一旦它释放掉了,则整个程序的生命周期就结束了。我们可以通过全局函数::AfxGetApp();来取得该实例。
      2) MFC程序的主框架: CMainFrm;
      一个MFC应用程序也只有一个主框架。它负责程序中各视图以及各种面板的布局展现工作。我们可以在任意位置通过::AfxGetMainWnd();或::AfxGetApp()->m_pMainWnd;
来获得该主框架对象。
      3) 文档模型: CDocTemplate;
      正常来说,文档模型的职责:负责维护程序中所创建的文档实例。(它同主框架一样,由应用程序theApp维护)。
      在应用程序中,我们可以通过 GetFirstDocTemplatePosition();取得第一个文档模型对象的地址(返回值为:POSITION类型).可以通过GetNextDocTemplate();取得下一个。从而
进行遍历。
      而在文档中,我们可以通过GetDocTemplate();来取得其所属的文档模型对象。
      4) 文档:CDocument:
      其是负责数据维护的工作。其通过结合相应的视图,可将数据展现。一个文档可以维护多个视图。(注意:一个视图只能属于一个文档)。
      在主框架对象中,我们可以通过:GetActiveDocument();取得当前活动的文档对象
      在文档模型对象中,我们通过:GetfirstDocPosition();与GetNextDoc();遍历文档对象
      在文档视图对象中,我们通过:GetDocument();取得所属的文档对象
      5) 视图:CView:
      与文档配置,实现数据的界面展现。
      在主框架类中,我们通过:GetActiveView();获得当前活动视图
      在文档类中,可以通过:GetFirstViewPosition();与GetNextView();遍历出所有的视图。
posted @ 2011-09-29 18:46 Jacc.Kim 阅读(415) | 评论 (0)编辑 收藏

本文转自:http://blog.csdn.net/dzyssssss/article/details/6609086

近日给其他组同事开发了一个控件,使用vs2008作为开发工具,完成后别人注册时居然不成功,经查发现居然是依赖库不全问题。

1、ATL库

2、msvcr90.dll库

对于第一个问题直接在工程中设置静态链接atl库即可解决该问题,但是对于第二个没有想明白怎么弄,难道非得发布msvcr90.dll文件吗,太麻烦了。后来一查居然有人说是vs2008的bug,不知道是不是,不过之总解决了上面依赖的库,不用带那么多"尾巴"了,呵呵。

具体处理过程如下:

1、在Project\Properties\Configuration Properties\Project Defaults\Use of MFC中,选择Use MFC in a Static Library

2、编译,编译不通过没关系(但是我做的库是编译通过了)

3、在Project\Properties\Configuration Properties\Project Defaults\Use of MFC中,选择Use Standard Windows Libraries(就是把设置改回去)

4、再次编译


再使用dependency工具查看,果然不依赖于上面提到的msvcr90.dll了,但是问题是再选择回去后,编译出来的库确实比以前大了不少,具体内部原因多半还得问微软是怎么回事了!

posted @ 2011-09-07 10:26 Jacc.Kim 阅读(2170) | 评论 (2)编辑 收藏

 1 BOOL CC3EngineDemoApp::InitInstance()
 2 {
 3         
 4 
 5     CC3EngineDemoDlg* pDlg;
 6     pDlg = new CC3EngineDemoDlg();
 7     pDlg->Create(IDD_C3ENGINEDEMO_DIALOG, NULL);
 8     pDlg->ModifyStyle(WS_MAXIMIZEBOX, 00);
 9     RECT rect;
10     UINT unDefWidth = 1024;
11     UINT unDefHeight = 768;
12     if (this->CalPositionInfo(rect, unDefWidth, unDefHeight))
13         pDlg->MoveWindow(rect.left, rect.top, unDefWidth, unDefHeight, TRUE);
14     else
15         pDlg->MoveWindow(001024768, TRUE);
16     pDlg->UpdateWindow();
17     m_pMainWnd = pDlg;
18     return TRUE;
19 }
20 
21 BOOL CC3EngineDemoApp::OnIdle(LONG lCount)
22 {
23     // TODO: Add your specialized code here and/or call the base class
24 
25     //return CWinAppEx::OnIdle(lCount);
26     return TRUE;
27 }
posted @ 2011-08-16 16:01 Jacc.Kim 阅读(438) | 评论 (0)编辑 收藏

 

 1 bool GetScreenSize(UINT& unWidth, UINT& unHeight)
 2 {
 3     try
 4     {
 5         unWidth = ::GetSystemMetrics(SM_CXSCREEN);
 6         unHeight = ::GetSystemMetrics(SM_CYSCREEN);
 7         return true;
 8     }
 9     catch()
10     {
11         unWidth = 0;
12         unHeight = 0;
13         return false;
14     }
15 }

 

posted @ 2011-08-16 15:58 Jacc.Kim 阅读(792) | 评论 (0)编辑 收藏

C++ Map 容器操作实例

// Test_20110514_1853.cpp : Defines the entry point for the console application.
//

//说明:最下面有总结说明。

#include 
"stdafx.h"

#include 
<iostream>
#include 
<map>
using namespace std;

typedef map
<intstring> TMyMap;

void PrintSplitterString(short sCount = 50)
{
    
if (sCount < 20 || sCount > 80)
        sCount 
= 50;
    
for (short i = 1; i <= sCount; i++)
        cout 
<< "-";
    cout 
<< endl;
}

void CoutMapList(const TMyMap& mmMap)
{
    
for (TMyMap::const_iterator iter = mmMap.begin(); iter != mmMap.end(); iter++)
    {
        
string str = iter->second;
        cout 
<< "键:" << iter->first << "      值:" << str.c_str() << endl;
    }
}

int _tmain(int argc, _TCHAR* argv[])
{
//*****************************************************************************************
// * 在此介绍map容器的用法
//*****************************************************************************************

    
//1.创建一个map容器变量
    TMyMap enumMap;

    
//往map中加入元素
    PrintSplitterString();
    cout 
<< "操作:往map 中添加元素方法一" << endl;
    enumMap[
1= "One";
    enumMap[
2= "Two";
    enumMap[
2= "Seven";    //此时将是修改键为的值,如果该键元素不存在,则新建一个
    CoutMapList(enumMap);

    
//////////////////////////////////////////////////////////////////////////
    //* 说明:使用此方法的优点是:十分的方便。
    
//* 缺点:效果不高。因为map 类已经对[] 操作符进行了重载
    
//*          比如,在插入第个元素时,系统需要先在enumMap中查找主键为的项,没有发现,然后新的对象插入enumMap,键是
    
//*       1,值是一个空的字符串。插入完成后,再将将显式的Two字符串,赋给值。如果我们要插入的是一个类对象了?
    
//*       那将会是个很大的开销。
    
//*       缺点:如果先前已经存在了键为的元素时,则将变成值修改
    //////////////////////////////////////////////////////////////////////////

    cout 
<< endl << "操作:往map 中添加元素方法二" << endl;
    enumMap.insert(TMyMap::value_type(
2"Third"));
    
//////////////////////////////////////////////////////////////////////////
    //* 说明:此方法解决了上面方法的缺点,但有个地方需要注意:
    
//* 如果列表中已经存在键为的元素时,它是不会插入新的元素的。
    //////////////////////////////////////////////////////////////////////////
    enumMap.insert(TMyMap::value_type(3"Third"));
    CoutMapList(enumMap);
    PrintSplitterString();

    
//查找并获取map中的元素
    PrintSplitterString();
    cout 
<< "操作:查找并获取map 中元素" << endl;
    
//方法一:通过下标获得一个值(此适用在下标明确的情况下)
    string tmp = enumMap[4];    //此方法总是安全的。就算不存在键为的元素,系统也不会报,只是返回的值是空的。因为系统是会新创建一个键为的节点,(值当然为空)
    cout << tmp.c_str() << endl;
    
    
//另一种取得元素的方法是,通过查找
    TMyMap::const_iterator iter_find = enumMap.find(2);
    
if (iter_find != enumMap.end())
    {
        
//找到了
        cout << iter_find->second.c_str() << endl;
    }
    
else
    {
        
//没有找到
        cout << "没有找到。" << endl;
    }
    PrintSplitterString();

    
//从map 中删除元素
    PrintSplitterString();
    cout 
<< "操作:从map 中删除元素的方法" << endl;
    
//////////////////////////////////////////////////////////////////////////
    //* 删除的方法有:
    
//* iterator erase(iterator it);//通过一个条目对象删除
    
//* iterator erase(iterator first, iterator last);//删除一个范围
    
//* size_type erase(const key& key);//通过键来删除
    
//* clear();//相漕运于enumMap.erase(enumMap.begin(), enumMap.end());
    //////////////////////////////////////////////////////////////////////////
    cout << "==> 全部列表如下:" << endl;
    CoutMapList(enumMap);
    enumMap.erase(
3);
    cout 
<< "==> 删除掉键值为:的" << endl;
    CoutMapList(enumMap);
    cout 
<< endl << endl;
    enumMap.erase(enumMap.begin());
    cout 
<< "==> 删除掉第一个元素" << endl;
    CoutMapList(enumMap);
    cout 
<< endl << endl;
    enumMap.clear();
    cout 
<< "==> 全部清空" << endl;
    CoutMapList(enumMap);
    PrintSplitterString();

    
//所有操作均已经结束
    PrintSplitterString();
    cout 
<< "所有操作均已经结束" << endl;
    PrintSplitterString();
    cout 
<< endl;


//*********************************************************************************************
//* 现在总结如下:
//* 对于map的操作。最好不要通过下标进行。比如:想要取一个元素,要先通过查找,有了,再操作,没有。不操作。
//* 否则有可能系统会为你自动添加 “莫名奇妙” 的元素进去你都不知道
//*********************************************************************************************

    
return 0;
}

posted @ 2011-07-04 20:30 Jacc.Kim 阅读(2431) | 评论 (0)编辑 收藏

List容器用法操作实例


// Test_20110513_1756.cpp : Defines the entry point for the console application.
//

//////////////////////////////////////////////////////////////////////////
//* list容器测试
//////////////////////////////////////////////////////////////////////////

#include 
"stdafx.h"

#include 
<list>
#include 
<iostream>
using namespace std;

typedef list
<int> LISTINT;

int _tmain(int argc, _TCHAR* argv[])
{
    
//创建一个list容器
    LISTINT lInt;

    
//在list容器的末尾,添加元素
    cout << "------------------------------------------------" << endl << "操作:从后面添加元素" << endl;
    
for (LISTINT::value_type iValCount = 1; iValCount != 11; iValCount++)
        lInt.push_back(iValCount);
    
for (LISTINT::iterator iter = lInt.begin(); iter != lInt.end(); iter++)
        cout 
<< *iter << endl;

    
//在list容器的头部,添加元素
    cout << "------------------------------------------------" << endl << "操作:从前面添加元素" << endl;
    
for (LISTINT::value_type iValCount = 11; iValCount != 21; iValCount++)
        lInt.push_front(iValCount);
    
for (LISTINT::iterator iter = lInt.begin(); iter != lInt.end(); iter++)
        cout 
<< *iter << endl;

    
//取出最后一个元素
    cout << "------------------------------------------------" << endl << "操作:取出最后一个元素" << endl;
    cout 
<< lInt.back() << endl;

    
//取出最前一个元素
    cout << "------------------------------------------------" << endl << "操作:取出最前一个元素" << endl;
    cout 
<< lInt.front() << endl;

    
//从后向前显示list中的元素(注意:迭代器,不可以同名,虽然在不同的作用域下)
    cout << "------------------------------------------------" << endl << "操作:从后向向前显示list中的元素" << endl;
    
for (LISTINT::reverse_iterator iter2 = lInt.rbegin(); iter2 != lInt.rend(); iter2++)
        cout 
<< *iter2 << endl;

    
//删除一个元素
    cout << "------------------------------------------------" << endl << "操作:删除最后一个元素" << endl;
    
if (lInt.size() > 0)
    {
        LISTINT::iterator delIter 
= lInt.end();
        delIter
--;
        cout 
<< *delIter << endl;
        lInt.erase(delIter);
        
if (lInt.size() > 0)
        {
            delIter 
= lInt.end();
            delIter
--;
            cout 
<< *delIter << endl;
        }
    }

    
//清空元素(并输入所有元素内容----正常输出为空。因为被清空了)
    cout << "------------------------------------------------" << endl << "操作:清空所有元素(并输入所有元素内容----正常输出为空。因为被清空了)" << endl;
    lInt.clear();
    
for (LISTINT::iterator iter3 = lInt.begin(); iter3 != lInt.end(); iter3++)
    cout 
<< *iter3 << endl;

    
//所有操作均已经结束
    cout << "------------------------------------------------" << endl << "操作:所有操作均已经结束" << endl;
    cout 
<< "------------------------------------------------" << endl;

    
return 0;
}

posted @ 2011-07-04 20:30 Jacc.Kim 阅读(9520) | 评论 (2)编辑 收藏

以下是Vector容器用户总结

---------------------------------------------------------------------------------------------------
几个介绍vector容器还不错的文章链接:
    http:
//blog.csdn.net/fm0517/archive/2009/06/09/4254099.aspx

---------------------------------------------------------------------------------------------------

// Test_20110513_1036.cpp : Defines the entry point for the console application.
//

#include 
"stdafx.h"

#include 
<vector>
#include 
<iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    
//创建vector容器
    vector<int> vInt;
    
//也可以下面这样初始化,表示将所有的元素初始化为
    
//vector<int> vInt(0);
    
//添加元素
    for (vector<int>::value_type i = 0; i < 10; i++)
        vInt.push_back(i 
+ 1);
    
//输出元素
    cout << "-------------------------------------------------------" << endl << "操作:添加元素" << endl;
    
for (vector<int>::iterator iter = vInt.begin(); iter != vInt.end(); iter++)
        cout 
<< *iter << endl;
    
    
//erase操作----其实就是删除指定的某个元素
    cout << "-------------------------------------------------------" << endl << "操作:erase操作" << endl;
    
for (vector<int>::iterator iter3 = vInt.begin(); iter3 != vInt.end(); iter3++)
    {
        
if (*iter3 == 8)
        {
            iter3 
= vInt.erase(iter3);
            
break;
        }
    }
    
for (vector<int>::iterator iter4 = vInt.begin(); iter4 != vInt.end(); iter4++)
        cout 
<< *iter4 << endl;

    
//删除最后一个元素,方法一
    cout << "-------------------------------------------------------" << endl << "操作:删除最后一个元素之方法一" << endl;
    
if (vInt.size() > 0)
    {
        vector
<int>::iterator iterEnd = vInt.end() - 1;
        
/*iterEnd = */vInt.erase(iterEnd);
        
//输出
        for (vector<int>::iterator iter5 = vInt.begin(); iter5 != vInt.end(); iter5++)
            cout 
<< *iter5 << endl;
    }

    
//删除最后一个元素,方法二
    cout << "-------------------------------------------------------" << endl << "操作:删除最后一个元素之方法二" << endl;
    
if (vInt.size() > 0)
    {
        vector
<int>::iterator iterEnd2 = vInt.end() - 1;
        vInt.pop_back();
        
//输出
        for (vector<int>::iterator iter5 = vInt.begin(); iter5 != vInt.end(); iter5++)
            cout 
<< *iter5 << endl;
    }

    
//清空所有数据元素
    vInt.clear();
    
//输入元素
    cout << "-------------------------------------------------------" << endl << "操作:清空元素" << endl;
    
for (vector<int>::iterator iter2 = vInt.begin(); iter2 != vInt.end(); iter2++)
        cout 
<< *iter2 << endl;

    
return 0;
}



以下是执行结果:
     

posted @ 2011-07-04 20:29 Jacc.Kim 阅读(498) | 评论 (0)编辑 收藏

在C++的类的成员函数中,允许直接访问该类的成员对象的私有成员变量
// SmartPointerStu.cpp : Defines the entry point for the console application.
//

#include 
"stdafx.h"

//#include "SmartPointer.h"
//#include <iostream>
//using namespace std;

class CPointEx_
{
public:
    
//CPointEx_(int _x = 0, int _y = -1) : x(_x), y(_y) {}
    void SetValue(int x, int y) { this->= x, this->= y; }
    
void CallPrivateMem(const CPointEx_& AObj)
    {
        x 
= AObj.x;
        y 
= AObj.y;
    }
private:
    
int x;
    
int y;
};

int _tmain(int argc, _TCHAR* argv[])
{
    CPointEx_ theObj, theObj2;
    theObj.SetValue(
1020);
    theObj2.SetValue(
3040);
    theObj2.CallPrivateMem(theObj);


    system(
"pause");
    
return 0;
}


posted @ 2011-06-29 14:41 Jacc.Kim 阅读(1446) | 评论 (0)编辑 收藏

仅列出标题
共14页: First 6 7 8 9 10 11 12 13 14