如何把窗体置于顶层

flying02 2005-01-06 03:16:36

Applyphotoshop ("open")
DoEvents
Load frmPhotoShow
Me.Hide
frmPhotoShow.Show vbModal
以上语句先打开photoshop,然后加载另一个窗体,然后显示这个加载的窗体,隐藏原窗体,然后需要把新加载的窗体置于photoshop的上层,但是无法置于上层.有什么好办法吗?
...全文
142 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
flying02 2005-01-06
  • 打赏
  • 举报
回复
楼上这位朋友的方法解决了问题谢谢两位
zhengoodman 2005-01-06
  • 打赏
  • 举报
回复
使窗体保持在最上层
有时应用程序需要一个信息或查询窗体总保持在最上层,即使用读书切换到其他窗体也能看到该窗体,如Microsoft Word中的Find窗体,这是通过调用Windows API函数SetWindowPos()实现的,示例如下:
Option Explicit
Private Declare Function SetWindowPos Lib“User32”(ByValhwnd As Long,ByVal h WndInsertAfter As Long,ByVal x As Long,ByVAl y As Long,ByVal cx As Long,ByVal cy As Long,ByVal wFlags As Long)As Long
Const HWND_TOPMOST=-1
Const SWP_SHOWWINDOW=&H40
Private Sub Form_load()
Dim retValue As Long
RetValue=setWindowPos(me.hwnd,HWND_TOPMOST,Me.CurrentX,Me.CurrentY,300,300,SWP_SHOWWINDOW)
End Sub
henry520 2005-01-06
  • 打赏
  • 举报
回复
Public 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
Public Const HWND_TOPMOST = -1

Public Function OnTop(ByVal hWnd As Long, ByVal frmlef As Long, ByVal frmtop As Long, ByVal frmwid As Long, ByVal frmhei As Long)
SetWindowPos hWnd, HWND_TOPMOST, frmlef / Screen.TwipsPerPixelX, frmtop \ Screen.TwipsPerPixelY, frmwid \ Screen.TwipsPerPixelX, frmhei \ Screen.TwipsPerPixelY, 0
End Function

窗体:
private sub form_load()
call ontop(me.hwnd,me.left,me.top,me.width,me.height)
end sub
二师兄的老公 2005-01-06
  • 打赏
  • 举报
回复
可以用API让窗体置顶,例子很多,搜一下吧。

1,486

社区成员

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

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