⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 01_9_16_4.asp.html

📁 有用的VC教程,包括编程思想编程技巧程序效率等方面的指导
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
<TITLE>计算机世界网-Visual C++ 编程问答(四)</TITLE></HEAD>
<style>
.a14{font-size:14px;text-indent:25px;line-height:20px}
.f{font-size:18px;color=#0f3ccd}
img{border:0px;}
td,p,input{font-fammily:verdana,宋体;font-size:12px;}
A:link {text-decoration:none;color:black}
A:visited {text-decoration:none;color:#80006f}
A:hover {text-decoration:underline;color:black}
</style>
<center>
<BODY topmargin=2 leftmargin=0>
<style>
.v12{font-size:10pt;color:"#ffffff";FONT-WEIGHT: bold}
.v14{font-size:14px;text-indent:25px;line-height:20px}
img{border:0px;}
td,p,input,select{font-fammily:verdana,宋体;font-size:12px;}
A:link {text-decoration:none;color:black}
A:visited {text-decoration:none;color:#80006f}
A:hover {text-decoration:underline;color:black}
</style>

<style>
.v13{font-size:10pt;color:"#ffffff";FONT-WEIGHT: bold}
.v12{font-size:13px;color:"#4C029C";FONT-WEIGHT: bold}
.v14{font-size:14px;text-indent:25px;line-height:20px}
img{border:0px;}
td,p,input,select{font-fammily:verdana,宋体;font-size:12px;}
A:link {text-decoration:none;color:black}
A:visited {text-decoration:none;color:#80006f}
A:hover {text-decoration:underline;color:black}
</style>

<!--头-->

<table align=center cellpadding="0" cellspacing="0" border="0" width="767">
  <tr><td valign=bottom>
      <table cellpadding="0" cellspacing="0" border=0>
        <tr><td valign=top><img src="../../../../../center/image/ccwlogo.gif"></td></tr>
        <tr><td height="27" valign=top><img src="../../../../../center/image/knowledge.gif" width="207" height="27"></td></tr>
      </table></td>
	<td valign=bottom width=556 bgcolor="#4c029c" height=96>
		  <table cellpadding="0" cellspacing="0" border=0 width=556 bgcolor="#4c029c" height=96>
        <tr><td height=25 valign=bottom bgcolor="#ffffff"  colspan=2 ><img src="../../../../../image2002/top.gif" usemap="#F"></td></tr>
	<tr  valign=middle >
		<td align=center valign=middle height="60" align=center>
		<!-- <a href="http://www.ccw.com.cn/search/" target=_blank><img src="../../../../../img2/esearch.GIF" border=0 width=468 height=60></a> --><a href="http://www.ccw.com.cn/html/search/thememail/" target=_blank><img src="../../../../../img2/topbanner_thememail.GIF" border=0 width=468 height=60></a>	
		</td>		
		<td  align=center width=15%>
			<table width=95%>
				<tr><td><a href="mailto:center@ccw.com.cn?subject=我要投稿:" target=_blank><font class=v13>我要投稿</a><br><a href="mailto:center@ccw.com.cn?subject=编读往来"><font class=v13>编读往来</a><br><a href="javascript:AddBookMark('计算机世界网首页')"><font class=v13>加入收藏</a></font></td></tr>
			</table>
		</td>
	</tr>
		<tr><td bgcolor="#ffffff" height=1 colspan=2 ></td></tr>
		<tr><td bgcolor="#b4aafc" height=2 colspan=2 ></td></tr></table>
		<map name="F">
<area href="http://www.ccw.com.cn/" shape="rect" coords="29, 3, 61, 18" target=_blank>
<area href="http://www.ccw.com.cn/news1/" shape="rect" coords="72, 3, 143, 18" target=_blank>
<area href="http://www.ccw.com.cn/center/" shape="rect" coords="155, 2, 216, 18" target=_blank>
<area href="http://www.ccw.com.cn/work/" shape="rect" coords="225, 2, 299, 18" target=_blank>
<area href="http://www.ccw.com.cn/search/" shape="rect" coords="310, 3, 364, 19" target=_blank>
<area href="http://www3.ccw.com.cn/" shape="rect" coords="372, 2, 412, 19" target=_blank>
<area href="http://www2.ccw.com.cn/" shape="rect" coords="424, 2, 550, 18" target=_blank></map>
	</td></tr>
	<tr><td colspan=2 bgcolor="#b4aafc">
	<table border=0 cellpadding=0 cellspacing=0 width=100%>
		<tr>
            <td width=26% align=center><font  class=v12>【2003年6月24日】&nbsp;&nbsp;&nbsp;</font></td>
            <td CLASS=V12> <a href="http://www.ccw.com.cn/center/topic.asp">专 题</a> /</td>
            <td CLASS=V12><a href="http://www.ccw.com.cn/center/tech.asp">技 术</a>  /</td>
            <td CLASS=V12><a href="http://www.ccw.com.cn/center/prod.asp">产 品</a> /</td>
            <td CLASS=V12><a href="http://www.ccw.com.cn/center/app.asp">应 用</a> /</td>
            <td CLASS=V12><a href="http://www.ccw.com.cn/center/net.asp">网 络</a> /</td>
            <td CLASS=V12><a href="http://www.ccw.com.cn/center/prog.asp">编 程</a> /</td>
            <td CLASS=V12><a href="http://www.ccw.com.cn/center/skill.asp">技 巧</a> </td>
         </tr>
	</table>
	</td></tr>
</table>
<table align=center width=728>
<tr><td align=center><br><h2><font color='#0f3ccd'>Visual C++ 编程问答(四)</font></h2>
</td></tr><tr><td align=right>01-9-16 下午 04:48:24<br><hr size=1 width=718 color=#f46240></td></tr></table><br>
<table align=center width=728><tr><td valign=top width=600>
  <table width=100% >
    <tr> 
      <td class=a14><b>61.如何查询和设置系统参数?</b></td>
    </tr>
  </table>
  <table width=100% ><tr><td class=a14>
在Windows 3.1 SDK中介绍过SDK函数SystemParametersInfo,调用该函数可以查询和设置系统参数,诸如按键的重复速率设置、鼠标双击延迟时间、图标字体以及桌面覆盖位图等等。</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
//Create a font that is used for icon titles.</td></tr></table><table width=100% ><tr><td class=a14>
LOGFONT stFont</td></tr></table><table width=100% ><tr><td class=a14>
 ∶: SystemParametersInfo (SPIF_GETICONTITLELOGFONT, sizeof (LOGFONT), &stFont, SPIF_SENDWININICHANGE)</td></tr></table><table width=100% ><tr><td class=a14>
m_font.CreateFontIndirect (&stFont)</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
//Change the wallpaper to leaves.bmp.</td></tr></table><table width=100% ><tr><td class=a14>
∶ : SystemParametersInfo (SPI_SETDESKWALLPAPER, 0, _T (" forest.bmp"), SPIF_UPDATEINIFILE)</td></tr></table>
  <table width=100% >
    <tr> 
      <td class=a14><b> <a name="62">62.如何使用一个预定义的Windows光标?</a></b></td>
    </tr>
  </table>
  <table width=100% ><tr><td class=a14>
调用CWinApp:: LoadStandardCursor并传送光标标识符。</td></tr></table><table width=100% ><tr><td class=a14>
 BOOL CSampleDialog:: OnSetCursor (CWnd* pWnd,</td></tr></table><table width=100% ><tr><td class=a14>
UINT nHitTest, UINT</td></tr></table><table width=100% ><tr><td class=a14>
message)</td></tr></table><table width=100% ><tr><td class=a14>
{</td></tr></table><table width=100% ><tr><td class=a14>
 //Display wait cursor if busy.</td></tr></table><table width=100% ><tr><td class=a14>
 if (m_bBusy)</td></tr></table><table width=100% ><tr><td class=a14>
 {</td></tr></table><table width=100% ><tr><td class=a14>
 SetCursor (AfxGetApp () ->LoadStandardCursor (IDC_WAIT))</td></tr></table><table width=100% ><tr><td class=a14>
 return TRUE</td></tr></table><table width=100% ><tr><td class=a14>
 }</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
 return CDialog:: OnSetCursor (pWnd. nHitTest,message)</td></tr></table><table width=100% ><tr><td class=a14>
}</td></tr></table>
  <table width=100% >
    <tr> 
      <td class=a14><b> <a name="63">63.如何确定当前屏幕分辨率?</a></b></td>
    </tr>
  </table>
  <table width=100% ><tr><td class=a14>
调用SDK函数GetSystemMetrics,该函数可以检索有关windows显示信息,诸如标题大小、边界大小以及滚动条大小等等。</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
//Initialize CSize object with screen size.</td></tr></table><table width=100% ><tr><td class=a14>
CSize sizeScreen (GetSystemMetrics (SM_CXSCREEN),</td></tr></table><table width=100% ><tr><td class=a14>
 GetSystemMetrics (SM_CYSCREEN))</td></tr></table>
  <table width=100% >
    <tr> 
      <td class=a14><b> <a name="64">64.如何检索原先的Task Manager应用程序使用的任务列表?</a></b></td>
    </tr>
  </table>
  <table width=100% ><tr><td class=a14>
原先的Task Manager应用程序显示顶层窗口的列表。为了显示该列表,窗口必须可见、包含一个标题以及不能被其他窗口拥有。调用CWnd:: GetWindow可以检索顶层窗口的列表,调用IsWindowVisible、GetWindowTextLength以及GetOwner可以确定窗口是否应该在列表中。下例将把TaskManager窗口的标题填充到列表中。</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
void GetTadkList (CListBox&list)</td></tr></table><table width=100% ><tr><td class=a14>
{</td></tr></table><table width=100% ><tr><td class=a14>
 CString strCaption</td></tr></table><table width=100% ><tr><td class=a14>
//Caption of window.</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
 list.ResetContent ()</td></tr></table><table width=100% ><tr><td class=a14>
//Clear list box.</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
 //Get first Window in window list.</td></tr></table><table width=100% ><tr><td class=a14>
 ASSERT_VALID (AfxGetMainWnd ())</td></tr></table><table width=100% ><tr><td class=a14>
 CWnd* pWnd=AfxGetMainWnd () ->GetWindow (GW_HWNDFIRST)</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
 //Walk window list.</td></tr></table><table width=100% ><tr><td class=a14>
 while (pWnd)</td></tr></table><table width=100% ><tr><td class=a14>
 {</td></tr></table><table width=100% ><tr><td class=a14>
 // I window visible, has a caption, and does not have an owner?</td></tr></table><table width=100% ><tr><td class=a14>
 if (pWnd ->IsWindowVisible()</td></tr></table><table width=100% ><tr><td class=a14>
&& pWnd ->GetWindowTextLength ()</td></tr></table><table width=100% ><tr><td class=a14>
&&! pWnd ->GetOwner ())</td></tr></table><table width=100% ><tr><td class=a14>
 {</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
//Add caption o window to list box.</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
pWnd ->GetWindowText (strCaption)</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
list.AddString (strCaption)</td></tr></table><table width=100% ><tr><td class=a14>
 }</td></tr></table><table width=100% ><tr><td class=a14>
 //Get next window in window list.</td></tr></table><table width=100% ><tr><td class=a14>
 pWnd=pWnd ->GetWindow(GW_HWNDNEXT)</td></tr></table><table width=100% ><tr><td class=a14>
 }</td></tr></table><table width=100% ><tr><td class=a14>
}</td></tr></table>
  <table width=100% >
    <tr> 
      <td class=a14><b> <a name="65">65.如何确定Windows和Windows系统目录?</a></b></td>
    </tr>
  </table>
  <table width=100% ><tr><td class=a14>
有两个SDK函数可以完成该功能。GetWindowsDirectory和GetSystemDirectory,下例说明了如何使用这两个函数:</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
TCHAR szDir [MAX_PATH]</td></tr></table><table width=100% ><tr><td class=a14>
//Get the full path of the windows directory.</td></tr></table><table width=100% ><tr><td class=a14>
∶ : GetWindowsDirectory (szDir, MAX_PATH)</td></tr></table><table width=100% ><tr><td class=a14>
TRACE ("Windows directory %s\n", szDir)</td></tr></table><table width=100% ><tr><td class=a14>
//Get the full path of the windows system directory.</td></tr></table><table width=100% ><tr><td class=a14>
∶ : GetSystemDirectory (szDir, MAX_PATH)</td></tr></table><table width=100% ><tr><td class=a14>
TRACE ("Windows system directory %s\n", szDir)</td></tr></table>
  <table width=100% >
    <tr> 
      <td class=a14><b><a name="66"> 66.在哪儿创建临文件? </a></b></td>
    </tr>
  </table>
  <table width=100% ><tr><td class=a14>
调用SDK函数GetTemPath可以确定临时文件的目录,该函数首先为临时路径检测TMP环境变量:如果没有指定TMP,检测TMP环境变量,然后返回到当前目录。下例说明了如何创建一个临时文件。</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
…</td></tr></table><table width=100% ><tr><td class=a14>
 //get unique temporary file.</td></tr></table><table width=100% ><tr><td class=a14>
 CString strFile</td></tr></table><table width=100% ><tr><td class=a14>
 GetUniqueTempName (strFile)</td></tr></table><table width=100% ><tr><td class=a14>
 TRY</td></tr></table><table width=100% ><tr><td class=a14>
 {</td></tr></table><table width=100% ><tr><td class=a14>
 //Create file and write data.Note that file is closed</td></tr></table><table width=100% ><tr><td class=a14>
 //in the destructor of the CFile object.</td></tr></table><table width=100% ><tr><td class=a14>
 CFile file (strFile,CFile ::modeCreate | CFile:: modeWrite)</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
 //write data</td></tr></table><table width=100% ><tr><td class=a14>
 }</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
 CATCH (CFileException, e)</td></tr></table><table width=100% ><tr><td class=a14>
 {</td></tr></table><table width=100% ><tr><td class=a14>
 //error opening file</td></tr></table><table width=100% ><tr><td class=a14>
 }</td></tr></table><table width=100% ><tr><td class=a14>
 END_CATCH</td></tr></table><table width=100% ><tr><td class=a14>
…</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
Void GetuniqueTempName (CString& strTempName)</td></tr></table><table width=100% ><tr><td class=a14>
{</td></tr></table><table width=100% ><tr><td class=a14>
 //Get the temporary files directory.</td></tr></table><table width=100% ><tr><td class=a14>
 TCHAR szTempPath [MAX_PATH]</td></tr></table><table width=100% ><tr><td class=a14>
 DWORD dwResult=:: GetTempPath (MAX_PATH, szTempPath)</td></tr></table><table width=100% ><tr><td class=a14>
 ASSERT (dwResult)</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
 //Create a unique temporary file.</td></tr></table><table width=100% ><tr><td class=a14>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -