MFC中树形控件的应用——电话簿

一、电话薄的代码如下:

1、

// PhoneDlg.cpp : implementation file
//#include "stdafx.h"
#include "Phone.h"
#include "PhoneDlg.h"
#include "AddDlg.h"
#include "ModifyDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/
// CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialog
{
public:CAboutDlg();// Dialog Data//{{AFX_DATA(CAboutDlg)enum { IDD = IDD_ABOUTBOX };//}}AFX_DATA// ClassWizard generated virtual function overrides//{{AFX_VIRTUAL(CAboutDlg)protected:virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support//}}AFX_VIRTUAL// Implementation
protected://{{AFX_MSG(CAboutDlg)//}}AFX_MSGDECLARE_MESSAGE_MAP()
};CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{//{{AFX_DATA_INIT(CAboutDlg)//}}AFX_DATA_INIT
}void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CAboutDlg)//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)//{{AFX_MSG_MAP(CAboutDlg)// No message handlers//}}AFX_MSG_MAP
END_MESSAGE_MAP()/
// CPhoneDlg dialogCPhoneDlg::CPhoneDlg(CWnd* pParent /*=NULL*/): CDialog(CPhoneDlg::IDD, pParent)
{//{{AFX_DATA_INIT(CPhoneDlg)// NOTE: the ClassWizard will add member initialization here//}}AFX_DATA_INIT// Note that LoadIcon does not require a subsequent DestroyIcon in Win32m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}void CPhoneDlg::DoDataExchange(CDataExchange* pDX)
{CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CPhoneDlg)DDX_Control(pDX, IDC_LIST, m_list);DDX_Control(pDX, IDC_TREE, m_treePhone);//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CPhoneDlg, CDialog)//{{AFX_MSG_MAP(CPhoneDlg)ON_WM_SYSCOMMAND()ON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_BN_CLICKED(IDC_ADD, OnAdd)ON_BN_CLICKED(IDC_DEL, OnDel)ON_NOTIFY(TVN_SELCHANGED, IDC_TREE, OnSelchangedTree)ON_COMMAND(ID_MODIFY, OnModify)ON_NOTIFY(NM_RCLICK, IDC_LIST, OnRclickList)//}}AFX_MSG_MAP
END_MESSAGE_MAP()/
// CPhoneDlg message handlersBOOL CPhoneDlg::OnInitDialog()
{CDialog::OnInitDialog();// Add "About..." menu item to system menu.// IDM_ABOUTBOX must be in the system command range.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);}}// Set the icon for this dialog.  The framework does this automatically//  when the application's main window is not a dialogSetIcon(m_hIcon, TRUE);			// Set big iconSetIcon(m_hIcon, FALSE);		// Set small icon// TODO: Add extra initialization hereHICON hIcon[10];m_imageList.Create(16,16,ILC_COLOR,10,10);hIcon[0] = AfxGetApp()->LoadIcon(IDI_ICON_gege);hIcon[1] = AfxGetApp()->LoadIcon(IDI_ICON_didi);hIcon[2] = AfxGetApp()->LoadIcon(IDI_ICON_zhangsan);hIcon[3] = AfxGetApp()->LoadIcon(IDI_ICON_lisi);hIcon[4] = AfxGetApp()->LoadIcon(IDI_ICON_zhangtongxue);hIcon[5] = AfxGetApp()->LoadIcon(IDI_ICON_litongxue);hIcon[6] = AfxGetApp()->LoadIcon(IDI_ICON_dianhuabu);hIcon[7] = AfxGetApp()->LoadIcon(IDI_ICON_jiating);hIcon[8] = AfxGetApp()->LoadIcon(IDI_ICON_pengyou);hIcon[9] = AfxGetApp()->LoadIcon(IDI_ICON_tongxue);for(int n=0; n<10; n++)m_imageList.Add(hIcon[n]);m_treePhone.SetImageList(&m_imageList, TVSIL_NORMAL);HTREEITEM hRoot = m_treePhone.InsertItem("电话薄",6,6,TVI_ROOT);HTREEITEM hFamily = m_treePhone.InsertItem("家庭",7,7,hRoot);HTREEITEM hFriend = m_treePhone.InsertItem("朋友",8,8,hRoot);HTREEITEM hClassmate = m_treePhone.InsertItem("同学",9,9,hRoot);HTREEITEM h10 = m_treePhone.InsertItem("哥哥",0,0,hFamily);HTREEITEM h11 = m_treePhone.InsertItem("弟弟",1,1,hFamily);HTREEITEM h20 = m_treePhone.InsertItem("张三",2,2,hFriend);HTREEITEM h21 = m_treePhone.InsertItem("李四",3,3,hFriend);HTREEITEM h30 = m_treePhone.InsertItem("张同学",4,4,hClassmate);HTREEITEM h31 = m_treePhone.InsertItem("李同学",5,5,hClassmate);CString *pString = new CString("10101010101");m_treePhone.SetItemData(h10,(DWORD)pString);pString = new CString("11111111111");m_treePhone.SetItemData(h11,(DWORD)pString);pString = new CString("20202020202");m_treePhone.SetItemData(h20,(DWORD)pString);pString = new CString("21212121212");m_treePhone.SetItemData(h21,(DWORD)pString);pString = new CString("30303030303");m_treePhone.SetItemData(h30,(DWORD)pString);pString = new CString("31313131313");m_treePhone.SetItemData(h31,(DWORD)pString);m_list.InsertColumn(0,"姓名",LVCFMT_LEFT,100);m_list.InsertColumn(1,"电话号码",LVCFMT_LEFT,120);m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);return TRUE;  // return TRUE  unless you set the focus to a control
}void CPhoneDlg::OnSysCommand(UINT nID, LPARAM lParam)
{if ((nID & 0xFFF0) == IDM_ABOUTBOX){CAboutDlg dlgAbout;dlgAbout.DoModal();}else{CDialog::OnSysCommand(nID, lParam);}
}// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.void CPhoneDlg::OnPaint() 
{if (IsIconic()){CPaintDC dc(this); // device context for paintingSendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);// Center icon in client rectangleint cxIcon = GetSystemMetrics(SM_CXICON);int cyIcon = GetSystemMetrics(SM_CYICON);CRect rect;GetClientRect(&rect);int x = (rect.Width() - cxIcon + 1) / 2;int y = (rect.Height() - cyIcon + 1) / 2;// Draw the icondc.DrawIcon(x, y, m_hIcon);}else{CDialog::OnPaint();}
}// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CPhoneDlg::OnQueryDragIcon()
{return (HCURSOR) m_hIcon;
}void CPhoneDlg::OnAdd() 
{// TODO: Add your control notification handler code hereHTREEITEM selItem = m_treePhone.GetSelectedItem();//获得树中选中节点if(selItem == NULL)				//如果没有选中节点,返回return;if(selItem == m_treePhone.GetRootItem())		//如果选中了根节点,返回return;DWORD m = m_treePhone.GetItemData(selItem); 	//获得选中节点关联数据if(m == NULL)					//如果为空,是分组节点{CAddDlg dlg;if(dlg.DoModal() == IDOK)		//显示添加人员对话框,并单击确定按钮{//在选中节点下添加新节点HTREEITEM item = m_treePhone.InsertItem(dlg.m_strName,2,2,selItem);CString *pString = new CString(dlg.m_strNumber);m_treePhone.SetItemData(item,(DWORD)pString); 	//设置关联数据refreshList(selItem);}}}void CPhoneDlg::OnDel() 
{// TODO: Add your control notification handler code hereHTREEITEM selItem = m_treePhone.GetSelectedItem();	//获得树中选中节点if(selItem == NULL) 				//如果没有选中节点,返回return;if(selItem == m_treePhone.GetRootItem())		//如果选中了根节点,返回return;DWORD m = m_treePhone.GetItemData(selItem); 	//获得选中节点关联数据if(m != NULL)					//如果不为空,是人员节点{if(AfxMessageBox("确定要删除" + m_treePhone.GetItemText(selItem) + "?",MB_OKCANCEL) == IDOK){HTREEITEM parent = m_treePhone.GetParentItem(selItem);CString *pString = (CString*)m; 	//删除关联数据delete pString;m_treePhone.DeleteItem(selItem); 	//删除节点refreshList(parent);}}}void CPhoneDlg::OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult) 
{NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;// TODO: Add your control notification handler code hereHTREEITEM selItem = m_treePhone.GetSelectedItem();	//获得树中选中节点if(selItem == m_treePhone.GetRootItem())	//如果没有选中节点,返回return;DWORD m = m_treePhone.GetItemData(selItem); 	//获得选中节点关联数据if(m == NULL)			//如果为空,是分组节点{refreshList(selItem); 		//刷新列表视图中的数据}*pResult = 0;
}void CPhoneDlg::refreshList(HTREEITEM parent)
{	m_list.DeleteAllItems();		//删除原有数据int index = 0; //遍历获得该分组节点下的所有子节点HTREEITEM child = m_treePhone.GetChildItem(parent); 	while (child != NULL) {DWORD n = m_treePhone.GetItemData(child);CString *pString = (CString*)n;	//得到人员节点中的关联电话号码//在列表视图中添加一项m_list.InsertItem(index,m_treePhone.GetItemText(child));m_list.SetItemText(index,1,*pString); //在列表视图中设置一子项index++;child = m_treePhone.GetNextSiblingItem(child); //得到下一个兄弟节点}}void CPhoneDlg::OnModify() 
{// TODO: Add your command handler code here//查找列表视图中被选中项的标号int i;for(i=0; i<m_list.GetItemCount(); i++)if( m_list.GetItemState(i, LVIS_SELECTED) == LVIS_SELECTED )break;//如果标号大于列表视图中项的个数,返回,即在没有数据的项上单击右键if(i >= m_list.GetItemCount())return;//得到被选中项的数据CString name = m_list.GetItemText(i,0);CString number = m_list.GetItemText(i,1);//声明对话框对象,并设置数据CModifyDlg dlg;dlg.SetValue(name,number);
//如果单击了“确定”按钮if(dlg.DoModal() == IDOK){CString newName = dlg.m_strName;CString newNumber = dlg.m_strNumber; //得到新的姓名和电话号码//查找该人员在树中是哪个节点HTREEITEM child = m_treePhone.GetChildItem(m_treePhone.GetSelectedItem());while (child) {if(name == m_treePhone.GetItemText(child)){//更新修改后的值m_treePhone.SetItemText(child,newName);CString *pString = (CString*)m_treePhone.GetItemData(child);*pString = newNumber;break;}child = m_treePhone.GetNextSiblingItem(child);}//在列表视图中更新m_list.SetItemText(i,0,newName);m_list.SetItemText(i,1,newNumber);UpdateData(FALSE);	 //更新界面显示}}void CPhoneDlg::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult) 
{// TODO: Add your control notification handler code hereCMenu m_menu;m_menu.LoadMenu(IDR_MENU1);//加载整条菜单   CMenu*pMenu=m_menu.GetSubMenu(0);//获得第一个菜单   POINT   p;   GetCursorPos(&p);//获得鼠标位置   pMenu->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON, p.x, p.y,this);   pMenu->DestroyMenu();//销毁菜单*pResult = 0;
}


2、

// AddDlg.cpp : implementation file
//#include "stdafx.h"
#include "Phone.h"
#include "AddDlg.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/
// CAddDlg dialogCAddDlg::CAddDlg(CWnd* pParent /*=NULL*/): CDialog(CAddDlg::IDD, pParent)
{//{{AFX_DATA_INIT(CAddDlg)m_strName = _T("");m_strNumber = _T("");//}}AFX_DATA_INIT
}void CAddDlg::DoDataExchange(CDataExchange* pDX)
{CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CAddDlg)DDX_Text(pDX, IDC_NAME, m_strName);DDX_Text(pDX, IDC_NUMBER, m_strNumber);//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CAddDlg, CDialog)//{{AFX_MSG_MAP(CAddDlg)ON_BN_CLICKED(IDC_OK, OnOk)ON_BN_CLICKED(IDC_CANCEL, OnCancel)//}}AFX_MSG_MAP
END_MESSAGE_MAP()/
// CAddDlg message handlersvoid CAddDlg::OnOk() 
{// TODO: Add your control notification handler code hereUpdateData(TRUE);if(m_strName == "" || m_strNumber == ""){AfxMessageBox("信息不完整,请重新输入!");return;}CDialog::OnOK();}void CAddDlg::OnCancel() 
{// TODO: Add your control notification handler code hereCDialog::OnCancel();}


3、

// ModifyDlg.cpp : implementation file
//#include "stdafx.h"
#include "Phone.h"
#include "ModifyDlg.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/
// CModifyDlg dialogCModifyDlg::CModifyDlg(CWnd* pParent /*=NULL*/): CDialog(CModifyDlg::IDD, pParent)
{//{{AFX_DATA_INIT(CModifyDlg)m_strName = _T("");m_strNumber = _T("");//}}AFX_DATA_INIT
}void CModifyDlg::DoDataExchange(CDataExchange* pDX)
{CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CModifyDlg)DDX_Text(pDX, IDC_NAME, m_strName);DDX_Text(pDX, IDC_NUMBER, m_strNumber);//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CModifyDlg, CDialog)//{{AFX_MSG_MAP(CModifyDlg)ON_BN_CLICKED(IDC_OK, OnOk)ON_BN_CLICKED(IDC_CANCEL, OnCancel)//}}AFX_MSG_MAP
END_MESSAGE_MAP()/
// CModifyDlg message handlersvoid CModifyDlg::SetValue(CString name, CString number)
{m_strName = name;m_strNumber = number;}void CModifyDlg::OnOk() 
{// TODO: Add your control notification handler code hereUpdateData(TRUE);if(m_strName == "" || m_strNumber == ""){AfxMessageBox("信息不完整,请重新输入!");return;}CDialog::OnOK();}void CModifyDlg::OnCancel() 
{// TODO: Add your control notification handler code hereCDialog::OnCancel();
}


4、
// PhoneDlg.h : header file
//#if !defined(AFX_PHONEDLG_H__0B6F97D2_4A74_4BA2_8D17_A10C447C734C__INCLUDED_)
#define AFX_PHONEDLG_H__0B6F97D2_4A74_4BA2_8D17_A10C447C734C__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000/
// CPhoneDlg dialogclass CPhoneDlg : public CDialog
{
// Construction
public:void refreshList(HTREEITEM parent);CImageList m_imageList;CPhoneDlg(CWnd* pParent = NULL);	// standard constructor// Dialog Data//{{AFX_DATA(CPhoneDlg)enum { IDD = IDD_PHONE_DIALOG };CListCtrl	m_list;CTreeCtrl	m_treePhone;//}}AFX_DATA// ClassWizard generated virtual function overrides//{{AFX_VIRTUAL(CPhoneDlg)protected:virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support//}}AFX_VIRTUAL// Implementation
protected:HICON m_hIcon;// Generated message map functions//{{AFX_MSG(CPhoneDlg)virtual BOOL OnInitDialog();afx_msg void OnSysCommand(UINT nID, LPARAM lParam);afx_msg void OnPaint();afx_msg HCURSOR OnQueryDragIcon();afx_msg void OnAdd();afx_msg void OnDel();afx_msg void OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult);afx_msg void OnModify();afx_msg void OnRclickList(NMHDR* pNMHDR, LRESULT* pResult);//}}AFX_MSGDECLARE_MESSAGE_MAP()
};//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_PHONEDLG_H__0B6F97D2_4A74_4BA2_8D17_A10C447C734C__INCLUDED_)


5、

#if !defined(AFX_ADDDLG_H__6FC879E4_4440_4B76_AB1B_90053CBE1213__INCLUDED_)
#define AFX_ADDDLG_H__6FC879E4_4440_4B76_AB1B_90053CBE1213__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// AddDlg.h : header file
///
// CAddDlg dialogclass CAddDlg : public CDialog
{
// Construction
public:CAddDlg(CWnd* pParent = NULL);   // standard constructor// Dialog Data//{{AFX_DATA(CAddDlg)enum { IDD = IDD_ADD_DIALOG };CString	m_strName;CString	m_strNumber;//}}AFX_DATA// Overrides// ClassWizard generated virtual function overrides//{{AFX_VIRTUAL(CAddDlg)protected:virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support//}}AFX_VIRTUAL// Implementation
protected:// Generated message map functions//{{AFX_MSG(CAddDlg)afx_msg void OnOk();afx_msg void OnCancel();//}}AFX_MSGDECLARE_MESSAGE_MAP()
};//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_ADDDLG_H__6FC879E4_4440_4B76_AB1B_90053CBE1213__INCLUDED_)


6、

#if !defined(AFX_MODIFYDLG_H__8336A465_F3A0_4F14_9894_28B29B7BFC51__INCLUDED_)
#define AFX_MODIFYDLG_H__8336A465_F3A0_4F14_9894_28B29B7BFC51__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ModifyDlg.h : header file
///
// CModifyDlg dialogclass CModifyDlg : public CDialog
{
// Construction
public:void SetValue(CString name, CString number);CModifyDlg(CWnd* pParent = NULL);   // standard constructor// Dialog Data//{{AFX_DATA(CModifyDlg)enum { IDD = IDD_MODIFY_DIALOG };CString	m_strName;CString	m_strNumber;//}}AFX_DATA// Overrides// ClassWizard generated virtual function overrides//{{AFX_VIRTUAL(CModifyDlg)protected:virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support//}}AFX_VIRTUAL// Implementation
protected:// Generated message map functions//{{AFX_MSG(CModifyDlg)afx_msg void OnOk();afx_msg void OnCancel();//}}AFX_MSGDECLARE_MESSAGE_MAP()
};//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_MODIFYDLG_H__8336A465_F3A0_4F14_9894_28B29B7BFC51__INCLUDED_)


二、最终运行效果如下:









本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/492445.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

一口气逛完AWE的10个展馆 我观察出了三大趋势

来源&#xff1a;网易智能走进任何一个展位&#xff0c;你都可以感受到人工智能大脑的神奇之处。3月14日&#xff0c;中国家电及消费电子博览会&#xff08;AWE&#xff09;在上海开幕&#xff0c;如果说2018年AWE是AI赋能的开局之年&#xff0c;那对于2019年而言&#xff0c;A…

下一次工业革命:计算生物学与生物平台

来源&#xff1a;资本实验室人类科技的进步一直离不开两个方向的并行&#xff1a;一是不断扩大对外部世界的探索&#xff0c;例如新元素与新材料的发现、月球与火星探险、极地气候变化研究&#xff1b;一个是不断深化对我们自身身体与生命的认识&#xff0c;例如手术技术开发、…

MFC制作打地鼠小游戏

一、游戏说明如下&#xff1a; 打中老鼠加一分&#xff0c;当得分值小于10分时&#xff0c;老鼠每0.8秒出现一次&#xff0c;当得分值大于等于10分并且小于50分时&#xff0c;老鼠每0.6秒出现一次。当得分值大于等于50分时&#xff0c;老鼠每0.4秒出现一次。这个游戏是参考别人…

人机大战三周年:围棋界发生了哪些巨变?

来源&#xff1a;弈客围棋三年前的2016年3月15日&#xff0c;举世瞩目的第一次“人机大战”结束&#xff0c;代表人类出战的棋手李世石九段1比4不敌横空出世的围棋人工智能AlphaGo&#xff0c;正式宣告了围棋AI时代的开启。三年后的现在&#xff0c;围棋界的生态环境与三年前相…

在状态栏中显示鼠标位置坐标

&#xff08;1&#xff09;在状态栏资源中添加一个窗格。实现的方法是打开MainFrm.cpp文件&#xff0c;找到静态数 组indicators的定义&#xff0c;在第一个数组元素ID_SEPARATOR后面增加一个新的数组元素&#xff0c;即 添加了一个新的窗格&#xff0c;为了表明这个窗格的用…

一文了解半导体的过去、现在和未来

来源&#xff1a;中科院半导体所半导体发展历史1 半导体是信息化的基础上个世纪半导体大规模集成电路、半导体激光器、以及各种半导体器件的发明&#xff0c;对现代信息技术革命起了至关重要的作用&#xff0c;引发了一场新的全球性产业革命。信息化是当今世界经济和社会发展的…

C++面试宝典第9题:找出第K大元素

题目 给定一个整数数组a,同时给定它的大小N和要找的K(1 <= K <= N),请根据快速排序的思路,找出数组中第K大的数(保证答案存在)。比如:数组a为[50, 23, 66, 18, 72],数组大小N为5,K为3,则第K大的数为50。 解析 这道题主要考察应聘者对于快速排序的理解,以及实…

MFC中修改应用程序主窗口的标题

1、第一种方法&#xff1a; 找到字符串资源中的IDR_MAINFRAME&#xff0c; 将“MyTextOut\n\nMyText\n\n\nMyTextOut.Document\nMyTextDocument”替换为 “我的窗口\n\nMyText\n\n\nMyTextOut.Document\nMyTextDocument”。 效果如下&#xff1a; 2、第二种方法&#xff1a; 在…

中国占三分之一!CBinsights世界最新独角兽排名出炉

来源&#xff1a;智东西摘要&#xff1a;揭晓最新的全球独角兽公司榜单。3月14日&#xff0c;知名市场研究机构CB Insights发布了最新的世界独角兽公司信息图表。CB Insights实时追踪并统计全球独角兽公司&#xff0c;全球共有326家价值10亿美元以上的私人公司上榜&#xff0c;…

华为自研操作系统官宣了,但有机会成功吗

来源&#xff1a;网易智能摘要&#xff1a;近日&#xff0c;据媒体报道&#xff0c;华为余承东在接受德国《世界报》采访时正式承认&#xff0c;华为自研操作系统确实存在&#xff0c;不仅支持手机和PC&#xff0c;而且已经研发了七年&#xff01;“华为确实已经准备了一套自研…

表变量和临时表的使用

表变量存储在内存中&#xff0c;而临时表存储在tempdb中&#xff0c;会涉及到物理IO读写&#xff0c;那么我们是否可以由此得出结论&#xff0c;使用表变量要比使用临时表效率高呢&#xff1f;相信有一部分人会和我有同样的想法&#xff0c;使用表变量的效率高&#xff0c;真是…

只有大规模算力才能救AI?强化学习之父 vs 牛津教授掀起隔空论战

乾明 安妮 发自 凹非寺量子位 出品 | 公众号 QbitAI70年来&#xff0c; 人们在AI领域“一直连续犯着同样的错误”。这是“强化学习之父”理查德萨顿&#xff08;Richard S. Sutton&#xff09;为同行后辈们敲响的警钟。他在博客上发表最新文章《苦涩的教训》(The Bitter Lesson…

MFC中为菜单命令添加快捷键

&#xff08;1&#xff09;添加“帮助/我的帮助”菜单项。ID为ID_MY_HELP&#xff0c;Caption为“我的帮助(&H)”&#xff0c; 设CtrlH作为该命令的快捷键。 当执行CtrlH命令时&#xff0c;使用一个信息对话框显示简单的帮助信息。 添加代码如下&#xff1a; void CMainF…

IBM 内核惨败:20 亿美元打水漂 !

来源&#xff1a;云头条摘要&#xff1a;IBM早在20世纪90年代豪赌微内核&#xff0c;看好它是操作系统领域的下一大技术&#xff0c;为此不惜耗费数十亿美元&#xff0c;最后却没多少成果。20世纪90年代早期&#xff0c;我们不知道计算机行业的发展方向&#xff0c;下一代技术是…

C语言ODBC连接MySQL数据库制作简易用户登录系统

1、代码如下&#xff1a; #include "stdafx.h" #include <windows.h> #include <windowsx.h> #include <sql.h> #include <sqlext.h> #include <sqltypes.h> #include "resource.h" #include "MainDlg.h" #define…

关于交通创新,这五大智慧城市做了啥?

来源&#xff1a;资本实验室在现代城市中&#xff0c;交通的可达性和运输效率是衡量城市运营水平的重要指标。而随着城市人口越来越多&#xff0c;城市规模不断变大&#xff0c;如何打造高效、舒适、快速出行的交通系统已经成为城市管理机构面临的一大挑战。随着传感器成本的持…

应用程序利用ADO对象访问数据库

1、已创建MySQL数据库employeedb&#xff0c;数据库中有如下所示的employeetb表。 2、在使用ADO对象之前&#xff0c;必须在工程的Stdafx.h文件里用直接引入符号#import引入 ADO库文件&#xff0c;以使编译器能够正确编译。代码如下&#xff1a; #import "D:\Program Fil…

人工智能让育种“物美价廉”

预测二元化基因表达量的卷积神经网络模型建立来源&#xff1a;中国科学报自从作物被驯化以来&#xff0c;培育集抗性强、优质、高产等性状为一体的作物品种一直是育种家的梦想。DNA分子结构模型的发现推动了分子生物学的发展&#xff0c;让育种家们能够从基因和分子水平上解码作…

Socket编程应用——开发聊天软件

1、客户端应用程序开发 建立一个基于对话框的MFC应用程序&#xff0c;创建的时候记得勾选【Windows Sockets】&#xff0c;其 他的默认就行。 &#xff08;1&#xff09;、对话框如图所示&#xff1a; &#xff08;2&#xff09;代码如下&#xff1a; // ChatClientDlg.cpp …

MFC中给单文档程序添加背景图片

1、在OnDraw函数中修改如下&#xff1a; void CBitmapView::OnDraw(CDC* pDC) {CBitmapDoc* pDoc GetDocument();ASSERT_VALID(pDoc);// TODO: add draw code for native data hereCBitmap bitmap; //位图类对象bitmap.LoadBitmap(IDB_BITMAP1); //从资源中装载入位图CDC dc…