【求助】标题栏上的菜单是怎么实现的?如图:
<p><img src="http://pb.images22.51img1.com/6000/loverosebay/bd069d3411b4415263f4ce7bd72d968a.jpg"/></p><p> </p>
<p>如图:像这样(红色部分)的菜单是怎么制作的? </p>
<p>单击程序图标或是最小化时单击鼠标右键会弹出这样的菜单,怎样在里面加入自己的菜单项?</p> <p><font face="Verdana">先取得系统菜单的句柄,再用AppendMenu添加即可.</font></p>
<p> </p>
<p><font face="Verdana"> SysMenuHwnd = GetSystemMenu(Me.hWnd, False) '取得系统自带菜单句柄</font></p>
<p><font face="Verdana"> Call AppendMenu(SysMenuHwnd, MF_SEPARATOR, 2000, vbNullString) '添加个分隔条<br/> Call AppendMenu(SysMenuHwnd, MF_STRING, 2001, "关于本程序(&A)") '添加个字符串项,并指定ID,响应时需要用到.</font></p>
<p> </p>
<p></p> <p>谢谢! 今天刚发现这个论坛,从下午到现在把论坛里几乎所有的贴子都看了一遍,获益不少啊,呵呵..</p> <p>论坛里的帖子基本上都是这四五年来积累的,很少有站外转帖.</p>
<p> </p>
<p>所以量不多,但我觉得这样挺好.</p> <p>是啊. 很多外面看不到的东西...</p>
<p>我自学VB也才差不多一年,而且初中毕业的水平,学起来比较吃力..</p>
<p>常期一个VB6.0的窗口,一个MSDN,一个金山快译.边写边查边试..</p>
<p>到目前为止写得最多的还是数据库操作类的程序.(只用过ACCESS.MSSQL.SQL桌面版(MSDE))</p>
<p>以后有问题,搜索引擎找不到答案就有地方可以问了.呵呵.. 多与大家交流吧..</p> <p>欢迎交流!</p>
<p> </p>
<p>数据库方面的东西我是接触得比较少,可能还需要大家带带我!</p> 谢谢老马了,很不错,有点头绪了 <div class="msgheader">QUOTE:</div><div class="msgborder"><b>以下是引用<i>menfly</i>在23/07/2009 20:17:43的发言:</b><br/>
<p>想学习api,有几个问题一直没搞懂,请教下老马</p>
<p>你的程序里</p>
<p><font face="Verdana">Private Const MF_SEPARATOR As Long = &H800&<br/>Private Const MF_STRING As Long = &H0&<br/>Private Const WM_SYSCOMMAND As Long = &H112</font></p>
<p> </p>
<p>这几个定义是哪个api函数要用的?</p>
<p>后面那个值如:&H800& 是固定的吗,还是根据需要自己设置的?</p>
<p>如何知道调用api函数时要定义这几个long型值呢?</p>
<p> </p>
<p>这几个问题在网上一直没看到解释,能不能简单讲下呢,或者推荐个能解决这些问题的教程也行,谢谢了<br/></p></div>
<p> </p>
<p>像<font face="Verdana">Const WM_SYSCOMMAND As Long = &H112</font>这样的内容叫"常量",其值是微软定义的,取了一个如<font face="Verdana">WM_SYSCOMMAND一样的字符串名字,只是为了让程序员在写程序时,代码的可读性较好.</font></p>
<p> </p>
<p>具体某个API实现某些功能时所需要使用到的常量值,在MSDN上是可以查到的,比如你要用<font face="Verdana">GetWindowLong</font>得到某句柄的扩展样式,就需要配合<font face="Verdana">GWL_EXSTYLE</font>常量,MSDN中是这么说的:</p>
<div class="msgheader">QUOTE:</div><div class="msgborder"><b>以下引用至MSDN:</b><br/>
<p> </p>
<h1><a name="_win32_getwindowlong"></a>GetWindowLong</h1>
<p>The <b>GetWindowLong</b> function retrieves information about the specified window. The function also retrieves the 32-bit (long) value at the specified offset into the extra window memory of a window. </p><pre><code><b>LONG GetWindowLong(
HWND</b><i> hWnd</i><b>,</b>// handle of window
<b>int</b><i> nIndex</i>// offset of value to retrieve
<b>);</b>
</code></pre>
<h4>Parameters</h4>
<dl>
<dt><i>hWnd</i>
<dd>Handle to the window and, indirectly, the class to which the window belongs.
<dt><i>nIndex</i>
<dd>Specifies the zero-based offset to the value to be retrieved. Valid values are in the range zero through the number of bytes of extra window memory, minus four; for example, if you specified 12 or more bytes of extra memory, a value of 8 would be an index to the third 32-bit integer. To retrieve any other value, specify one of the following values:
<table cellspacing="4" cols="2">
<tbody>
<tr valign="top">
<th align="left" width="36%">Value</th>
<th align="left" width="64%">Action</th></tr>
<tr valign="top">
<td width="36%">GWL_EXSTYLE</td>
<td width="64%">Retrieves the extended window styles.</td></tr>
<tr valign="top">
<td width="36%">GWL_STYLE</td>
<td width="64%">Retrieves the window styles.</td></tr>
<tr valign="top">
<td width="36%">GWL_WNDPROC</td>
<td width="64%">Retrieves the address of the window procedure, or a handle representing the address of the window procedure. You must use the <b>CallWindowProc</b> function to call the window procedure.</td></tr>
<tr valign="top">
<td width="36%">GWL_HINSTANCE</td>
<td width="64%">Retrieves the handle of the application instance.</td></tr>
<tr valign="top">
<td width="36%">GWL_HWNDPARENT</td>
<td width="64%">Retrieves the handle of the parent window, if any.</td></tr>
<tr valign="top">
<td width="36%">GWL_ID</td>
<td width="64%">Retrieves the identifier of the window.</td></tr>
<tr valign="top">
<td width="36%">GWL_USERDATA</td>
<td width="64%">Retrieves the 32-bit value associated with the window. Each window has a corresponding 32-bit value intended for use by the application that created the window.</td></tr></tbody></table><br/>
<p>The following values are also available when the <i>hWnd</i> parameter identifies a dialog box:
<table cellspacing="4" cols="2">
<tbody>
<tr valign="top">
<th align="left" width="33%">Value</th>
<th align="left" width="67%">Action</th></tr>
<tr valign="top">
<td width="33%">DWL_DLGPROC</td>
<td width="67%">Retrieves the address of the dialog box procedure, or a handle representing the address of the dialog box procedure. You must use the <b>CallWindowProc</b> function to call the dialog box procedure.</td></tr>
<tr valign="top">
<td width="33%">DWL_MSGRESULT</td>
<td width="67%">Retrieves the return value of a message processed in the dialog box procedure.</td></tr>
<tr valign="top">
<td width="33%">DWL_USER</td>
<td width="67%">Retrieves extra information private to the application, such as handles or pointers.</td></tr></tbody></table><br/></p></dd></dl>
<h4>Return Values</h4>
<p>If the function succeeds, the return value is the requested 32-bit value.</p>
<p>If the function fails, the return value is zero. To get extended error information, call <b>GetLastError</b>.</p>
<p><br/> </p></div>
<p> </p>
<p>至于常量,API浏览器里面可以查到,不过我推荐你使用API VIEWER2004,相当的全.</p>
[此贴子已经被作者于2009-7-24 20:34:34编辑过] <p>站长是好人,鉴定完毕。</p>
<p> </p> <p>想学习api,有几个问题一直没搞懂,请教下老马</p>
<p>你的程序里</p>
<p><font face="Verdana">Private Const MF_SEPARATOR As Long = &H800&<br/>Private Const MF_STRING As Long = &H0&<br/>Private Const WM_SYSCOMMAND As Long = &H112</font></p>
<p> </p>
<p>这几个定义是哪个api函数要用的?</p>
<p>后面那个值如:&H800& 是固定的吗,还是根据需要自己设置的?</p>
<p>如何知道调用api函数时要定义这几个long型值呢?</p>
<p> </p>
<p>这几个问题在网上一直没看到解释,能不能简单讲下呢,或者推荐个能解决这些问题的教程也行,谢谢了<br/></p>
页:
[1]