Jump to content
Fórum Script Brasil
  • 0

Ajuda executar .exe dentro do form


ShadowBill
 Share

Question

Na verdade a duvida é, ao executar um .exe dentro do form, digamos o bloco de notas, ela fica a frente dos botões do meu form, gostaria que os botões ficassem sempre em cima, no caso do exemplo na imagem o botão ficou atras:

form1.png

OBS: O CÓDIGO FAZ COM QUE O BLOCO DE NOTAS NÃO SAIA DE DENTRO DO FORM

Se tiver algo que possa por meu form dentro de um .exe, fazer parte como se fosse um menu adicional, gostária também.

Usei esse codigo:

Public Class Form1
Declare Auto Function SetParent Lib "user32.dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) AsInteger
Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam sInteger, ByVal lParam As Integer) As Integer
Private Const WM_SYSCOMMAND As Integer = 274
Private Const SC_MAXIMIZE As Integer = 61488
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim proc As Process
        proc = Process.Start("C:\windows\notepad.exe")
        proc.WaitForInputIdle()
        SetParent(proc.MainWindowHandle, Me.Handle)
        SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
        Me.BringToFront()
    End Sub
Edited by ShadowBill
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Você pode usar MoveWindow para mover e redimensionar a janela, veja um exemplo:

Public Class Form1
    Declare Auto Function SetParent Lib "user32.dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
    Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    Private Const WM_SYSCOMMAND As Integer = 274
    Private Const SC_MAXIMIZE As Integer = 61488
    Public Declare Auto Function MoveWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal X As Int32, ByVal Y As Int32, ByVal nWidth As Int32, ByVal nHeight As Int32, ByVal bRepaint As Boolean) As Boolean


    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim proc As Process
        proc = Process.Start("C:\windows\notepad.exe")
        proc.WaitForInputIdle()
        SetParent(proc.MainWindowHandle, Me.Handle)
        'SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
        MoveWindow(proc.MainWindowHandle, 50, 100, 300, 300, True)
        Me.BringToFront()
    End Sub
End Class
E você postou na sala errada, esta aqui é apenas sobre o VB6. Para .NET use a respectiva sala.
Abraços!
Edited by Graymalkin
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Forum Statistics

    • Total Topics
      149.8k
    • Total Posts
      646.6k
×
×
  • Create New...