Problemas con la api SetParent
Publicado por Evan Hailey (51 intervenciones) el 04/01/2020 21:11:40
Saludos, hoy escribo con idea de encontrar a alguien que entienda de apis de windows porque resulta que intento incrustar una ventana de emulador (Emulador Mame32) en un formulario y al parecer se incrusta, pero se queda congelada perdiendo su funcionalidad y no entiendo porque pasa esto.
Dejo el código que tengo mas una captura para que vean el problemas, desde ya agradeceré cualquier orientación al respecto.
Resultado:

Dejo el código que tengo mas una captura para que vean el problemas, desde ya agradeceré cualquier orientación al respecto.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Imports System.Runtime.InteropServices
Imports System.Threading
Public Class Formulario
Public Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String,
ByVal lpWindowName As String) As Int32
Declare Auto Function SendMessage Lib "user32" (ByVal hwnd As IntPtr,
ByVal msg As Integer,
ByVal wParam As Integer,
ByVal lParam As Integer) As Integer
Const WM_SYSCOMMAND As Integer = &H112
Const SC_MINIMIZE As Integer = &HF020
Const SC_MAXIMIZE As Integer = &HF030
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Public Shared Function SetParent(ByVal hWndChild As IntPtr,
ByVal hWndNewParent As IntPtr) As IntPtr
End Function
Private myHWND As IntPtr = IntPtr.Zero
Private Sub scene_Load(sender As Object, e As EventArgs) Handles MyBase.Load
myHWND = FindWindow("ClassMAME32", "Mortal Kombat (rev 5.0 T-Unit 03/19/93)")
Me.Text = myHWND.ToString
End Sub
Private Sub scene_Shown(sender As Object, e As EventArgs) Handles Me.Shown
Thread.Sleep(500)
SetParent(myHWND, Me.Handle)
My.Application.DoEvents()
Thread.Sleep(500)
SendMessage(myHWND, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
End Sub
End Class
Resultado:

Valora esta pregunta


0