Results 1 to 2 of 2

Thread: Showmodal -> owner

  1. #1
    CharlyDoes
    Guest

    Showmodal -> owner

    Hi,

    I have a hWnd of a window I wan't to be the owner of a form... the showmodal function only takes a form as parameter, not a hWnd... is there any way to show a form modal with the hWnd value instead of a form?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    2. Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    3. Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
    4. Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    5. Const SW_SHOWNORMAL = 1
    6. Const WM_CLOSE = &H10
    7. Const gcClassnameMSWord = "OpusApp"
    8. Const gcClassnameMSExcel = "XLMAIN"
    9. Const gcClassnameMSIExplorer = "IEFrame"
    10. Const gcClassnameMSVBasic = "wndclass_desked_gsk"
    11. Const gcClassnameNotePad = "Notepad"
    12. Const gcClassnameMyVBApp = "ThunderForm"
    13. Private Sub Form_Load()
    14.     'KPD-Team 1998
    15.     'URL: [url]http://www.allapi.net/[/url]
    16.     'E-Mail: [email][email protected][/email]
    17.     Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
    18.     'Ask for a Window title
    19.     Ret = InputBox("Enter the exact window title:" + Chr$(13) + Chr$(10) + "Note: must be an exact match")
    20.     'Search the window
    21.     WinWnd = FindWindow(vbNullString, Ret)
    22.     If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
    23.     'Show the window
    24.     ShowWindow WinWnd, SW_SHOWNORMAL
    25.     'Create a buffer
    26.     lpClassName = Space(256)
    27.     'retrieve the class name
    28.     RetVal = GetClassName(WinWnd, lpClassName, 256)
    29.     'Show the classname
    30.     MsgBox "Classname: " + Left$(lpClassName, RetVal)
    31.     'Post a message to the window to close itself
    32.     PostMessage WinWnd, WM_CLOSE, 0&, 0&
    33. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width