Seite 1 von 1

ActiveX Control einbinden

Verfasst: 16.03.2010 13:06
von univeda
Nachdem mich Kiffi darauf hinwies, diesen Beitrag im deutschen Forum weiterzuführen, mach ich das doch.

Hallo Kiffi, du hast meinen Beitrag im englischen Forum verfolgt, ich wäre natürlich sehr an deinem erwähnten Remotedesktop-Code interessiert.

Gruss
Michael

Re: ActiveX Control einbinden

Verfasst: 16.03.2010 14:17
von Kiffi
univeda hat geschrieben:ich wäre natürlich sehr an deinem erwähnten Remotedesktop-Code interessiert.
ich habe den Code mal aus den Untiefen meiner Festplatte geborgen,
an die neue PB-Version angepasst, zu einem Paket zusammengeschnürt
und auf a14xerus' brandneue Hosting-Seite hochgeladen:

http://upload.alexander-n.de/=MTkuMTI2ODc0MTA2Ng==

Übrigens habe ich ähnliche Clipping-Probleme wie Du. Damals habe ich das
Interesse an dem Code verloren und dann auch nicht mehr versucht, das
Problem zu beheben.

Grüße ... Kiffi

Re: ActiveX Control einbinden

Verfasst: 16.03.2010 14:47
von univeda
Danke Kiffi, werde deinen Code gleich mal unter die Lupe nehmen.

Re: ActiveX Control einbinden

Verfasst: 16.03.2010 15:54
von univeda
Kiffi hat geschrieben:Übrigens habe ich ähnliche Clipping-Probleme wie Du. Damals habe ich das
Interesse an dem Code verloren und dann auch nicht mehr versucht, das
Problem zu beheben.

Grüße ... Kiffi
Das Clipping-Problem habe ich mit Hilfe von srod und meinem autoIt-Skript folgendermaßen gelöst:

Code: Alles auswählen

Procedure SetStyles()
;this prevents clipping problems

;ContainerHandle
hContainerClass = RdpObject\GetContainerhWnd()
SetWindowLongPtr_(hContainerClass, #GWL_STYLE, #WS_CHILD | #WS_CLIPCHILDREN | #WS_CLIPSIBLINGS | #WS_VISIBLE)
SetWindowLongPtr_(hContainerClass, #GWL_EXSTYLE, #WS_EX_NOINHERITLAYOUT | #WS_EX_NOPARENTNOTIFY)    

;MainHandle
hMainClass = GetParent_(hContainerClass)
SetWindowLongPtr_(hMainClass, #GWL_STYLE, #WS_CHILD | #WS_CLIPCHILDREN | #WS_CLIPSIBLINGS | #WS_VISIBLE)
SetWindowLongPtr_(hMainClass, #GWL_EXSTYLE, $0)

;ATLHandle
hATLClass = FindWindowEx_(hContainerClass, 0, 0, 0)
SetWindowLongPtr_(hATLClass, #GWL_STYLE, #WS_CHILD | #WS_CLIPCHILDREN | #WS_CLIPSIBLINGS | #WS_VISIBLE)
SetWindowLongPtr_(hATLClass, #GWL_EXSTYLE, $0)

;WindowHandle
hWnd = WindowID(#WIN_MAIN)
SetWindowLongPtr_(hWnd, #GWL_STYLE, #WS_CAPTION | #WS_TABSTOP | #WS_MINIMIZEBOX | #WS_SYSMENU | #WS_CLIPCHILDREN | #WS_CLIPSIBLINGS | #WS_VISIBLE)
SetWindowLongPtr_(hWnd, #GWL_EXSTYLE, #WS_EX_WINDOWEDGE)
EndProcedure
Was bleibt ist die simple Frage, wie ich es hinbekomme bei meinem RDP-Fenster das Maximize-Gaget zu deaktivieren. Ich möchte nicht, dass der Benutzer die Fenstergröße ändert.

Nachtrag: Es hat sich noch ein weiteres Problem aufgetan. Sobald ich einmal auf oder in ein anderes Fenster auf meinem Desktop klicke (z.B. ein Explorer-Fenster), kann ich im Container meines RDP-Fensters nichts mehr anklicken.

Re: ActiveX Control einbinden

Verfasst: 16.03.2010 20:15
von Kiffi
univeda hat geschrieben:Was bleibt ist die simple Frage, wie ich es hinbekomme bei meinem RDP-Fenster das Maximize-Gaget zu deaktivieren. Ich möchte nicht, dass der Benutzer die Fenstergröße ändert.
meinst Du ausgehend von diesem Code-Schnippsel? Da würde ich dann glatt das
#PB_Window_MaximizeGadget weglassen (oder ist die Lösung doch nicht so einfach?).
univeda hat geschrieben:Nachtrag: Es hat sich noch ein weiteres Problem aufgetan. Sobald ich einmal auf oder in ein anderes Fenster auf meinem Desktop klicke (z.B. ein Explorer-Fenster), kann ich im Container meines RDP-Fensters nichts mehr anklicken.
poste mal den gesamten Code.

Grüße ... Kiffi

Re: ActiveX Control einbinden

Verfasst: 16.03.2010 21:20
von univeda
Ich hab da mal was zusammengestellt. Die Prozedur SetStyles() habe ich etwas verkürzt, da schien einiges doppelt.

Der Punkt ist nun folgender: Wenn ich das Programm in Variante 1 starte, habe ich keine Clipping-Fehler und klicks in andere Fenster bringen mein RDP-Fenster auch nicht dazu, keine Mausklicks mehr anzunehmen. Allerdings kann man das Fenster nur noch eingeschränkt bewegen, d.h. mit der linken Maustaste angefasst kann es nur noch "unsichtbar" bewegt werden. Außerdem fehlt dann das Systemmenu (Rechtsklick auf Fenster-Titel zeigt kein Systemmenu). Schau es dir am besten mal an.

In Variante 2 habe ich auch keine Clipping-Fehler, das Fenster bewegt sich normal und das Systemmenu erscheint bei Recktsklick auf die Fenstertitelleiste auch. Allerdings reicht ein Klick auf ein anderes Fenster damit mein RDP-Fenster keine Mausklicks mehr annimmt.

Code: Alles auswählen

XIncludeFile "COMatePLUS.pbi"

Global.COMateObject RdpObject

Define Server.s = "your_server"
Define Domain.s = "your_domain"
Define UserName.s = "username"
Define Password.s = "password"
Define RdpWidth.i = 800
Define RdpHeight.i = 600
Define ColorDepth.i = 16

Enumeration
#WIN_MAIN
EndEnumeration

Declare SetStyles()

If OpenWindow(#WIN_MAIN, 10, 10, RdpWidth, RdpHeight, "Extended Terminal Services Client - " + Server)

  RdpObject = Comate_CreateActiveXControl(0, 0, RdpWidth, RdpHeight, "mstscax.mstscax") 
  
  If RdpObject
    RdpObject\SetProperty("DisconnectedText = 'Verbindung wurde getrennt.'")
    RdpObject\SetProperty("ConnectingText = 'Verbindung wird aufgebaut. Bitte warten...'")
    RdpObject\SetProperty("Server = '" + Server + "'")
    RdpObject\SetProperty("Domain = '" + Domain + "'")
    RdpObject\SetProperty("UserName = '" + UserName + "'")
    RdpObject\SetProperty("AdvancedSettings2\ClearTextPassword = '" + Password + "'")
    RdpObject\SetProperty("DesktopWidth = '" + Str(RdpWidth) + "'")
    RdpObject\SetProperty("DesktopHeight = '" + Str(RdpHeight) + "'")
    RdpObject\SetProperty("ColorDepth = '" + Str(ColorDepth) + "'")
    RdpObject\Invoke("Connect()")
    
    SetStyles()
    
    While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend 
    RdpObject\Release()
    CloseWindow(#WIN_MAIN)
  Else
    MessageRequester("ExTSC", "ActiveX Control konnte nicht erstellt werden!")
  EndIf
  
EndIf

End 0

Procedure SetStyles()
;this prevents clipping problems

;ContainerHandle
hContainer = RdpObject\GetContainerhWnd()
SetWindowLongPtr_(hContainer, #GWL_STYLE, #WS_CHILD | #WS_CLIPCHILDREN | #WS_CLIPSIBLINGS | #WS_VISIBLE)
SetWindowLongPtr_(hContainer, #GWL_EXSTYLE, #WS_EX_NOINHERITLAYOUT | #WS_EX_NOPARENTNOTIFY) 

;WindowHandle
hWnd = WindowID(#WIN_MAIN)
;Variante 1
SetWindowLongPtr_(hWnd, #GWL_STYLE, #WS_CLIPCHILDREN | #WS_VISIBLE | #WS_CAPTION | #WS_MINIMIZEBOX | #WS_SYSMENU)
;Variante 2
SetWindowLongPtr_(hWnd, #GWL_STYLE, #WS_CHILD | #WS_CAPTION | #WS_CLIPCHILDREN | #WS_CLIPSIBLINGS | #WS_GROUP | #WS_MINIMIZEBOX | #WS_SYSMENU | #WS_TABSTOP | #WS_VISIBLE)
SetWindowLongPtr_(hWnd, #GWL_EXSTYLE, $0)
EndProcedure
Danke fürs testen.

Re: ActiveX Control einbinden

Verfasst: 17.03.2010 10:57
von Kiffi
univeda hat geschrieben:Ich hab da mal was zusammengestellt.
ich habe mal ein paar Sachen getestet. Dabei ist mir aufgefallen,
dass es anscheinend eine Rolle spielt, auf welchem Rechner man
den Code laufen lässt und welchen Server man konnektieren will.

Zu Hause (XP): wenn das Fenster einmal im Hintergrund war,
lässt sich dessen Inhalt nicht mehr bedienen.

Im Büro (Vista): wenn ich nen WServer 2003 konnektiere, funktioniert
alles problemlos (und zwar ohne SetStyle!). Wenn ich ich mich hingegen
mit einem WServer 2000 verbinde: siehe XP oben.

Wie lief denn Dein AutoIt-Code? Hattest Du da ähnliche Probleme? Kannst
Du den Code hier mal reinstellen?

Grüße ... Kiffi

Re: ActiveX Control einbinden

Verfasst: 17.03.2010 12:02
von univeda
Meine Versuche habe ich immer mit einem Vista-Client und einem W2003-Server gemacht.

Hier mal der komplette AutoIt-Code, damit gabs keine Probleme bei o.g. Konfiguration:

Code: Alles auswählen

#include <WindowsConstants.au3>
#include <GUIConstants.au3>

;http://msdn.microsoft.com/en-us/library/aa383022%28VS.85%29.aspx

$remoteServer = "your_server"
$logonDomain = "logon_domain"
$remoteUser = "username"
$passWord = "password"
$width = 1024
$height = 768
$colorDepth = 16

If $CmdLine[0] > 0 Then
	$remoteServer = $CmdLine[1]
	$logonDomain = $CmdLine[2]
	$remoteUser = $CmdLine[3]
	$passWord = $CmdLine[4]
	$width = $CmdLine[5]
	$height = $CmdLine[6]
	$colorDepth = $CmdLine[7]
EndIf

$GUI = GUICreate("Extended Terminal Services Client - " & $remoteServer, $width, $height, -1, -1, -1)

$RdpClient = ObjCreate("MsTscAx.MsTscAx")

$GUIActiveX = GUICtrlCreateObj($RdpClient, -1, -1, $width, $height)
GUICtrlSetStyle($GUIActiveX, $WS_VISIBLE)
GUICtrlSetResizing($GUIActiveX, $GUI_DOCKAUTO)
GUISetIcon("extsc.ico")
GUISetState()

$RdpClient.Server = $remoteServer
$RdpClient.Domain = $logonDomain
$RdpClient.UserName = $remoteUser
$RdpClient.AdvancedSettings2.ClearTextPassword = $passWord
$RdpClient.DesktopWidth = $width
$RdpClient.DesktopHeight = $height
$RdpClient.ColorDepth = $colorDepth
;$RdpClient.Fullscreen = True
;$RdpClient.AdvancedSettings3.SmartSizing = True
$RdpClient.ConnectingText = "Verbindung wird aufgebaut. Bitte warten..."
$RdpClient.DisconnectedText = "Verbindung wurde getrennt."

$RdpConnected = 0
$RdpClient.Connect()

; Determine the class name of the ATL control - it seems to be random from system to system
Opt("WinTitleMatchMode", 4) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
$sATLClass = ""
$aClasses = StringSplit(WinGetClassList($GUI, ""), @LF)
For $i = 1 To $aClasses[0]
	If StringLeft($aClasses[$i], 4) = "ATL:" Then
		$sATLClass = $aClasses[$i]
		ExitLoop
	EndIf
Next

; get the handles to the controls that must have their styles modified
$hUIContainerClass = ControlGetHandle($GUI, "", "[CLASS:UIContainerClass]")
$hUIMainClass = ControlGetHandle($GUI, "", "[CLASS:UIMainClass]")
$hATL = ControlGetHandle($GUI, "", "[CLASS:" & $sATLClass & "]")
ConsoleWrite("$hUIContainerClass (should not be 0 or blank):" & $hUIContainerClass & @CRLF)
ConsoleWrite("$hUIMainClass (should not be 0 or blank):" & $hUIMainClass & @CRLF)
ConsoleWrite("$hATL (should not be 0 or blank):" & $hATL & @CRLF)

; modify the styles of the child controls to match those set by the offical client application
; this prevents clipping problems
Const $WS_EX_NOPARENTNOTIFY = 0x4
Const $WS_EX_NOINHERITLAYOUT = 0x100000
$hUIContainerClassStyle = BitOR($WS_CHILD, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_VISIBLE) ; 0x56000000
$hUIContainerClassStyleEx = BitOR($WS_EX_NOINHERITLAYOUT, $WS_EX_NOPARENTNOTIFY) ; 0x00100004
$hUIMainClassStyle = BitOR($WS_CHILD, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_SYSMENU, $WS_VISIBLE) ; 0x56080000
$hUIMainClassStyleEx = 0x0
$hATLStyle = BitOR($WS_CHILD, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_VISIBLE) ; 0x56000000
$hATLStyleEx = 0x0
;$guiStyle = BitOR($WS_BORDER, $WS_CAPTION, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_DLGFRAME, $WS_GROUP, $WS_MAXIMIZE, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SYSMENU, $WS_TABSTOP, $WS_THICKFRAME, $WS_VISIBLE) ; 0x17CF0100
$guiStyle = BitOR($WS_CAPTION, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_GROUP, $WS_MINIMIZEBOX, $WS_SYSMENU, $WS_TABSTOP, $WS_VISIBLE) ; 0x17CF0100
$guiStyleEx = $WS_EX_WINDOWEDGE ; 0x00000100
_SetStyle($hUIContainerClass, $hUIContainerClassStyle, $hUIContainerClassStyleEx)
_SetStyle($hUIMainClass, $hUIMainClassStyle, $hUIMainClassStyleEx)
_SetStyle($hATL, $hATLStyle, $hATLStyleEx)
_SetStyle($GUI, $guiStyle, $guiStyleEx)
$aStyle = GUIGetStyle()
GUISetStyle(BitAND($aStyle[0], BitNOT($WS_MAXIMIZEBOX)))

Func _SetStyle($hwnd, $style, $exstyle)
	DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hwnd, "int", -16, "long", $style)
	DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hwnd, "int", -20, "long", $exstyle)
EndFunc   ;==>_SetStyle

While 1
	If $RdpClient.Connected = 1 And $RdpConnected <> 1 Then
		;MsgBox(0, "Achtung", "Login Complete!")
		$RdpConnected = 1
	EndIf
	If $RdpClient.Connected <> 1 And $RdpConnected = 1 Then
		;MsgBox(0, "Achtung", "Logoff Complete!")
		$RdpConnected = 0
		ExitLoop
	EndIf
	$msg = GUIGetMsg()
	Select
		Case $msg = $GUI_EVENT_CLOSE
			ExitLoop
	EndSelect
WEnd

GUIDelete()

Exit

Re: ActiveX Control einbinden

Verfasst: 19.03.2010 15:19
von univeda
Hi Kiffi,

hattest du schon Gelegenheit dir den AutoIt-Code mal anzusehen bzw. mal einen Test damit durchzuführen?

Wie gesagt, dieser AutoIt-Code funktioniert bei mir ohne Clipping-Fehler und ohne die anderen beschriebenen Probleme.

Danke für die Hilfe.

@all: natürlich ist auch andere Hilfe jederzeit willkommen.

Gruss
Michael