AznSai Posted September 18, 2005 Share Posted September 18, 2005 (edited) Simple function to recieve the handle of the parent window of a child window (That was a bit confusing) Func GetParentHandle($ChildHwnd) Local $ParentLong = DllCall("user32.dll","long","GetWindowLong","hwnd",$ChildHwnd,"int",-8) If $ParentLong[0] = 0 Then SetError(1) Local $ParentHwnd = String($ParentLong[0]) Return HWnd($ParentHwnd) EndFunc And an example: Dim $ChildhWnd = WinGetHandle("Child Window Text") Dim $ParenthWnd = GetParentHandle($ChildhWnd) If @error <> 0 Then Exit WinSetState($ParenthWnd,"",@SW_MINIMIZE) Sorry if this has been done before Edited September 18, 2005 by AznSai Link to comment Share on other sites More sharing options...
w0uter Posted September 18, 2005 Share Posted September 18, 2005 Func GetParentHandle($ChildHwnd) Local $ParentLong = DllCall("user32.dll","long","GetWindowLong","hwnd",$ChildHwnd,"int",-8) If @ERROR <> 0 OR $ParentLong[0] = 0 Then SetError(1) Return 0 EndIf Return HWnd($ParentLong[0]) EndFunc works a bit better IMO. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
AznSai Posted September 18, 2005 Author Share Posted September 18, 2005 Func GetParentHandle($ChildHwnd) Local $ParentLong = DllCall("user32.dll","long","GetWindowLong","hwnd",$ChildHwnd,"int",-8) If @ERROR <> 0 OR $ParentLong[0] = 0 Then SetError(1) Return 0 EndIf Return HWnd($ParentLong[0]) EndFuncworks a bit better IMO.Thanks for that, it's the only way I'll learn :"> Link to comment Share on other sites More sharing options...
jefhal Posted September 18, 2005 Share Posted September 18, 2005 (edited) Return HWnd($ParentLong[0]) Oddly, I got an error that HWnd was not found, until I re-re-installed Scite and the re-installed the Scite update to beta 75. Edited September 18, 2005 by jefhal ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
AznSai Posted September 18, 2005 Author Share Posted September 18, 2005 my attemptFunc _WinGetParent( $WGP_hwnd ) $ret = DLLCall( "User32.dll", "hwnd", "GetParent", "hwnd", $WGP_hwnd) Return $ret[0] EndFuncYour's might be able to do what mine does in less code, but my code looks better Lol im just a sore loser... Link to comment Share on other sites More sharing options...
WSCPorts Posted September 19, 2005 Share Posted September 19, 2005 (edited) Func _WinSetParent($OldHwnd, $NewHwnd) $ret = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $OldHwnd, "hwnd", $NewHwnd) If @error <> 0 then SetError(1) Return 0 ElseIf isHwnd($ret[0]) Then Return $ret[0] Else SetError(1) Return 0 EndIf EndFunc Func _WinGetParent( $WGP_hwnd ) $ret = DLLCall( "User32.dll", "hwnd", "GetParent", "hwnd", $WGP_hwnd) If @error <> 0 then SetError(1) Return 0 ElseIf isHwnd($ret[0]) Then Return $ret[0] Else SetError(1) Return 0 EndIf EndFunc i like both of em @ w0oter :is that better? Edited September 19, 2005 by WSCPorts http://www.myclanhosting.com/defiasVisit Join and contribute to a soon to be leader in Custumized tools development in [C# .Net 1.1 ~ 2.0/C/C++/MFC/AutoIt3/Masm32] Link to comment Share on other sites More sharing options...
w0uter Posted September 19, 2005 Share Posted September 19, 2005 you should first check for @error and then try to access $ret. becouse if there is an error $ret isnt an array and your script will crash. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now