martin Posted May 17, 2007 Share Posted May 17, 2007 This script causes an invalid window handle error but I can't see why.Can anyone show me what's wrong?expandcollapse popup#include <GUIConstants.au3> Const $FLOODFILLBORDER = 0, $FLOODFILLSURFACE = 1 $gg = GUICreate("floods",100,100,10,10) $pic1 = GUICtrlCreatePic(@Systemdir & "\oobe\images\merlin.gif",0,0, 0,0) If $pic1 = 0 Then _GetLastErrorMessage("error from create pic") $hpic1 = ControlGetHandle("floods","",$pic1) If $hpic1 = '' Then _GetLastErrorMessage("erro from controlgethandle") ;$hpic1= DLLCall("user32.dll","int","GetDC","hwnd",$pic1) If GUISetState(@SW_SHOW) <> 1 Then _GetLastErrorMessage("erro from guisetstate") $r = DllCall("user32.dll","int","GetDC","hwnd",$hpic1);GUICtrlGetHandle($pic1)) If $r[0] = 0 Then _GetLastErrorMessage("error from getdc") $col = 0xff0000 If IsArray($r) Then $ff = DllCall("gdi32.dll","int","ExtFloodFill","int",$r[0],"int",5,"int", 3,"int",$col,"uint",1) If $ff[0] = 0 Then _GetLastErrorMessage("error from floodfill") EndIf While 1 $m = GUIGetMsg() If $m = $GUI_EVENT_CLOSE Then ExitLoop WEnd Func _GetLastErrorMessage($DisplayMsgBox = "") Local $ret, $s Local $p = DllStructCreate("char[4096]") Local Const $FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000 If @error Then Return "" $ret = DllCall("Kernel32.dll", "int", "GetLastError") $LastError = $ret[0] $ret = DllCall("kernel32.dll", "int", "FormatMessage", _ "int", $FORMAT_MESSAGE_FROM_SYSTEM, _ "ptr", 0, _ "int", $LastError, _ "int", 0, _ "ptr", DllStructGetPtr($p), _ "int", 4096, _ "ptr", 0) $s = DllStructGetData($p, 1) If $DisplayMsgBox <> "" Then MsgBox(0, "_GetLastErrorMessage", $DisplayMsgBox & @CRLF & String($LastError) & "-" & $s) Return $s EndFunc ;==>_GetLastErrorMessageSee ExtFloodFill definition Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Davo Posted May 18, 2007 Share Posted May 18, 2007 (edited) i think the problem lies in this line of code DllCall("gdi32.dll","int","ExtFloodFill","int",$r[0],"int",5,"int", 3,"int",$col,"uint",1) I'm not sure if this answers the question your asking??? if not let give me more info I will keep trying to help Dave Edited May 18, 2007 by Davo ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------"I don't need to know everything, I just need to know where to find it when I need it"....EinsteinAnd in our case... That's the AutoIT helpfile ;) Please read before posting!!! Link to comment Share on other sites More sharing options...
GaryFrost Posted May 18, 2007 Share Posted May 18, 2007 i think the problem lies in this line of code DllCall("gdi32.dll","int","ExtFloodFill","int",$r[0],"int",5,"int", 3,"int",$col,"uint",1)oÝ÷ Øýz-²êÞûaƧ³«²Ø^ªç¬¶*'Ê«jÉ"ezØ"½éÞwè#¥G¦Úòx-¢¥¤6¯{ú®¢×µÇ(®·¶ôjËkx"²z-jëh×6 Const $FLOODFILLBORDER = 0 Const $FLOODFILLSURFACE = 1 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
martin Posted May 18, 2007 Author Share Posted May 18, 2007 1 is correct or 0 a string is not. Const $FLOODFILLBORDER = 0 Const $FLOODFILLSURFACE = 1 Yes, see the second line of the code I posted, I just put 1 through lazyness. But does anyone else get the same problem? When the floodfill function is called it paints the client area of the main form. The image is still there and you can see it again if you refresh the window by simply grabbing the title bar and moving it off the desktop and then back. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
GaryFrost Posted May 18, 2007 Share Posted May 18, 2007 Yes, see the second line of the code I posted, I just put 1 through lazyness.But does anyone else get the same problem? When the floodfill function is called it paints the client area of the main form. The image is still there and you can see it again if you refresh the window by simply grabbing the title bar and moving it off the desktop and then back.$FLOODFILLSURFACE on my system doesn't seem to work at all$FLOODFILLBORDER gives me the same results as yoursI've checked and the hdc seems to be correct, would have to do more research on the ExtFloodFill, may be more that needs to be done to get it to work correctly. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
martin Posted May 18, 2007 Author Share Posted May 18, 2007 $FLOODFILLSURFACE on my system doesn't seem to work at all$FLOODFILLBORDER gives me the same results as yoursI've checked and the hdc seems to be correct, would have to do more research on the ExtFloodFill, may be more that needs to be done to get it to work correctly.I couldn't get this to work so I wrote a dll to do it.see this post Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Zedna Posted May 18, 2007 Share Posted May 18, 2007 Here is working script: expandcollapse popup#include <GUIConstants.au3> Const $FLOODFILLBORDER = 0, $FLOODFILLSURFACE = 1 $gg = GUICreate("floods",500,700,10,10) $pic1 = GUICtrlCreatePic(@ScriptDir & "\South_America_Map.GIF",0,0, 0,0) $hpic1 = ControlGetHandle("floods","",$pic1) GUISetState(@SW_SHOW) $r = DllCall("user32.dll","int","GetDC","hwnd",$hpic1) $hBrush = DllCall("gdi32.dll", "long", "CreateSolidBrush", "int", 0xFF00FF) ; fill color $obj_orig = DLLCall("gdi32.dll","int","SelectObject","int",$r[0],"int",$hBrush[0]) $ff = DllCall("gdi32.dll","int","ExtFloodFill","int",$r[0],"int",5,"int", 3,"int",0x00,"uint",$FLOODFILLBORDER ) ; border color If $ff[0] = 0 Then _GetLastErrorMessage("error from floodfill") While 1 $m = GUIGetMsg() If $m = $GUI_EVENT_CLOSE Then ExitLoop WEnd DLLCall("gdi32.dll","int","SelectObject","int",$r[0],"int",$obj_orig[0]) DLLCall("gdi32.dll","int","DeleteObject","int",$hBrush[0]) Func _GetLastErrorMessage($DisplayMsgBox = "") Local $ret, $s Local $p = DllStructCreate("char[4096]") Local Const $FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000 If @error Then Return "" $ret = DllCall("Kernel32.dll", "int", "GetLastError") $LastError = $ret[0] $ret = DllCall("kernel32.dll", "int", "FormatMessage", _ "int", $FORMAT_MESSAGE_FROM_SYSTEM, _ "ptr", 0, _ "int", $LastError, _ "int", 0, _ "ptr", DllStructGetPtr($p), _ "int", 4096, _ "ptr", 0) $s = DllStructGetData($p, 1) If $DisplayMsgBox <> "" Then MsgBox(0, "_GetLastErrorMessage", $DisplayMsgBox & @CRLF & String($LastError) & "-" & $s) Return $s EndFunc ;==>_GetLastErrorMessage Note: On my Win98SE isn't working ExtFloodFill with $FLOODFILLSURFACE = 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
martin Posted December 4, 2007 Author Share Posted December 4, 2007 Here is working script: expandcollapse popup#include <GUIConstants.au3> Const $FLOODFILLBORDER = 0, $FLOODFILLSURFACE = 1 $gg = GUICreate("floods",500,700,10,10) $pic1 = GUICtrlCreatePic(@ScriptDir & "\South_America_Map.GIF",0,0, 0,0) $hpic1 = ControlGetHandle("floods","",$pic1) GUISetState(@SW_SHOW) $r = DllCall("user32.dll","int","GetDC","hwnd",$hpic1) $hBrush = DllCall("gdi32.dll", "long", "CreateSolidBrush", "int", 0xFF00FF) ; fill color $obj_orig = DLLCall("gdi32.dll","int","SelectObject","int",$r[0],"int",$hBrush[0]) $ff = DllCall("gdi32.dll","int","ExtFloodFill","int",$r[0],"int",5,"int", 3,"int",0x00,"uint",$FLOODFILLBORDER ) ; border color If $ff[0] = 0 Then _GetLastErrorMessage("error from floodfill") While 1 $m = GUIGetMsg() If $m = $GUI_EVENT_CLOSE Then ExitLoop WEnd DLLCall("gdi32.dll","int","SelectObject","int",$r[0],"int",$obj_orig[0]) DLLCall("gdi32.dll","int","DeleteObject","int",$hBrush[0]) Func _GetLastErrorMessage($DisplayMsgBox = "") Local $ret, $s Local $p = DllStructCreate("char[4096]") Local Const $FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000 If @error Then Return "" $ret = DllCall("Kernel32.dll", "int", "GetLastError") $LastError = $ret[0] $ret = DllCall("kernel32.dll", "int", "FormatMessage", _ "int", $FORMAT_MESSAGE_FROM_SYSTEM, _ "ptr", 0, _ "int", $LastError, _ "int", 0, _ "ptr", DllStructGetPtr($p), _ "int", 4096, _ "ptr", 0) $s = DllStructGetData($p, 1) If $DisplayMsgBox <> "" Then MsgBox(0, "_GetLastErrorMessage", $DisplayMsgBox & @CRLF & String($LastError) & "-" & $s) Return $s EndFunc ;==>_GetLastErrorMessage Note: On my Win98SE isn't working ExtFloodFill with $FLOODFILLSURFACE = 1 A bit of a long time since the previous post but in case it helps anyone I have just discovered something about ExtFloodFill with $FLOODFILLSURFACE. It doesn't work if the surface to be filled is the default gui colour which is normally the button colour. (Using XP) This is a pain because I want to use floodfill to get rid of that colour but I can't. If you change the surface to any other colour it works. The code below demonstrates. #include <guiconstants.au3> Const $FLOODFILLSURFACE = 1 $GG = guicreate("flood demo") $but = GUICtrlCreateButton("Fill (only works if gui colour changed)",50,50,200,21) $but2 = GUICtrlCreateButton("change background colour",50,80,140,21) Opt("PixelCoordMode",2) GUISetState() While 1 $m = GUIGetMsg() If $m = -3 Then ExitLoop If $m = $but2 Then GUISetBkColor(0xaaaaaa,$gg) If $m = $but Then PaintBK($GG,10,10,0) WEnd Func PaintBK($hGui,$ix,$iy,$iCol) Local $hdc = DLLCall("user32.dll","int","GetDC","hwnd",$hGui) Local $NowCol = PixelGetColor(10,10);ensures we have the correct surface colour Local $hBrush = DllCall("gdi32.dll", "long", "CreateSolidBrush", "int", $iCol); fill color Local $obj_orig = DLLCall("gdi32.dll","int","SelectObject","int",$hdc[0],"int",$hBrush[0]) DllCall("gdi32.dll","int","ExtFloodFill","int",$hdc[0],"int",$ix,"int",$iy,"int",$NowCol,"int",$FLOODFILLSURFACE); border color DLLCall("gdi32.dll","int","SelectObject","int",$hdc[0],"int",$obj_orig[0]) DLLCall("gdi32.dll","int","DeleteObject","int",$hBrush[0]) EndFunc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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