AustrianOak Posted September 13, 2008 Author Share Posted September 13, 2008 Bump Link to comment Share on other sites More sharing options...
Andreik Posted September 13, 2008 Share Posted September 13, 2008 Try this: #include <GUIConstants.au3> #include <GDIPlus.au3> #Include <WinAPI.au3> Opt("MustDeclareVars", 1) Global $hGUI, $hImage, $hGraphic, $hImage1 $hGUI = GUICreate("Show PNG", 260, 260,-1,-1,0x80000000) _GDIPlus_StartUp() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\MyPic.png") $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT") GUISetState() ; Loop until user exits do until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() ; Draw PNG image Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0,0) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE) Return $GUI_RUNDEFMSG EndFunc When the words fail... music speaks. Link to comment Share on other sites More sharing options...
AustrianOak Posted September 13, 2008 Author Share Posted September 13, 2008 Its point to $WM_PAINT saying variable used without being declared. Im using 3.2.11.8 Link to comment Share on other sites More sharing options...
Andreik Posted September 13, 2008 Share Posted September 13, 2008 Its point to $WM_PAINT saying variable used without being declared. Im using 3.2.11.8 Add #Include <WindowsConstants.au3> When the words fail... music speaks. Link to comment Share on other sites More sharing options...
AustrianOak Posted September 13, 2008 Author Share Posted September 13, 2008 Ok. It works relatively the same as szhlopps version does but i dont know what to change in his version that will allow me to make more than one png on the screen. Link to comment Share on other sites More sharing options...
Andreik Posted September 13, 2008 Share Posted September 13, 2008 (edited) Ok. It works relatively the same as szhlopps version does but i dont know what to change in his version that will allow me to make more than one png on the screen.What exactly do you want to do? Edited September 13, 2008 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
AustrianOak Posted September 13, 2008 Author Share Posted September 13, 2008 (edited) This is what I want to do: I have multiple guis in a separate program that are all really child guis. They are dragged around on the screen and I want to be able to have a png image file layed on each of them. (Just like a bmp or gif) So if I have 6 little draggable child guis i want to create a png file on each of them just like you would load a bmp or gif file on them. The reason Im using pngs is because they are the best quality and I also want parts of the little draggable gui to look transparent. Edited September 13, 2008 by IWantIt Link to comment Share on other sites More sharing options...
AustrianOak Posted September 14, 2008 Author Share Posted September 14, 2008 Bump Link to comment Share on other sites More sharing options...
AustrianOak Posted September 16, 2008 Author Share Posted September 16, 2008 Bump. Link to comment Share on other sites More sharing options...
AustrianOak Posted September 21, 2008 Author Share Posted September 21, 2008 Bump Link to comment Share on other sites More sharing options...
Zedna Posted September 21, 2008 Share Posted September 21, 2008 BumpSuch bumping is pointless.In post #22 you were given nice solution.If you don't understand how to use it then go to www.rentacoder.com - somebody will make it for you.Or you can post here simplified version of your child-GUI script and somebody can accomodate WM_PAINT solution for it. Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
AustrianOak Posted September 21, 2008 Author Share Posted September 21, 2008 Mr. Zedna:this is what i posted in reply to post 22:Ok. It works relatively the same as szhlopps version does but i dont know what to change in his version that will allow me to make more than one png on the screen.i want to be able to have multiple pngs... instead of one and i dont know how? Link to comment Share on other sites More sharing options...
Zedna Posted September 21, 2008 Share Posted September 21, 2008 Mr. Zedna:this is what i posted in reply to post 22:i want to be able to have multiple pngs... instead of one and i dont know how?I know about that. Just read LAST sentence of my previous post! Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
AustrianOak Posted September 21, 2008 Author Share Posted September 21, 2008 I read your last sentence and don't know what you want from me when you say simplified version of my child gui. Link to comment Share on other sites More sharing options...
Zedna Posted September 21, 2008 Share Posted September 21, 2008 I read your last sentence and don't know what you want from me when you say simplified version of my child gui.If you want to get help then you must provide code you have.Nobody will write code for you from scratch.Understand now? Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
AustrianOak Posted September 21, 2008 Author Share Posted September 21, 2008 yea sorry but andreiks post is pretty much all i have. i have just one other thing and it wouldnt help because all it is is a child gui and a parent with the png picture set on it, Link to comment Share on other sites More sharing options...
AustrianOak Posted October 12, 2008 Author Share Posted October 12, 2008 Bump -dont flame me for bumping read previous post Link to comment Share on other sites More sharing options...
monoceres Posted October 13, 2008 Share Posted October 13, 2008 (edited) I don't see the problem, the solution is GDI+, and frankly, it's not that hard considering you have got examples on how to do it. Here's the steps: When you create a GUI (parent, child whatever) you get a window handle, AKA hWnd. With this handle you can create a Graphics object, this gives you the ability to draw whatever you like on the window (like for example images loaded by the appropriate GDI+ functions). Up to now everything is great in Windows Land, but there is still a villain on the loose, he is called "repainting" and there is no escape from him, he shows himself every time a window hovers over your window*, your window is dragged outside the screen or when your window is being restored from a minimized state. Every window that lives in Windows Land must deal with him and the only possible solutions are 1) Constantly redrawing the window or 2) waiting for windows to send a message to let you know that repainting must be done. This message is called WM_PAINT and to register this msg in AutoIt3 you simply include WindowsConstants.au3 and call GUIRegisterMsg() with $WM_PAINT as a parameter. In the function that is called you simply reuse the code you used to draw the stuff in the first place and that's pretty much it. So if you drawed your png image with _GDIPlus_GraphicsDrawImageRect($Graphics,$Image,10,10,100,100), you just copy & paste that line into the redrawing function. Now it's your turn to do some work, I've just done my best to explain how to use multiple png images on multiple child GUI's, go write some code that uses this method, you have Andreik's post as a backup when you don't understand something, and if you get stuck with anything else just post the code your not getting to work and I will be more than happy to help you fix it. Good luck! Edited October 13, 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 October 13, 2008 Author Share Posted October 13, 2008 Thank you so much for such an explanatory and helpful response. Will get started. Link to comment Share on other sites More sharing options...
AustrianOak Posted November 1, 2008 Author Share Posted November 1, 2008 Long time no see. Anyway I've been working and my code structure as far as GDI+ goes I think is fine but when i click the button to create a png image it doesnt appear? 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, $hImage1 $GUI = GUICreate("Dragable Controls", 300, 300) $Create_DIP_Button = GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 32, 58, 26, 26) _GDIPlus_StartUp() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\background.png") $hGraphic = _GDIPlus_GraphicsCreateFromHWND($ahInput[$ahInput[0][0]][1]) GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT") GUISetState() While 1 $nMsg = GUIGetMsg(1) Switch $nMsg[0] Case $GUI_Event_Close 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 ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() ; Draw PNG image Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam) _WinAPI_RedrawWindow($ahInput[$ahInput[0][0]][1], 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0,0) _WinAPI_RedrawWindow($ahInput[$ahInput[0][0]][1], 0, 0, $RDW_VALIDATE) Return $GUI_RUNDEFMSG EndFunc 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)) $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...
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