Home Database Mysql Tutorial VC操作SQL Server主从表

VC操作SQL Server主从表

Jun 07, 2016 pm 03:04 PM
server sql Work operate

工作之余,用VC作了一个小程序,是VC+SQL server模式的,程式内容比较简单,主要设及以下内容: 窗口如何分割; 多视图之间如何通信; 列表视图的操作及事件处理; 树形控件的操作及事件处理,利用递归根据数据库动态生成目录; 实现主从表的显示 以下对程序

工作之余,用VC作了一个小程序,是VC+SQL server模式的,程式内容比较简单,主要设及以下内容:

窗口如何分割;

多视图之间如何通信;

列表视图的操作及事件处理;

树形控件的操作及事件处理,利用递归根据数据库动态生成目录;

实现主从表的显示 以下对程序细节稍作一下说明;

一、窗口如何分割

切分窗口既适用于SDI应用程序,也适宜于MDI应用程序。它通常驻是以类 CSplitterWnd来表示,对 Windows 来说,CSplitterWnd 是一个真正的窗口,它完全占用框架窗口的客户区域而视图占用切分窗口的窗格区域。 动态切分与静态切分 动态切分允许用户须任何时候对窗口进行切分,用户既可以通过选取菜单也可以通过拖动滚动条中的切分框来进行切分。动态切分窗口使用的是一个视图类。 静态切分,当窗口第一次被创建时,窗格就已经被切他好了,它们不能再被改变。用户可以移动窗格边框,但此时不能再对窗口进行合并或再划分。静态切分窗口允许使用多个视图类,并且可以创建时对这些视图类进行配置。在静态切分窗口中,每个窗格都有自己的滚动条。 动态切分比较简单,不实用,下面看静态切分。

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)<br> {<br>    CRect rect;<br>    GetClientRect(&rect);<br>    m_wndSplitter1.CreateStatic(this,1,2);<br>    m_wndSplitter1.CreateView(0,0,RUNTIME_CLASS(CClassTreeView),CSize(150,150),pContext);<br>    m_wndSplitter2.CreateStatic(&m_wndSplitter1,<br>    2,1,WS_CHILD|WS_VISIBLE,<br>    m_wndSplitter1.IdFromRowCol(0,1));<br> <br>    m_wndSplitter2.CreateView(1,0,RUNTIME_CLASS(CDagDetialView),CSize(0,0),pContext);<br>    m_wndSplitter2.CreateView(0,0,RUNTIME_CLASS(CDagView),CSize(0,0),pContext);<br>    m_wndSplitter2.SetRowInfo(0,rect.Height()/2,0);<br>    return true;<br>   //重载时不能调用基类的OnCreateClient()<br> }

以上是本程序DEMO使用的方法。关于切分详细信息,请查阅MSDN.

二、多视图之间的通信

本程序demo使用了三个视图类,Winzard生成了一个,其余的是我加的。关于多视图之间的通信主要是茯得你要访问的视图类的pointer,如何茯得?有两种方法1,通过视图类(如果有多个视图共享一个文档类的话)2.通过主框架茯得。由于我的程式就一个文档类,其他视图类是独立的,所以就采用第二种方法了。

以下代码是茯得CDagDetialView类指针的示例,其余类同。

CMainFrame* pFrame=static_cast<cmainframe>(AfxGetMainWnd());//茯得主框架<br> CDagDetialView* pDagDetialView =<br> static_cast<cdagdetialview>(pFrame->m_wndSplitter2.GetPane(1,0));</cdagdetialview></cmainframe>

以上有一点,我觉得最好采用以上形式,虽说通过C的强制转换语法也行,但最好还是使用C++的语法比较好。

茯得视图指针后你就可以do anything that you want to do

顺便说一下,通信细节有一些牵连到效率的地方,一定要妥善处理。上面的demo程式,没有考虑过多。因为我觉得这比较适合大家看明白意思,如果程式模块分散开来,程式看起来是简洁了不少,但不太方便看清程序流程。请见谅。

1 2 3  下一页

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the difference between HQL and SQL in Hibernate framework? What is the difference between HQL and SQL in Hibernate framework? Apr 17, 2024 pm 02:57 PM

HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

Usage of division operation in Oracle SQL Usage of division operation in Oracle SQL Mar 10, 2024 pm 03:06 PM

"Usage of Division Operation in OracleSQL" In OracleSQL, division operation is one of the common mathematical operations. During data query and processing, division operations can help us calculate the ratio between fields or derive the logical relationship between specific values. This article will introduce the usage of division operation in OracleSQL and provide specific code examples. 1. Two ways of division operations in OracleSQL In OracleSQL, division operations can be performed in two different ways.

Comparison and differences of SQL syntax between Oracle and DB2 Comparison and differences of SQL syntax between Oracle and DB2 Mar 11, 2024 pm 12:09 PM

Oracle and DB2 are two commonly used relational database management systems, each of which has its own unique SQL syntax and characteristics. This article will compare and differ between the SQL syntax of Oracle and DB2, and provide specific code examples. Database connection In Oracle, use the following statement to connect to the database: CONNECTusername/password@database. In DB2, the statement to connect to the database is as follows: CONNECTTOdataba

PyCharm usage tutorial: guide you in detail to run the operation PyCharm usage tutorial: guide you in detail to run the operation Feb 26, 2024 pm 05:51 PM

PyCharm is a very popular Python integrated development environment (IDE). It provides a wealth of functions and tools to make Python development more efficient and convenient. This article will introduce you to the basic operation methods of PyCharm and provide specific code examples to help readers quickly get started and become proficient in operating the tool. 1. Download and install PyCharm First, we need to go to the PyCharm official website (https://www.jetbrains.com/pyc

Detailed explanation of the Set tag function in MyBatis dynamic SQL tags Detailed explanation of the Set tag function in MyBatis dynamic SQL tags Feb 26, 2024 pm 07:48 PM

Interpretation of MyBatis dynamic SQL tags: Detailed explanation of Set tag usage MyBatis is an excellent persistence layer framework. It provides a wealth of dynamic SQL tags and can flexibly construct database operation statements. Among them, the Set tag is used to generate the SET clause in the UPDATE statement, which is very commonly used in update operations. This article will explain in detail the usage of the Set tag in MyBatis and demonstrate its functionality through specific code examples. What is Set tag Set tag is used in MyBati

How to install, uninstall, and reset Windows server backup How to install, uninstall, and reset Windows server backup Mar 06, 2024 am 10:37 AM

WindowsServerBackup is a function that comes with the WindowsServer operating system, designed to help users protect important data and system configurations, and provide complete backup and recovery solutions for small, medium and enterprise-level enterprises. Only users running Server2022 and higher can use this feature. In this article, we will explain how to install, uninstall or reset WindowsServerBackup. How to Reset Windows Server Backup If you are experiencing problems with your server backup, the backup is taking too long, or you are unable to access stored files, then you may consider resetting your Windows Server backup settings. To reset Windows

Linux Deploy operation steps and precautions Linux Deploy operation steps and precautions Mar 14, 2024 pm 03:03 PM

LinuxDeploy operating steps and precautions LinuxDeploy is a powerful tool that can help users quickly deploy various Linux distributions on Android devices, allowing users to experience a complete Linux system on their mobile devices. This article will introduce the operating steps and precautions of LinuxDeploy in detail, and provide specific code examples to help readers better use this tool. Operation steps: Install LinuxDeploy: First, install

How to solve the 5120 error in SQL How to solve the 5120 error in SQL Mar 06, 2024 pm 04:33 PM

Solution: 1. Check whether the logged-in user has sufficient permissions to access or operate the database, and ensure that the user has the correct permissions; 2. Check whether the account of the SQL Server service has permission to access the specified file or folder, and ensure that the account Have sufficient permissions to read and write the file or folder; 3. Check whether the specified database file has been opened or locked by other processes, try to close or release the file, and rerun the query; 4. Try as administrator Run Management Studio as etc.

See all articles