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

📄 在dll中使用资源(1).htm

📁 我在网上收集的一些有关vcDLL编程的文章。
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 11">
<meta name=Originator content="Microsoft Word 11">
<link rel=File-List href="在DLL中使用资源(1).files/filelist.xml">
<link rel=Edit-Time-Data href="在DLL中使用资源(1).files/editdata.mso">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<title>在DLL中使用资源(一)</title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>pop</o:Author>
  <o:LastAuthor>pop</o:LastAuthor>
  <o:Revision>1</o:Revision>
  <o:TotalTime>0</o:TotalTime>
  <o:Created>2006-04-11T12:45:00Z</o:Created>
  <o:LastSaved>2006-04-11T12:45:00Z</o:LastSaved>
  <o:Pages>1</o:Pages>
  <o:Words>738</o:Words>
  <o:Characters>4209</o:Characters>
  <o:Company>baodi</o:Company>
  <o:Lines>35</o:Lines>
  <o:Paragraphs>9</o:Paragraphs>
  <o:CharactersWithSpaces>4938</o:CharactersWithSpaces>
  <o:Version>11.5606</o:Version>
 </o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:PunctuationKerning/>
  <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
  <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
  <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:Compatibility>
   <w:SpaceForUL/>
   <w:BalanceSingleByteDoubleByteWidth/>
   <w:DoNotLeaveBackslashAlone/>
   <w:ULTrailSpace/>
   <w:DoNotExpandShiftReturn/>
   <w:AdjustLineHeightInTable/>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
   <w:DontGrowAutofit/>
   <w:UseFELayout/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
 </w:LatentStyles>
</xml><![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:宋体;
	panose-1:2 1 6 0 3 1 1 1 1 1;
	mso-font-alt:SimSun;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
	{font-family:"\@宋体";
	panose-1:2 1 6 0 3 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:3 135135232 16 0 262145 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	mso-pagination:none;
	font-size:10.5pt;
	mso-bidi-font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:宋体;
	mso-font-kerning:1.0pt;}
 /* Page Definitions */
 @page
	{mso-page-border-surround-header:no;
	mso-page-border-surround-footer:no;}
@page Section1
	{size:595.3pt 841.9pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	mso-header-margin:42.55pt;
	mso-footer-margin:49.6pt;
	mso-paper-source:0;
	layout-grid:15.6pt;}
div.Section1
	{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:普通表格;
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin:0cm;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";
	mso-ansi-language:#0400;
	mso-fareast-language:#0400;
	mso-bidi-language:#0400;}
</style>
<![endif]-->
</head>

<body lang=ZH-CN style='tab-interval:21.0pt;text-justify-trim:punctuation'>

<div class=Section1 style='layout-grid:15.6pt'>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width="100%"
 style='width:100.0%;mso-cellspacing:0cm;mso-padding-alt:0cm 0cm 0cm 0cm'>
 <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;height:30.0pt'>
  <td style='padding:0cm 0cm 0cm 0cm;height:30.0pt'>
  <p class=MsoNormal align=center style='text-align:center;mso-pagination:widow-orphan'><b><span
  style='font-size:12.0pt;font-family:宋体;mso-bidi-font-family:宋体;mso-font-kerning:
  0pt'>在<span lang=EN-US>DLL</span>中使用资源(一)</span></b><span lang=EN-US
  style='font-size:9.0pt;font-family:宋体;mso-bidi-font-family:宋体;mso-font-kerning:
  0pt'><o:p></o:p></span></p>
  </td>
 </tr>
 <tr style='mso-yfti-irow:1;mso-yfti-lastrow:yes;height:18.75pt'>
  <td style='border:none;border-bottom:solid windowtext 1.5pt;padding:0cm 0cm 0cm 0cm;
  height:18.75pt'>
  <p class=MsoNormal align=center style='text-align:center;mso-pagination:widow-orphan'><span
  style='font-size:9.0pt;font-family:宋体;mso-bidi-font-family:宋体;mso-font-kerning:
  0pt'>【文章出处:转载】<span lang=EN-US>&nbsp;</span>【作者:未知】<span lang=EN-US>&nbsp;</span>【发布时间:<span
  lang=EN-US>2005-01-25</span>】<span lang=EN-US>&nbsp;</span>【查看: <span
  lang=EN-US><script language="JavaScript"  src="/php/count.php?artID=10754&view=yes">
  </script>31</span>次】 <span lang=EN-US><o:p></o:p></span></span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal align=left style='text-align:left;mso-pagination:widow-orphan'><span
lang=EN-US style='font-size:9.0pt;font-family:宋体;mso-bidi-font-family:宋体;
display:none;mso-hide:all;mso-font-kerning:0pt'><o:p>&nbsp;</o:p></span></p>

<div align=center>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width="96%"
 style='width:96.0%;mso-cellspacing:0cm;mso-padding-alt:0cm 0cm 0cm 0cm'>
 <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;height:3.0pt'>
  <td colspan=3 style='padding:0cm 0cm 0cm 0cm;height:3.0pt'>
  <p class=MsoNormal align=left style='text-align:left;mso-pagination:widow-orphan'><span
  lang=EN-US style='font-size:3.0pt;mso-bidi-font-size:9.0pt;font-family:宋体;
  mso-bidi-font-family:宋体;mso-font-kerning:0pt'><o:p>&nbsp;</o:p></span></p>
  </td>
 </tr>
 <tr style='mso-yfti-irow:1;mso-yfti-lastrow:yes'>
  <td valign=top style='padding:0cm 0cm 0cm 0cm' id=fontzoom>
  <p class=MsoNormal align=left style='text-align:left;line-height:15.0pt;
  mso-pagination:widow-orphan'><span lang=EN-US style='font-size:10.0pt;
  font-family:宋体;mso-bidi-font-family:宋体;mso-font-kerning:0pt'><o:p>&nbsp;</o:p></span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:15.0pt;
  mso-pagination:widow-orphan'><span style='font-size:10.0pt;font-family:宋体;
  mso-bidi-font-family:宋体;mso-font-kerning:0pt'>在<span lang=EN-US>DLL</span>中使用资源(一)<span
  lang=EN-US> <br>
  </span>  现在最常看见的关于<span lang=EN-US>DLL</span>的问题就是如何在<span lang=EN-US>DLL</span>中使用对话框,这是一个很普遍的关于如何在<span
  lang=EN-US>DLL</span>中使用资源的问题。这里我们从<span lang=EN-US>Win32 DLL</span>和<span
  lang=EN-US>MFC DLL</span>两个方面来分析并解决这个问题。<span lang=EN-US> <br>
  <br>
  1</span>.<span lang=EN-US>Win32 DLL <br>
  </span>  在<span lang=EN-US>Win32 DLL</span>中使用对话框很简单,你只需要在你的<span lang=EN-US>DLL</span>中添加对话框资源,而且可以在对话框上面设置你所需要的控件。然后使用<span
  lang=EN-US>DialogBox</span>或者<span lang=EN-US>CreateDialog</span>这两个函数(或相同作用的其它函数)来创建对话框,并定义你自己的对话框回调函数处理对话框收到的消息。下面通过一个具体实例来学习如何在<span
  lang=EN-US>Win32 DLL</span>中使用对话框,可以按照以下步骤来完成这个例子:<span lang=EN-US> <br>
  <br>
  <br>
  <br>
  1</span>)在<span lang=EN-US>VC</span>菜单中<span lang=EN-US>File-&gt;New</span>新建一个命名为<span
  lang=EN-US>UseDlg</span>的<span lang=EN-US>Win32 Dynamic-Link Library</span>工程,下一步选择<span
  lang=EN-US>A simple DLL project</span>。<span lang=EN-US> <br>
  <br>
  <br>
  <br>
  2</span>)在<span lang=EN-US>VC</span>菜单中<span lang=EN-US>Insert-&gt;Resource</span>添加一个<span
  lang=EN-US>ID</span>为<span lang=EN-US>IDD_DLG_SHOW</span>的<span lang=EN-US>Dialog</span>资源,将此<span
  lang=EN-US>Dialog</span>上的<span lang=EN-US>Cancel</span>按钮去掉,仅保留<span
  lang=EN-US>OK</span>按钮。再添加一个<span lang=EN-US>ID</span>为<span lang=EN-US>IDD_ABOUTBOX</span>的对话框,其<span
  lang=EN-US>Caption</span>为<span lang=EN-US>About</span>。保存此资源,将资源文件命名为<span
  lang=EN-US>UseDlg.rc</span>。并将<span lang=EN-US>resource.h</span>和<span
  lang=EN-US>UseDlg.rc</span>加入到工程里面。<span lang=EN-US> <br>
  <br>
  <br>
  <br>
  3</span>)在<span lang=EN-US>UseDlg.app</span>中包含<span lang=EN-US>resource.h</span>,并添加如下代码:<span
  lang=EN-US> <br>
  <br>
  <br>
  <br>
  HINSTANCE hinst = NULL; <br>
  <br>
  HWND hwndDLG = NULL; <br>
  <br>
  <br>
  <br>
  BOOL CALLBACK DlgProc(HWND hDlg, UINT message, <br>
  <br>
  WPARAM wParam, LPARAM lParam); <br>
  <br>
  BOOL CALLBACK AboutProc(HWND hDlg, UINT message, <br>
  <br>
  WPARAM wParam, LPARAM lParam); <br>
  <br>
  extern &quot;C&quot; __declspec(dllexport) void ShowDlg(); <br>
  <br>
  <br>
  <br>
  BOOL APIENTRY DllMain( HANDLE hModule, <br>
  <br>
  </span>     <span lang=EN-US> DWORD ul_reason_for_call, <br>
  <br>
  </span>     <span lang=EN-US> LPVOID lpReserved <br>
  <br>
  </span>         <span lang=EN-US>) <br>
  <br>
  { <br>
  <br>
  </span> <span lang=EN-US> switch(ul_reason_for_call) <br>
  <br>
  </span> <span lang=EN-US> { <br>
  <br>
  </span> <span lang=EN-US> case DLL_PROCESS_ATTACH: <br>
  <br>
  </span>   <span lang=EN-US> hinst = (HINSTANCE)hModule; <br>
  <br>
  </span> <span lang=EN-US> case DLL_PROCESS_DETACH: <br>
  <br>
  </span>   <span lang=EN-US> break; <br>
  <br>
  </span> <span lang=EN-US> } <br>
  <br>
  </span> <span lang=EN-US>return TRUE; <br>
  <br>
  } <br>
  <br>
  <br>
  <br>
  extern &quot;C&quot; __declspec(dllexport) void ShowDlg() <br>
  <br>
  { <br>
  <br>
  </span> <span lang=EN-US> hwndDLG =
  CreateDialog(hinst,MAKEINTRESOURCE(IDD_DLG_SHOW), <br>
  <br>
  NULL,(DLGPROC)DlgProc); <br>
  <br>
  </span> <span lang=EN-US> ShowWindow(hwndDLG, SW_SHOW); <br>
  <br>
  } <br>
  <br>
  <br>
  <br>
  BOOL CALLBACK DlgProc(HWND hDlg, UINT message, <br>
  <br>
  WPARAM wParam, LPARAM lParam) <br>
  <br>
  { <br>
  <br>

⌨️ 快捷键说明

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