📄 example19-2.htm
字号:
</v:shape><![endif]-->
<img width="288" height="210" src="exampl16.jpg" v:shapes="_x0000_i1025"></span>
</font><span lang="EN-US" style="font-size:10.5pt;mso-bidi-font-size:
10.0pt;font-family:"Times New Roman";mso-fareast-font-family:宋体;mso-font-kerning:
10.5pt;mso-ansi-language:EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:
AR-SA"><!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600"
o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f"
stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style='width:3in;
height:153pt'>
<v:imagedata src="../../../../DOCUME~1/y/LOCALS~1/Temp/msoclip1/01/clip_image001.png"
o:title=""/>
</v:shape><![endif]-->
<img width="288" height="204" src="exampl17.jpg" v:shapes="_x0000_i1025"></span></p>
<font SIZE="1">
<p ALIGN="CENTER" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">图</font>19-17
<font LANG="ZH-CN">选择数据库</font>
<font LANG="ZH-CN">图</font>19-18 <font LANG="ZH-CN">创建对话框以及相应的控件</font></font></p>
<p ALIGN="CENTER" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2"><span lang="EN-US" style="font-size:10.5pt;mso-bidi-font-size:
10.0pt;font-family:"Times New Roman";mso-fareast-font-family:宋体;mso-font-kerning:
10.5pt;mso-ansi-language:EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:
AR-SA"><!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600"
o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f"
stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style='width:213.75pt;
height:156pt'>
<v:imagedata src="../../../../DOCUME~1/y/LOCALS~1/Temp/msoclip1/01/clip_image001.png"
o:title=""/>
</v:shape><![endif]-->
<img width="285" height="208" src="exampl18.jpg" v:shapes="_x0000_i1025"></span>
</font><span lang="EN-US" style="font-size:10.5pt;mso-bidi-font-size:
10.0pt;font-family:"Times New Roman";mso-fareast-font-family:宋体;mso-font-kerning:
10.5pt;mso-ansi-language:EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:
AR-SA"><!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600"
o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f"
stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style='width:184.5pt;
height:152.25pt'>
<v:imagedata src="../../../../DOCUME~1/y/LOCALS~1/Temp/msoclip1/01/clip_image001.png"
o:title=""/>
</v:shape><![endif]-->
<img width="246" height="203" src="exampl19.jpg" v:shapes="_x0000_i1025"></span></p>
<p ALIGN="CENTER" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2"><font LANG="ZH-CN">图</font>19-19
<font LANG="ZH-CN">显示</font>Microsoft FlexGrid<font LANG="ZH-CN">控件
</font> <font LANG="ZH-CN">图</font>19-20 <font LANG="ZH-CN">增加成员变量</font></font></p>
<font SIZE="3">
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2"><font LANG="ZH-CN">③</font>
<font LANG="ZH-CN">添加代码</font></font></p>
<font SIZE="3">
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">在</font>CPostalcodeView::OnDraw(CDC*
pDC)<font LANG="ZH-CN">函数中增加以下代码即可。</font></font></p>
<blockquote>
<blockquote>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">void
CPostalcodeView::OnDraw(CDC* pDC)</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">{</font></p>
<blockquote>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">CRect
rect;
// <font LANG="ZH-CN">记录视图窗口的客户区大小</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">char
lpstrRow[6] = "1"; // FlexGrid<font LANG="ZH-CN">控件当前行第</font>0<font LANG="ZH-CN">列的显示</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">int
iRowCount = 1; // FlexGrid<font LANG="ZH-CN">控件的当前行</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">//
<font LANG="ZH-CN">调整</font>FlexGrid<font LANG="ZH-CN">控件的大小为整个客户区大小</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">GetClientRect(rect);
// <font LANG="ZH-CN">获取视图窗口客户区</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"> </p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.MoveWindow(rect,TRUE);
// <font LANG="ZH-CN">改变</font>FlexGrid<font LANG="ZH-CN">控件的位置和大小</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.RedrawWindow(NULL,NULL,</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">RDW_INVALIDATE
| RDW_UPDATENOW | RDW_ERASE); // <font LANG="ZH-CN">重画控件</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">//
<font LANG="ZH-CN">设置</font>FlexGrid<font LANG="ZH-CN">将要显示的总行数和总列数</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetCols((m_pSet->m_nFields)+1);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetRows(100);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">//
<font LANG="ZH-CN">设置控件所有行的宽度和所有列的高度</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetColWidth(-1,1000);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetRowHeight(-1,360);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">//
<font LANG="ZH-CN">单独设置控件第</font>0<font LANG="ZH-CN">列(序号列)的宽度</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetColWidth(0,600);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">//
<font LANG="ZH-CN">设置控件第</font>0<font LANG="ZH-CN">行(标题行)个列的显示文本</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetRow(0);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetCol(1);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetText("<font LANG="ZH-CN">地区</font>");</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetCol(2);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetText("<font LANG="ZH-CN">省份</font>");</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetCol(3);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetText("<font LANG="ZH-CN">邮编</font>");</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetCol(4);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetText("<font LANG="ZH-CN">区号</font>");</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"> </p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">//
<font LANG="ZH-CN">将记录集移动到第一个</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_pSet->MoveFirst();</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">//
<font LANG="ZH-CN">显示每一个记录集的各个字段</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">while(!m_pSet->IsEOF())</font></p>
<blockquote>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">{</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">//
<font LANG="ZH-CN">移动到当前行</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetRow(iRowCount);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">//
<font LANG="ZH-CN">在当前行第</font>0<font LANG="ZH-CN">列显示行号</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetCol(0);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">itoa(iRowCount,(char*)lpstrRow,6);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetText(lpstrRow);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">//
<font LANG="ZH-CN">在当前行第</font>1<font LANG="ZH-CN">列显示地区</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetCol(1);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetText(m_pSet->m_dq);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">//
<font LANG="ZH-CN">在当前行第</font>2<font LANG="ZH-CN">列显示省份</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetCol(2);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetText(m_pSet->m_sm);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">//
<font LANG="ZH-CN">在当前行第</font>3<font LANG="ZH-CN">列显示邮编</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetCol(3);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetText(m_pSet->m_yb);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">//
<font LANG="ZH-CN">在当前行第</font>4<font LANG="ZH-CN">列显示区号</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetCol(4);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetText(m_pSet->m_qh);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">if(!m_pSet->IsEOF())//
<font LANG="ZH-CN">如果没有结束,移动到下一行继续显示</font></font></p>
<blockquote>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">{</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_pSet->MoveNext();
// <font LANG="ZH-CN">移动到下一个记录</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">iRowCount
+= 1; // <font LANG="ZH-CN">当前行加</font>1</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">}</font></p>
</blockquote>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">}</font></p>
</blockquote>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">//
<font LANG="ZH-CN">将记录集移动到第一个</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_pSet->MoveFirst();</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">//
<font LANG="ZH-CN">设置控件的当前选择为第一行第一列</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetRow(1);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">m_FlexGrid.SetCol(1);</font></p>
</blockquote>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">}</font></p>
</blockquote>
</blockquote>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -