VB怎么使外调程序置顶

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VB怎么使外调程序置顶相关的知识,希望对你有一定的参考价值。

Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow% Lib "user32" Alias "FindWindowA" (ByVal lpclassname As Any, ByVal lpCaption As Any)
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As Long
Const HWND_TOPMOST = -1
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Private Const SW_RESTORE = 9
Private Const SW_HIDE = 0
Private Const SW_SHOW = 5
Dim b As Long

Private Sub Command1_Click()
b = FindWindow("SciCalc", vbNullString)
If b = 0 Then
x = Shell("CALC.EXE", vbMinimizedNoFocus)
b = FindWindow("SciCalc", vbNullString)
SetWindowPos b, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
Else
If IsIconic(b) <> 0 Then
ShowWindow b, SW_RESTORE
Else
SetWindowPos b, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW
End If
End If
End Sub追问

先谢谢你,不过我还有一个问题:窗体的类你是怎么知道的?

追答

SciCalc是计算器的类名MSDN里面有很多例子,另外,不知道的类可以用工具查看,VB安装盘里有个SPY++就可以查看。给分么?

参考技术A shell ("c:\1.exe"),vbNormalFocus
vbNormalFocus很重要

一个vb编的程序!通过滚动条控制文本框颜色的改变

设计一个程序:文本框中的背景色采用RGB配色方案中的颜色,由三个滚动条上的Value值决定,前景色与背景色反相,分别通过255减滚动条的Value值得到。可以使用Change和Scroll事件联合实现变色效果。每个滚动条对应的事件过程中,所作的操作相同,因此可以通过滚动条控件数组方式,使程序更加简单。注意滚动条的Max和Min属性分别赋初值255和0。

参考技术A Private Sub HsbBlue_Change()
Text3.BackColor = RGB(HsbRed.Value, HsbGreen.Value, HsbBlue.Value)
End Sub

Private Sub HsbGreen_Change()
Text2.BackColor = RGB(HsbRed.Value, HsbGreen.Value, HsbBlue.Value)
End Sub

Private Sub HsbRed_Scroll()
Text1.BackColor = RGB(HsbRed.Value, HsbGreen.Value, HsbBlue.Value)
End Sub
参考技术B 自己写吧, 网上有参考程序.

不会就多看点书

以上是关于VB怎么使外调程序置顶的主要内容,如果未能解决你的问题,请参考以下文章

MFC 如何使窗口 置顶

怎么使通过进程打开的win32程序窗口始终置顶

微信小程序怎样置顶

微信小程序置顶显示的小技巧

使 VB.NET 程序崩溃的简单方法

VB.NET如何使控件不能响应KeyDown事件