jeg er lidt nybegynder inde for faget VB. Jeg skal åbne et windowsprogram og sætte dets position i venstre hjørne. hvad gør jeg? Jeg ved at jeg åbner programmet ved at bruge shell;
Private Sub Command1_Click() Shell ("X:\Spil\Bodog Poker\GameClient.exe") End Sub
hvad gør jeg så der efter for at placere vinduet? skal jeg erklære programmet som noget først? kender funktionen SetWindowPos, men ved ikke hvordan jeg bruger det i sammenhæng.
Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Const GW_HWNDNEXT = 2
Private Function InstanceToWnd(ByVal target_pid As Long) As Long Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long test_hwnd = FindWindow(ByVal 0&, ByVal 0&) Do While test_hwnd <> 0 If GetParent(test_hwnd) = 0 Then test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid) If test_pid = target_pid Then InstanceToWnd = test_hwnd Exit Do End If End If test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT) Loop End Function
Private Sub Command1_Click() Dim r As RECT Dim nLeft As Long Dim nWidth As Long Dim nHeight As Long Dim nhWnd As Long Dim strShell As String
strShell = "X:\Spil\Bodog Poker\GameClient.exe"
nhWnd = InstanceToWnd(Shell(strShell)) If nhWnd <> 0 Then Call GetWindowRect(nhWnd, r)
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.