一、创建文本插入符

Step01、创建插入符

相关函数/结构体
            CWnd::CreateSolidCaret(); 
             定义:void CreateSolidCaret(int nWidth,int nHeight);
        在View类中加入WM_CREATE消息的响应函数OnCreate,加入CreateSolidCaret()
        效果:没有显示插入符呀!   

QUOTE FROM MSDN
The CreateSolidCaret method automatically destroys the previous caret shape, if any, regardless of which window owns the caret. Once created, the caret is initially hidden. To show the caret, the ShowCaret method must be called.

Step02、显示插入符

        加上ShowCaret();
    Step03、让插入符跟字体大小相关
        相关函数/结构体:
            获取字符信息CDC::GetTextMetrics
            字符属性结构体TEXTMETRIC Structure

code
    ///////////////////////////////////////////////////////////////////////////// 
   
// CTextView message handlers 

   
int CTextView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
    { 
       
if (CView::OnCreate(lpCreateStruct) == -1
           
return -1
       
//创建设备描述表 
        CClientDC dc(this); 
       
//定义文本信息结构体变量 
        TEXTMETRIC tm; 
       
//获得设备描述表中的文本信息 
        dc.GetTextMetrics(
&tm); 
       
//根据字体大小,创建合适的插入符 
        CreateSolidCaret(tm.tmAveCharWidth
/8, tm.tmHeight); 
       
//显示插入符 

        ShowCaret(); 
        SetTimer(
1,100,NULL); 
       
return 0
    } 

 

二、创建图形插入符

Step01、创建Bitmap


        定义:CBitmap bitmap;要放在View类的头文件中,并将其访问权限设置为private。为什么private?因为只在View类中调用。 

QUOTE
若将CBitmap bitmap放在CTextView中,bitmap为局部变量,当OnCreate()执行完毕会发生析构,相关的资源也会被销毁。那么说那幅位图也被销毁?应该不会吧?

Step02、创建图形插入符

  
        相关函数
            CWnd::CreateCaret();
                定义:void CreateCaret(CBitmap* pBitmap);                

Quote from MSDN
The bitmap must have previously been created by the CBitmap::CreateBitmap member function, the CreateDIBitmap Windows function, or the CBitmap::LoadBitmap member function.

所以需要Step01中把bitmap定义为全局变量。

OnCreate消息响应函数源代码
1    
2     /////////////////////////////////////////////////////////////////////////////
3     // CTextView message handlers
4     int CTextView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
5     { 
6         if (CView::OnCreate(lpCreateStruct) == -1
7             return -1
8         bitmap.LoadBitmap(IDB_BITMAP1); 
9         CreateCaret(&bitmap); 
10         ShowCaret(); 
11         SetTimer(1,100,NULL); 
12         return 0
13     }
posted @ 2010-01-25 23:22 Anthony Lee 阅读(229) 评论(0) 编辑

一、输入数据

6623-412664ca62468acf

SQL
1 alter table T_Employee ADD FSubCompany varchar(20);
2 alter table T_Employee add FDepartment varchar(20);
3 ------------------
4 update T_Employee set FSubCompany='Beijing',FDepartment='Development'
5 where FNumber='DEV001';
6 
7 update T_Employee set FSubCompany='Shenzhen',FDepartment='Development'
8 where FNumber='DEV002';
9 
10 update T_Employee set FSubCompany='Beijing',FDepartment='HR'
11 where FNumber='HR001';
12 
13 update T_Employee set FSubCompany='Beijing',FDepartment='HR'
14 where FNumber='HR002';
15 
16 update T_Employee set FSubCompany='Beijing',FDepartment='IT'
17 where FNumber='IT001';
18 
19 update T_Employee set FSubCompany='Shenzhen',FDepartment='IT'
20 where FNumber='IT002';
21 
22 update T_Employee set FSubCompany='Beijing',FDepartment='Sales'
23 where FNumber='SALES001';
24 
25 update T_Employee set FSubCompany='Beijing',FDepartment='Sales'
26 where FNumber='SALES002';
27 
28 update T_Employee set FSubCompany='Shenzhen',FDepartment='Sales'
29 where FNumber='SALES003';

二、数据分组入门:GROUP BY

关键字:

GROUP BY;

作用:

1、按条件选取字段并排除重复数值。IOW,按字段分组。

6292-412664ca581845c9

2、分组统计:分组使用聚合函数。
  • e.g.分年龄统计平均工资

    6623-412664ca5c672895

  • e.g.先按分公司,再按年龄分组

    6623-412664ca5f579be0

  • e.g.先按年龄,再按分公司分组

    6623-412664ca5f654321

  • 也可以用order by指定排列顺序

    6623-412664ca61c10b00

PS:

GROUP BY必须在WHERE语句段之后

6623-412664ca5b0bc1cd

三、使用HAVING语句对分组进行过滤

聚合函数不能再WHERE语句中使用,必须使用HAVING子句代替。

PS:order by必须放在最后。估计是DBMS选取数据完成最后才排序,SQL语句也按照这一过程制定语法。

image

 

      posted @ 2010-01-25 12:57 Anthony Lee 阅读(208) 评论(0) 编辑

      创建数据表

      6311@6292_28436ba27ffd32b19c4469b1745cb576

      定义非空约束

      • (字段名 字段类型 NOT NULL)

      6345@6292_89ac41a98d3af15575c50fc394437c9b 

       6347@6292_853d2197f2a05328055d2e8808d7f669

      定义默认字值                               

      • (字段名 字段类型 default 默认值)

      定义主键

      • Primary key (主键字段名)

      定义外键

      • 概念:外键是指向另一个表已有数据的约束,因此外键必须在目标表中存在。可以类比成网页链接;而链接那端存在内容才有意义。

      6326@6292_c1b1004ecafbdc6aef7ffe795bbd5848 

      修改已有数据表

      增加列(字段)

      6331@6292_ce0f98528ddd52864d7cf75e08f64ce8 

      删除列(字段)

      6518@6292_093ec46b490e57a07a8167d39227c6e3 

      上述语句运行不通过。

      修改字段名

      • 格式:alter table 表名 alter column 旧字段名 新字段名

        6530@6292_b2c96877da3cd0fb23b9a7c4d54b1445

        ……上述语句经SQL Server 2000测试,查询分析通过,但是运行不通过。

      为什么?百度知道

      一般地,改字段名可以用这条语句:

      alter table A rename column a to c

      但是,实际应用中,我们往往是用J-SQL进行编译,而J-SQL不支持修改字段名,所以,如果一定要修改字段名,那么只有通过变通的方法了,具体思路为:

      1.新建一个字段,取名为c;

      2.将字段a的内容拷贝到c;

      3.删除字段a;

      修改字段名、删除字段、修改数据表名等因为牵连到其他元素:外键等,所以要慎重操作。实在需要,就在企业管理器中操作。

      删除数据表

      6336@6292_7a58f6a05c2fc783fa4f778e45b32ef2

      posted @ 2010-01-25 11:28 Anthony Lee 阅读(179) 评论(0) 编辑

      这篇文章是关于数据库的提纲。

      Catalog

      (在有的DBMS中也称作Database,数据库)

      Index(索引)

      • 无索引的表是一个无序的行集。
      • 索引像词典的目录:按笔画查找、按拼音查找……这些就是索引。
      • 效果
        • 方便查找
        • 占据一定磁盘空间
        • 数据插入和删除速度减慢

      表关联

      • 减少信息冗余。
      • See Also
        • Internet的链接结构。如何选择最佳链接点?

      SQL

      posted @ 2010-01-25 02:00 Anthony Lee 阅读(32) 评论(0) 编辑