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

📄 vbtips3.htm

📁 所有我收藏的VB技巧
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<html>

<head>
<meta http-equiv="Content-Type"
content="text/html; charset=gb_2312-80">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>VBTips4</title>
</head>

<body>

<h1 align="center"><a name="home"></a>VB技巧<font size="5"><strong>(4)</strong></font></h1>

<blockquote>
    <p><strong>1、</strong><a href="#tips0"><strong>把 VB
    标准的工具栏变成平面式</strong></a><strong><br>
    2、</strong><a href="#tips1"><strong>在 Caption 中显示
    &amp; 符号</strong></a><strong><br>
    3、</strong><a href="#tips2"><strong>让窗口一直在上面</strong></a><strong><br>
    4、</strong><a href="#tips3"><strong>播放资源文件中的声音</strong></a><strong><br>
    5、</strong><a href="#tips4"><strong>使用枚举变量</strong></a><strong><br>
    6、</strong><a href="#tips5"><strong>动态改变屏幕设置</strong></a><strong><br>
    7、</strong><a href="#tips6"><strong>移动没有标题栏的窗口</strong></a><strong><br>
    8、</strong><a href="#tips7"><strong>快速选择全部项目</strong></a><strong><br>
    9、</strong><a href="#tips8"><strong>真正删除数据库的记录</strong></a><strong><br>
    10、</strong><a href="#tips9"><strong>捕捉 MoueExit 事件</strong></a></p>
    <div align="center"><center><table border="0" cellspacing="1"
    width="88%">
        <tr>
            <td width="80%"><p align="left"><a
            href="vbtips.htm#Return">[1]</a> <a
            href="vbtips1.htm">[2]</a> <a href="vbtips2.htm">[3]</a>
            [4] <a href="vbtips4.htm">[5]</a> <a
            href="vbtips5.htm">[6]</a> <a href="vbtips7.htm">[7]</a>
            <a href="#home">[8]</a> <a href="vbtips9.htm">[9]</a>
            <a href="vbtips10.htm">[10]</a></p>
            </td>
            <td><p align="right"><font size="2">第四页(共十页)</font></p>
            </td>
        </tr>
    </table>
    </center></div>
</blockquote>

<hr>

<blockquote>
</blockquote>
<div align="center"><center>

<table border="0" width="88%">
    <tr>
        <td><a name="tips0"></a><strong>把 VB
        标准的工具栏变成平面式 </strong><br>
        平面式的工具栏好象显得很酷!但 VB5
        只提供了普通的凸起的工具栏。你是否想把它变成平面的?这似乎<br>
        很不容易。但事实并非如此,试试: <br>
        BAS: <br>
        Public Const WM_USER = &amp;H400<br>
        Public Const TB_SETSTYLE = WM_USER + 56<br>
        Public Const TB_GETSTYLE = WM_USER + 57<br>
        Public Const TBSTYLE_FLAT = &amp;H800<br>
        Public Declare Function SendMessageLong Lib
        &quot;user32&quot; Alias &quot;SendMessageA&quot; _<br>
        (ByVal hwnd As Long, _<br>
        ByVal wMsg As Long, _<br>
        ByVal wParam As Long, _<br>
        ByVal lParam As Long) As Long<br>
        Public Declare Function FindWindowEx Lib
        &quot;user32&quot; Alias &quot;FindWindowExA&quot; _<br>
        (ByVal hWnd1 As Long, _<br>
        ByVal hWnd2 As Long, _<br>
        ByVal lpsz1 As String, _<br>
        ByVal lpsz2 As String) As Long<br>
        SUB: <br>
        Private Sub MakeFlat()<br>
        Dim style As Long<br>
        Dim hToolbar As Long<br>
        Dim r As Long<br>
        hToolbar = FindWindowEx(Toolbar1.hwnd, 0&amp;,
        &quot;ToolbarWindow32&quot;, vbNullString)<br>
        style = SendMessageLong(hToolbar, TB_GETSTYLE, 0&amp;,
        0&amp;)<br>
        If style And TBSTYLE_FLAT Then<br>
        style = style Xor TBSTYLE_FLAT<br>
        Else: style = style Or TBSTYLE_FLAT<br>
        End If<br>
        r = SendMessageLong(hToolbar, TB_SETSTYLE, 0, style)<br>
        Toolbar1.Refresh<br>
        End Sub<br>
        注意:需要 4.70 或其以上版本的 comctl32.dll
        支持。<br>
        <a href="#home">返回</a><p><a name="tips1"></a><strong>在
        Caption 中显示 &amp; 符号 </strong><br>
        大家知道,&amp; 符号是 Windows
        的快捷键表示符号,如果要在 Caption 中显示
        &amp; ,方法很简单,连续输入<br>
        两个 &amp; 符号即可。如在 Caption 中输入 Save
        &amp;&amp; Exit,则显示 Save &amp; Exit。 <br>
        <a href="#home">返回</a></p>
        <p><a name="tips2"></a><strong>让窗口一直在上面 </strong><br>
        很多流行软件都有这样一个选项:Always on
        Top。它可以让窗口在最上面,别的窗口不能覆盖它。我们在<br>
        VB 中,可以使用下面的方法来实现: <br>
        Private Const SWP_NOSIZE = &amp;H1<br>
        Private Const SWP_NOMOVE = &amp;H2<br>
        Private Const SWP_NOZORDER = &amp;H4<br>
        Private Const SWP_NOREDRAW = &amp;H8<br>
        Private Const SWP_NOACTIVATE = &amp;H10<br>
        Private Const SWP_FRAMECHANGED = &amp;H20<br>
        Private Const SWP_SHOWWINDOW = &amp;H40<br>
        Private Const SWP_NOCOPYBITS = &amp;H80<br>
        Private Const SWP_NOOWNERZORDER = &amp;H200<br>
        Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED<br>
        Private Const SWP_NOREPOSITION = SWP_NOOWNERZORDER
        Private Const HWND_TOP = 0<br>
        Private Const HWND_BOTTOM = 1<br>
        Private Const HWND_TOPMOST = -1<br>
        Private Const HWND_NOTOPMOST = -2 <br>
        Private Declare Function SetWindowPos Lib
        &quot;user32&quot; ( _<br>
        ByVal hwnd As Long, _<br>
        ByVal hWndInsertAfter As Long, _<br>
        ByVal X As Long, _<br>
        ByVal Y As Long, _<br>
        ByVal cx As Long, _<br>
        ByVal cy As Long, _<br>
        ByVal wFlags As Long) As Long<br>
        Private mbOnTop As Boolean<br>
        Private Property Let OnTop(Setting As Boolean)<br>
        if Setting Then<br>
        SetWindowPos hwnd, -1, 0, 0, 0, 0, SWP_NOMOVE Or
        SWP_NOSIZE<br>
        Else<br>
        SetWindowPos hwnd, -2, 0, 0, 0, 0, SWP_NOMOVE Or
        SWP_NOSIZE<br>
        End If<br>
        mbOnTop = Setting<br>
        End Property <br>
        Private Property Get OnTop() As Boolean<br>
        'Return the private variable set in Property Let<br>
        OnTop = mbOnTop<br>
        End Property <br>
        调用 OnTop=True 即可让窗口 Always OnTop。 <br>
        <a href="#home">返回</a></p>
        <p><a name="tips3"></a><strong>播放资源文件文件中的声音
        </strong><br>
        VB
        提供的方法使我们可以很容易地使用资源文件中的字符、图片等资源。<br>
        我们可以用以下方法播放资源文件中的 wav
        声音: <br>
        首先,在你的资源文件的源文件 (RC)
        文件加入下面一行: <br>
        MySound WAVE c:\music\vanhalen.wav <br>
        然后将其编译为 RES
        文件。最后使用下面的声明及代码: <br>
        Private Declare Function PlaySound Lib _
        &quot;winmm.dll&quot; Alias &quot;PlaySoundA&quot; ( <br>
        _ ByVal lpszName As String, _ ByVal hModule As Long, _
        ByVal dwFlags As Long) As Long <br>
        Private Const SND_ASYNC&amp; = &amp;H1 <br>
        Private Const SND_NODEFAULT&amp; = &amp;H2 <br>
        Private Const SND_RESOURCE&amp; = &amp;H40004 <br>
        Dim hInst As Long <br>
        Dim sSoundName As String <br>
        Dim lFlags As Long <br>
        Dim lRet As Long <br>
        Private Sub Command1_Click() <br>
        hInst = App.hInstance <br>
        sSoundName = &quot;MySound&quot; <br>
        lFlags = SND_RESOURCE + SND_ASYNC + _ SND_NODEFAULT <br>
        lRet = PlaySound(sSoundName, hInst, lFlags) <br>
        End Sub <br>
        <a href="#home">返回</a></p>
        <p><a name="tips4"></a><strong>使用枚举变量 </strong><br>
        VB5
        引入枚举变量,使用它,我们可以显著地改变应用程序的易读性:
        <br>
        Public Enum TimeOfDay<br>
        Morning = 0<br>
        Afternoon = 1<br>
        Evening = 2<br>
        End Enum<br>
        Sub Main()<br>

⌨️ 快捷键说明

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