crislivinitup Posted April 20, 2010 Share Posted April 20, 2010 Hello programmers (of the AutoIt variety) Alright, my challenge is this: I created a GUI and have set a picture on it with $picture = GUICtrlCreatePic("PKOscreenshot2.jpg", 350, 50, 300, 225) Afterwards I want to create a graphic ONTOP of this picture--like drawing a rectangle; when I've tried this however, it was a no go (the picture is always on top). I'm sure there is a very simple solution to adjust the layer of the pic, but I have been looking and can't seem t find it. Secondly, I am having a hard time getting the functionality of a input box that I desire. I have created an input box and a listbox underneath it. I want that when the user is typing in the input box, the listbox will immediately select the closest match to the string in the input box. Kind of like how the Index search of AutoIt Help works. Any genius programmers out there willing to lend a hand? Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 20, 2010 Share Posted April 20, 2010 Hello programmers (of the AutoIt variety)Alright, my challenge is this: I created a GUI and have set a picture on it with $picture = GUICtrlCreatePic("PKOscreenshot2.jpg", 350, 50, 300, 225)Afterwards I want to create a graphic ONTOP of this picture--like drawing a rectangle; when I've tried this however, it was a no go (the picture is always on top). I'm sure there is a very simple solution to adjust the layer of the pic, but I have been looking and can't seem t find it.See help file under GUICtrlCreatePic(): Comments: ; ...If a picture is set as a background picture, as the other controls will overlap, it's important to disable the pic control and create it after the others controls: GuiCtrlSetState(-1,$GUI_DISABLE).Secondly, I am having a hard time getting the functionality of a input box that I desire. I have created an input box and a listbox underneath it. I want that when the user is typing in the input box, the listbox will immediately select the closest match to the string in the input box. Kind of like how the Index search of AutoIt Help works.Read the contents of input in a loop, continuously doing ControlCommand() on the listbox with "FindString" and "SelectString". If you populated the listbox from and array, it might be quicker to _ArraySearch() and then select the matching item in the listbox. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
crislivinitup Posted April 20, 2010 Author Share Posted April 20, 2010 Thanks for your reply, I think I will try to set the picture as a background picture so that the other controls overlap if that's the case. Also, about the input control "GUIctrlcreateinput()"... I'd like to incorporate the GUIRegisterMSG() like is written in the example _Guictrlslider_Create() that comes with autoit The function from that example is like this expandcollapse popup#include <GuiSlider.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("(UDF Created) Slider Create", 400, 296) $hSlider = _GUICtrlSlider_Create($hGUI, 2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS)) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndSlider $hWndSlider = $hSlider If Not IsHWnd($hSlider) Then $hWndSlider = GUICtrlGetHandle($hSlider) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndSlider Switch $iCode Case $NM_RELEASEDCAPTURE ; The control is releasing mouse capture ;~ MsgBox(0,"","") _DebugPrint("$NM_RELEASEDCAPTURE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; No return value EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Mind you, that is not the whole program, just the important parts. I was looking through the Windowsconstants and found a few constants that might be useful for this matter, but I don't have the slightest clue to go about using them to create a function like this. I understand the concept of using the DLLCreateStruct() and retrieving data from it, (only from studying this particular example), but I am not sure if every Windowsconstant (such as $WM_NOTIFY or other ones like $WM_INPUT, $WM_KEYDWN) require a function unique to their design. Is there a good reference available to utilize this GUIregisterMSG() function with the window constants? I understood it to be that you can create an event from any specific occurance with regards to the windowsconstants. Thanks ahead of time for help in this matter; Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 20, 2010 Share Posted April 20, 2010 Since the first question was pretty basic, I wasn't going to go into an advanced method for the second. But, since you asked, register WM_COMMAND and watch for EN_CHANGE messages from the input control as your trigger to update the selection in the listbox. If you search the forum for WM_COMMAND and EN_CHANGE, you'll find working examples. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
crislivinitup Posted April 20, 2010 Author Share Posted April 20, 2010 Great, that's what I will do for the GUIregisterMSG().... Umm... I fell aweful about asking this, but I've been looking and I can't figure out how to set a picture as a background picture. I've looked at the helpfile and in the example it only has GUICrtlcreatepic() being used. Would you please clarify for me how to do this. I'm trying to make a GUI where the user can draw on top of a Template image. The drawing is very simple so I can accomplis this with GUIctrlcreategraphic(), (no need to use te GDI functions). I know this is a really simple question, but it's got me confused enough to come back for an answer. The answer you gave me before, told me how to get the picture on top, but I'd like it behind(to be drawn on), maybe there are some settings/styles, I have overlooked??? Thanks again for brilliant answers, Chris Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 20, 2010 Share Posted April 20, 2010 (edited) There is no setting it as background. Just put it at 0/0, the same size as the GUI, and disable it. Then create the other controls on top. That makes it effectively the background: #include <GUIConstantsEx.au3> $hGUI = GUICreate("My GUI picture", 300, 300) $idPic = GUICtrlCreatePic("C:\Program Files\AutoIt3\Examples\GUI\merlin.gif", 0, 0, 300, 300) GUICtrlSetState($idPic, $GUI_DISABLE) $idInput = GUICtrlCreateInput("", 50, 200, 200, 20) $idButton = GUICtrlCreateButton("Test", 100, 250, 100, 30) GUISetState() ; Run the GUI until the dialog is closed While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idButton MsgBox(64, "Test", "Input = " & GUICtrlRead($idInput), 3) EndSwitch WEnd Edited April 20, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
crislivinitup Posted April 22, 2010 Author Share Posted April 22, 2010 Hey, I found a solution that worked for what I needed; I thought I would post it incase it might help anybody out or give somebody good ideas. My problem was that I couldn't find a way to make a graphic ontop of a picture; I still haven't found a way. With your code, however, I noticed a control can be created on top of a picture and decided I could use a control's border to make the lines I needed; so, I came up with this. An interesting solution to a problem. include <GUIConstants.au3> #include <StaticConstants.au3> Opt("mousecoordmode", 2) Opt("GUIOnEventMode", 1) $hGUI = GUICreate("My Picture", 700, 350, -1, -1) $idPic = GUICtrlCreatePic("D:\Programming\AutoIt\AutoIt Programs\pkoscreenshot2.jpg", 0, 0, 300, 300) GUICtrlSetOnEvent(-1, "resize") $button = GUICtrlCreateButton("Click to close", 50, 50) GUICtrlSetState(-1, $GUI_FOCUS) GUISetOnEvent(-1, "Quit") $frame = GUICtrlCreateLabel("", 0, 50, 50, 50, $SS_WHITEFRAME) GUICtrlCreateTabItem("") GUISetState() Func resize() Local $pos = MouseGetPos() GUICtrlSetPos($frame, 0, 0, $pos[0], $pos[1]) EndFunc ;==>resize GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") Func Quit() Exit EndFunc ;==>Quit While 1 Sleep(100) WEnd Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 22, 2010 Share Posted April 22, 2010 That mess works for you? The label isn't visible, the button doesn't work, there's a stray GUICtrlCreateTabItem("") with no tabs, and what's the "resize" event supposed to do? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
crislivinitup Posted May 2, 2010 Author Share Posted May 2, 2010 That mess works for you? The label isn't visible, the button doesn't work, there's a stray GUICtrlCreateTabItem("") with no tabs, and what's the "resize" event supposed to do?Hi blinky, hahaha. Yes the script may look very weird to you, but the whole point of it was for me to give the user the ability to draw a rectangle over a picture. This script is very choppy and it's only point was to test the ability to draw a rectangle. It is a tiny piece of the program I'm making. The stray guictrlcreatetabitem("") was because I was testing this with different tabs. I'll admit, it isn't my favourite way to solve the problem of drawing over a picture, but it was the only way I could find. The resize event is supposed to draw the label according to where the user clicks in the picture. Try clicking in the picture. I'm not sure why you say the label isn't visible to you?? you can't see a label but you can see a white rectangle correct? I've modified the script in my program so it will use the label to draw a rectangle where the user wants. Well, at least it solved my problem right? 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