流星蔡园 发表于 2011-7-2 14:27:01

[求助]窗口的前端显示

求助
VB写的.exe里有对话框,在CAD菜单调用,怎么让对话框显示在AutoCAD窗口的前端

chpmould 发表于 2011-7-2 16:25:30

很久没有用VB了,记得是需要先做以下声明,你可以参考一下,希望能帮到你
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

pmq 发表于 2011-7-3 10:13:03

'Module1

Option Explicit

'===============窗口置顶=====================================
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 Const HWND_BOTTOM = -2
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOZORDER = &H8
Const WM_KEYDOWN = &H100

Public Sub SetFormTopmost(TheForm As Form)    '窗口置顶
    SetWindowPos TheForm.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOZORDER + SWP_NOMOVE + SWP_NOSIZE
End Sub

Public Sub SetFormNoTopMost(TheForm As Form) '解除置顶
    SetWindowPos TheForm.hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOZORDER + SWP_NOMOVE + SWP_NOSIZE
End Sub
'--------------------------------------------------
'Form
Private Sub Form_Load()
    SetFormTopmost Form1
End Sub

这是窗口置顶,但不知相对置顶怎么弄,就象记事本与查找对话框那样。

流星蔡园 发表于 2011-7-11 11:10:24

楼上这个是窗口显示在所有窗品的前端,而不只是CAD的前端吧。
页: [1]
查看完整版本: [求助]窗口的前端显示