hi,有分,

juror 2003-10-15 04:18:15
只在本应用程序中,
怎么样能使一个窗体一直存在于最顶层。
...全文
40 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
kmzs 2003-10-16
  • 打赏
  • 举报
回复
这样应该行了
juror 2003-10-16
  • 打赏
  • 举报
回复
给分了
juror 2003-10-16
  • 打赏
  • 举报
回复
是解霸ontop的较果吗?
守城小轩 2003-10-15
  • 打赏
  • 举报
回复
模块
Option Explicit

Public Const HWND_TOP = 0
Public Const HWND_BOTTOM = 1
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2

Public Const SWP_NOSIZE = &H1
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOZORDER = &H4
Public Const SWP_NOREDRAW = &H8

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
窗体
Option Explicit

Private Sub Command1_Click()
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
End Sub

Private Sub Command2_Click()
SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
End Sub
victorycyz 2003-10-15
  • 打赏
  • 举报
回复
模块部分:
Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (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

Global Const SWP_HIDEWINDOW = &H80
Global Const SWP_NOACTIVATE = &H10
Global Const SWP_NOCOPYBITS = &H100
Global Const SWP_NOMOVE = &H2
Global Const SWP_NOOWNERZORDER = &H200
Global Const SWP_NOREDRAW = &H8
Global Const SWP_NOREPOSITION = SWP_NOOWNERZORDER
Global Const SWP_NOSIZE = &H1
Global Const SWP_NOZORDER = &H4
Global Const SWP_SHOWWINDOW = &H40
Global Const HWND_BOTTOM = 1
Global Const HWND_BROADCAST = &HFFFF&
Global Const HWND_DESKTOP = 0
Global Const HWND_NOTOPMOST = -2
Global Const HWND_TOPMOST = -1
Global Const HWND_TOP = 0
Global Const Flags=SWP_NOMOVE Or SWP_NOSIZE

窗体部分:
Dim Success as Long
SuccesS=SetwindowPos(me.HWnd. HWND_TOPMOST,0,0,0,0,FLAGS)
若Success返回的值不等于零则表示调用成功。
luckysym 2003-10-15
  • 打赏
  • 举报
回复
应该是这个

BringWindowToTop Function

--------------------------------------------------------------------------------

The BringWindowToTop function brings the specified window to the top of the Z order. If the window is a top-level window, it is activated. If the window is a child window, the top-level parent window associated with the child window is activated.

Syntax

BOOL BringWindowToTop( HWND hWnd
);
Parameters

hWnd
[in] Handle to the window to bring to the top of the Z order.
Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

luckysym 2003-10-15
  • 打赏
  • 举报
回复
在每次窗口失去焦点时调用以下API

SetFocus Function

--------------------------------------------------------------------------------

The SetFocus function sets the keyboard focus to the specified window. The window must be attached to the calling thread's message queue.

Syntax

HWND SetFocus( HWND hWnd
);
Parameters

hWnd
[in] Handle to the window that will receive the keyboard input. If this parameter is NULL, keystrokes are ignored.
Return Value

If the function succeeds, the return value is the handle to the window that previously had the keyboard focus. If the hWnd parameter is invalid or the window is not attached to the calling thread's message queue, the return value is NULL. To get extended error information, call GetLastError.

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧