AustrianOak Posted November 16, 2008 Author Share Posted November 16, 2008 bump Link to comment Share on other sites More sharing options...
monoceres Posted November 16, 2008 Share Posted November 16, 2008 Seems like $hGraphics isn't really pointing anywhere. You create it from an empty array element. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
AustrianOak Posted November 16, 2008 Author Share Posted November 16, 2008 I really dont know what you meant by that. Is that the problem though? Link to comment Share on other sites More sharing options...
monoceres Posted November 16, 2008 Share Posted November 16, 2008 I really dont know what you meant by that. Is that the problem though? Look at this line: $hGraphic = _GDIPlus_GraphicsCreateFromHWND($ahInput[$ahInput[0][0]][1]) THe thing you put in CreateFromHWND() must be the hwnd to the gui you want the image to appear on, like $GUI. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
AustrianOak Posted November 16, 2008 Author Share Posted November 16, 2008 Ok, but inside CreateFromHWND() i put $ahInput[$ahInput[0][0]][1] which is the handle to the gui i want the image to appear on if im not mistaken. Link to comment Share on other sites More sharing options...
monoceres Posted November 16, 2008 Share Posted November 16, 2008 Ok, but inside CreateFromHWND() i put $ahInput[$ahInput[0][0]][1] which is the handle to the gui i want the image to appear on if im not mistaken. Maybe but it needs to be a valid hwnd when you call it, not later. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
AustrianOak Posted November 16, 2008 Author Share Posted November 16, 2008 thats not possible because the handle doesnt become valid until the function is called. so maybe my whole code is shit. Link to comment Share on other sites More sharing options...
monoceres Posted November 16, 2008 Share Posted November 16, 2008 thats not possible because the handle doesnt become valid until the function is called. so maybe my whole code is shit.No. You just have to create the graphics after you create the child window and save the graphics in the array. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
AustrianOak Posted November 16, 2008 Author Share Posted November 16, 2008 So move the $hGraphic line to after I create the little gui image in the CreateDragIp() function? Link to comment Share on other sites More sharing options...
monoceres Posted November 16, 2008 Share Posted November 16, 2008 So move the $hGraphic line to after I create the little gui image in the CreateDragIp() function?Yeah, but it need to be saved somewhwre so it's not overwritten next time you create a child. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
AustrianOak Posted November 16, 2008 Author Share Posted November 16, 2008 (edited) my script crashes on startup when i move that line Edited November 16, 2008 by AustrianOak Link to comment Share on other sites More sharing options...
AustrianOak Posted November 16, 2008 Author Share Posted November 16, 2008 i found this code in a search i did. expandcollapse popup#include <GDIPlus.au3> #include <GuiConstantsEx.au3> Opt("MustDeclareVars", 1) ; ==================================================================================================== ; Description ...: Shows how to display a PNG image ; Author ........: Paul Campbell (PaulIA) ; Notes .........: ; ==================================================================================================== ; Global variables ; ==================================================================================================== Global $hGUI, $hImage, $hGraphic ; Create GUI $hGUI = GUICreate("Show PNG", 240, 240) GUISetState() ; Load PNG image _GDIPlus_StartUp() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\background.png") ; Draw PNG image $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0) ; Loop until user exits do until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() to test it you'll need a png image in the script dir. how do i change the size the png will be in the gui? Link to comment Share on other sites More sharing options...
monoceres Posted November 16, 2008 Share Posted November 16, 2008 Use _GDIPlus_GraphicsDrawImageRect() instead. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
AustrianOak Posted November 16, 2008 Author Share Posted November 16, 2008 Here's my current code. I understand it better because I took some code from PaulIA's example and am trying to get that concept working in mine but the png is not showing up. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #Include <WinAPI.au3> #Include <WindowsConstants.au3> Global $ahInput[2][5];Changed 4 to 5 Global $GUI, $hImage, $hGraphic $GUI = GUICreate("PNG Images", 300, 300) $Create_DIP_Button = GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 32, 58, 26, 26) GUISetState() ; Load PNG image _GDIPlus_StartUp() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\background.png") While 1 $nMsg = GUIGetMsg(1) Switch $nMsg[0] Case $GUI_Event_Close ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() Exit Case $Create_DIP_Button CreateDragIP() Case $ahInput[1][1] To $ahInput[$ahInput[0][0]][1];$GUI_EVENT_PRIMARYDOWN If $nMsg[0] = 0 Then ContinueLoop Local $aMouse_Pos = MouseGetPos() Local $aCursorInfo = GUIGetCursorInfo($nMsg[1]), $aCurrent_Mouse_Pos, $aInputGUI_Pos $aInputGUI_Pos = WinGetPos($nMsg[1]) If Not IsArray($aInputGUI_Pos) Then ContinueLoop While IsArray($aCursorInfo) And $aCursorInfo[2] = 1 $aCursorInfo = GUIGetCursorInfo($nMsg[1]) $aCurrent_Mouse_Pos = MouseGetPos() WinMove($nMsg[1], "", _ $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _ $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1]) Sleep(10) WEnd EndSwitch ;Changed the all loop (to work more effective with more than one message) For $i = 1 To $ahInput[0][0] Switch $nMsg[0] Case $ahInput[$i][3];This is the "Delete" item message DeleteDragIP($nMsg[0]) ExitLoop Case $ahInput[$i][4];This is the "Delete All" item message DeleteAllDragIP() ExitLoop EndSwitch Next WEnd Func CreateDragIP() Local $aMainGUI_Pos = WinGetPos($GUI) $ahInput[0][0] += 1 ReDim $ahInput[$ahInput[0][0]+1][5];4 changed to 5 $ahInput[$ahInput[0][0]][0] = GUICreate("", 26, 26, $aMainGUI_Pos[0] + 65, $aMainGUI_Pos[1] + 60 + 25, _ $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED)) ; Draw PNG image $hGraphic = _GDIPlus_GraphicsCreateFromHWND($ahInput[$ahInput[0][0]][0]) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 0, 0, 26, 26) $ahInput[$ahInput[0][0]][1] = GUICtrlCreatePic($hImage, 0, 0, 26, 26, -1) $ahInput[$ahInput[0][0]][2] = GUICtrlCreateContextMenu($ahInput[$ahInput[0][0]][1]) $ahInput[$ahInput[0][0]][3] = GUICtrlCreateMenuItem("&Delete", $ahInput[$ahInput[0][0]][2]) $ahInput[$ahInput[0][0]][4] = GUICtrlCreateMenuItem("&Delete All", $ahInput[$ahInput[0][0]][2]);Added GUISetState(@SW_SHOW, $ahInput[$ahInput[0][0]][0]) WinSetOnTop($ahInput[$ahInput[0][0]][0], "", 1) EndFunc Func DeleteDragIP($iCtrlID) Local $aTmpArr[2][5];Changed 4 to 5 For $i = 1 To $ahInput[0][0] If $ahInput[$i][3] = $iCtrlID Then GUIDelete($ahInput[$i][0]) Else $aTmpArr[0][0] += 1 ReDim $aTmpArr[$aTmpArr[0][0]+1][5];Changed 4 to 5 $aTmpArr[$aTmpArr[0][0]][0] = $ahInput[$i][0] $aTmpArr[$aTmpArr[0][0]][1] = $ahInput[$i][1] $aTmpArr[$aTmpArr[0][0]][2] = $ahInput[$i][2] $aTmpArr[$aTmpArr[0][0]][3] = $ahInput[$i][3] $aTmpArr[$aTmpArr[0][0]][4] = $ahInput[$i][4];This line was added EndIf Next $ahInput = $aTmpArr EndFunc ;Added new function Func DeleteAllDragIP() For $i = 1 To $ahInput[0][0] GUIDelete($ahInput[$i][0]) Next $ahInput = 0 Dim $ahInput[2][5] EndFunc Link to comment Share on other sites More sharing options...
AustrianOak Posted November 23, 2008 Author Share Posted November 23, 2008 bump Link to comment Share on other sites More sharing options...
Zedna Posted November 23, 2008 Share Posted November 23, 2008 bumpSearch forum for PNG.There are some examples already. Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
AustrianOak Posted November 23, 2008 Author Share Posted November 23, 2008 dude ive done vast amounts of searching and obviously have come up with nothing otherwise i wouldnt be bumping my never ending topic. if you've stumbled onto something that could help me, it be great if you would share it. Link to comment Share on other sites More sharing options...
monoceres Posted November 23, 2008 Share Posted November 23, 2008 (edited) I built a system of child windows that uses png background for you, it takes care of garbage collecting and everything, all you have to care about is the _CreateChild() function expandcollapse popup#include <GDIPlus.au3> #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <array.au3> #include <misc.au3> Global $GUI_OBJECT[1][5]; 0=hwnd, 1=width, 2=height, 3=graphics obj, 4 = img obj Opt("GUIOnEventMode",1) $hwnd=GUICreate("Parent",400,300) GUISetOnEvent($GUI_EVENT_CLOSE,"close") GUISetState() _GDIPlus_Startup() $GUI_OBJECT[0][0]=$hwnd $GUI_OBJECT[0][1]=400 $GUI_OBJECT[0][2]=300 $GUI_OBJECT[0][3]=_GDIPlus_GraphicsCreateFromHWND($hwnd) $GUI_OBJECT[0][4]=_GDIPlus_ImageLoadFromFile("background.png") _RePaint($GUI_OBJECT[0][0],0,0,0) GUIRegisterMsg($WM_PAINT,"_RePaint") Do Sleep(20) If _IsPressed("01") And WinActive($hwnd) Then _CreateChild($hwnd,Random(0,@DesktopWidth,1),Random(0,@DesktopHeight,1),300,200,"background.png") Do Sleep(10) Until Not _IsPressed("01") EndIf Until False Func _CreateChild($parent,$x,$y,$w,$h,$imagename) ReDim $GUI_OBJECT[Ubound($GUI_OBJECT)+1][5] $GUI_OBJECT[Ubound($GUI_OBJECT)-1][0]=GUICreate("Child number: "&Ubound($GUI_OBJECT),$w,$h,$x,$y,-1,-1,$parent) GUISetState(@SW_SHOW,$GUI_OBJECT[Ubound($GUI_OBJECT)-1][0]) $GUI_OBJECT[Ubound($GUI_OBJECT)-1][1]=$w $GUI_OBJECT[Ubound($GUI_OBJECT)-1][2]=$h $GUI_OBJECT[Ubound($GUI_OBJECT)-1][3]=_GDIPlus_GraphicsCreateFromHWND($GUI_OBJECT[Ubound($GUI_OBJECT)-1][0]) $GUI_OBJECT[Ubound($GUI_OBJECT)-1][4]=_GDIPlus_ImageLoadFromFile($imagename) GUISetOnEvent($GUI_EVENT_CLOSE,"close",$GUI_OBJECT[Ubound($GUI_OBJECT)-1][0]) _RePaint($GUI_OBJECT[Ubound($GUI_OBJECT)-1][0],0,0,0) EndFunc Func _RePaint($hwndparam,$msg,$wparam,$lparam) For $i=0 To UBound($GUI_OBJECT)-1 If $hwndparam=$GUI_OBJECT[$i][0] Then _GDIPlus_GraphicsDrawImageRect($GUI_OBJECT[$i][3],$GUI_OBJECT[$i][4],0,0,$GUI_OBJECT[$i][1],$GUI_OBJECT[$i][2]) ExitLoop EndIf Next Return $GUI_RUNDEFMSG EndFunc Func close() If @GUI_WinHandle<>$hwnd THen For $i=0 To UBound($GUI_OBJECT)-1 If @GUI_WinHandle=$GUI_OBJECT[$i][0] Then _GDIPlus_GraphicsDispose($GUI_OBJECT[$i][3]) _GDIPlus_ImageDispose($GUI_OBJECT[$i][4]) GUIDelete($GUI_OBJECT[$i][0]) _ArrayDelete($GUI_OBJECT,$i) Return EndIf Next EndIf For $i=0 To UBound($GUI_OBJECT)-1 _GDIPlus_GraphicsDispose($GUI_OBJECT[$i][3]) _GDIPlus_ImageDispose($GUI_OBJECT[$i][4]) Next _GDIPlus_Shutdown() Exit EndFunc Edited November 23, 2008 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
AustrianOak Posted November 23, 2008 Author Share Posted November 23, 2008 thank you so much. this looks promising. Link to comment Share on other sites More sharing options...
AustrianOak Posted December 6, 2008 Author Share Posted December 6, 2008 I want the child guis created from the main one to be independent and i dont want them to have a window border around them. i changed this line: $GUI_OBJECT[Ubound($GUI_OBJECT)-1][0]=GUICreate("Child number: "&Ubound($GUI_OBJECT),$w,$h,$x,$y,-1,-1,$parent) to: $GUI_OBJECT[Ubound($GUI_OBJECT)-1][0]=GUICreate("Child number: "&Ubound($GUI_OBJECT),$w,$h,$x,$y,$WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED),$parent) but when i changed it no windows show up anymore? 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