Habe es geschaft ein externes Fenster mittels Mouse zu steuern. Möchte das aber nicht mit der Mouse sonder dem externen Fenster eine fixe Position zu teilen.
Kann mir da jemand sagen was ich bei diesem Code ändern muss damit es funktioniert ?? Komme einfach nicht drauf und ähnliche Codes habe ich leider nicht gefunden, bzw nicht umsetzen können.
Gruß Martin
'Um Fehler oder Fragen zu klären, nutzen Sie bitte unser Forum.
'Ansonsten viel Spaß und Erfolg mit diesem Source!
'------------- Anfang Projektdatei Project1.vbp -------------
'--------- Anfang Formular "Form1" alias Form1.frm ---------
' Steuerelement: Schaltfläche "Command2"
' Steuerelement: Schaltfläche "Command1"
' Steuerelement: Bildfeld-Steuerelement "Picture1"
Option Explicit
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
Private Declare Function ShowWindow Lib "user32" (ByVal _
hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal _
hwnd As Long, lpRect As RECT) As Long
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As String) As Long
Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1
Const HWND_TOPMOST = -1
Const SW_MAXIMIZE = 3
Const SW_MINIMIZE = 6
Const SW_RESTORE = 9
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Dim XhWnd&
Private Sub Form_Load()
Dim Result&
Picture1.ScaleMode = vbPixels
Picture1.Print "Hier die Maus drüber bewegen !"
'NotePad starten
Result = Shell("C:\Casino\Casino Tropez\casino.exe", vbNormalFocus)
'Handle des Notepads auslesen
XhWnd = FindWindow(vbNullString, "Europäisches Roulette - Casino Tropez")
'Eigenes Fenster nach oben setzen
Result = SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, _
SWP_NOMOVE + SWP_NOSIZE)
End Sub
Private Sub Command1_Click()
XhWnd = FindWindow(vbNullString, "Europäisches Roulette - Casino Tropez")
End Sub
Private Sub Command2_Click()
Call ShowWindow(XhWnd, SW_RESTORE)
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As _
Integer, x As Single, y As Single)
Dim R As RECT, pX&, pY&
'Neue Position berechnen
pX = x * Screen.Width / Picture1.Width
pY = y * Screen.Height / Picture1.Height
'Neue Position Setzen
Call SetWindowPos(XhWnd, 0, pX * 0.5, pY * 0.5, pX * 0.5 + _
pX * 0.25, pY * 0.5 + pY * 0.25, 0&)
'Neue Position Auslesen und anzeigen
Call GetWindowRect(XhWnd, R)
Me.Caption = "[" & R.Left & "] [" & R.Top & "]"
End Sub |