| |

VB & Windows APISetWindowPlacement | |  | Autor: emersonlakeandpalmer | Datum: 25.10.11 11:30 |
| Hallo,
ich benötige eine Routine, welche in einer gemischten XP 32bit und Win7 64bit Umgebung (mit der alten Tastleiste) in der Lage, ist ein Fenster falls nur verdeckt, in den Vordergrund zu bringen (funktionert!) oder wenn es minimiert in der Taskleiste (Tray währe der nächste Schritt) dieses zu maximieren und dann in den Vordergrund zu bringen.
WndPlcmt.showCmd liefert jedoch je nach Lust und Laune 1 oder 3 und selbst wenn man
die Abfrage umgeht WndPlcmt.showCmd=SW_SHOWMAXIMIZED setzt, passiert absolut nichts.
Weiß jemand Rat?
Gruß elp
Modulcode:
Public Const SW_HIDE = 0 'Hide the window
Public Const SW_MAXIMIZE = 3 'Maximize the window
Public Const SW_MINIMIZE = 6 'Minimize the window
Public Const SW_RESTORE = 9 'Restore the window (not maximized nor minimized)
Public Const SW_SHOW = 5 'Show the window
Public Const SW_SHOWMAXIMIZED = 3 'Show the window maximized
Public Const SW_SHOWMINIMIZED = 2 'Show the window minimized
Public Const SW_SHOWMINNOACTIVE = 7 'Show the window minimized but do not activate it
Public Const SW_SHOWNA = 8 'Show the window in its current state but do not activate it
Public Const SW_SHOWNOACTIVATE = 4 'Show the window in its most recent size and position but do not activate it
Public Const SW_SHOWNORMAL = 1 'Show the window and activate it (as usual)
Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Declare Function SetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Long
Public Type POINTAPI
x As Long
y As Long
End Type
Public Type WINDOWPLACEMENT
Length As Long
flags As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Function ActivateWindow(xhWnd&) As Boolean
Dim Result&, WndPlcmt As WINDOWPLACEMENT
With WndPlcmt
.Length = Len(WndPlcmt)
Result = GetWindowPlacement(xhWnd&, WndPlcmt)
If Result Then
If .showCmd = SW_SHOWMINIMIZED Then '<=
.flags = 0
.showCmd = SW_SHOWMAXIMIZED
Result = SetWindowPlacement(xhWnd&, WndPlcmt) '<=
Else
Call SetForegroundWindow(xhWnd)
Result = BringWindowToTop(xhWnd&)
End If
If Result Then ActivateWindow = True
End If
End With
End Function |  |
Re: SetWindowPlacement | |  | Autor: emersonlakeandpalmer | Datum: 09.11.11 09:59 |
| Hallo Martoeng,
bei mir weder unter XP 32bit noch unter Win7 64bit.
Letzteres hätte mich auch erstmal nicht verwundert, hat doch Microsoft mit seiner tollen 'Superbar'
vieles durcheinander gebracht (was zumindest die Steuerungsmöglichkeiten über die Gruppenrichtlinien eines AD Servers angeht).
Aber wie gesagt, auch unter XP 32bit funktioniert das nicht.
Bei der Abfrage des aktuellen Zusatndes von .showcmd wird bei mir 3 ausgegeben, also SW_SHOWMAXIMIZED
obwohl das aufzurufende Tool minimiert in der Taskleiste liegt.
Selbst wenn manuell den Ablauf durch die True-Teil laufen lasse passiert bei
Result = SetWindowPlacement(xhWnd&, WndPlcmt)
Result wird mit 1 ausgeben und das wars.
Kann es sein das meine Routine, welche mit der ich den Handle des Fensters bestimme mit nicht sicher
denn Handle des Fensters sondern ggfls. den Handle eines Objekt im diesem Fenster liefert?:
Function FindApp(AppTitle As String)
Dim hWnd&, Result&, Title$
hWnd& = GetWindow(Form1.hWnd, GW_HWNDFIRST)
Do 'Alle vorhandenen Fenster durchlaufen
Result = GetWindowTextLength(hWnd&) + 1
Title = Space$(Result&)
Result = GetWindowText(hWnd&, Title$, Result&)
Title = Left$(Title$, Len(Title$) - 1)
hWnd& = GetWindow(hWnd&, GW_HWNDNEXT)
Loop Until hWnd& = 0 Or (AppTitle <> "" And LCase(Title$) Like "*" + LCase(AppTitle) + "*")
FindApp = hWnd&
End Function
Gruß
elp |  |
Re: SetWindowPlacement | |  | Autor: emersonlakeandpalmer | Datum: 18.12.11 17:51 |
| Das sind alles Fenster außerhalb meiner Anwendung.
Im wesentlichen:
Office
Notepad
spez. in VB6 geschriebene Anwsendungen
CAD Programme wie Catia, ProE etc.
Gruß
ELP |  |
Re: SetWindowPlacement | |  | Autor: alicerobert | Datum: 05.03.13 08:40 |
| Vielen Dank ... Ich mag dieses Forum sehr viel, weil es sehr informativ ist ...
alice --- |  |
 | Sie sind nicht angemeldet! Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.
Einloggen | Neu registrieren |
  |
|
Neu! sevEingabe 3.0 
Einfach stark!
Ein einziges Eingabe-Control für alle benötigten Eingabetypen und -formate, inkl. Kalender-, Taschenrechner und Floskelfunktion, mehrspaltige ComboBox mit DB-Anbindung, ImageComboBox u.v.m. Weitere InfosTipp des Monats März 2023 Dieter OtterPopUp-Menü wird nicht angezeigt :-(In diesem Tipp verraten wir Ihnen, wie Sie Probleme mit PopUp-Menüs umgehen können, wenn diese unter bestimmten Umständen einfach nicht angezeigt werden. TOP Entwickler-Paket 
TOP-Preis!!
Mit der Developer CD erhalten Sie insgesamt 24 Entwickler- komponenten und Windows-DLLs. Die Einzelkomponenten haben einen Gesamtwert von 1605.50 EUR...
Jetzt nur 599,00 EURWeitere Infos
|