Jump to content
Sign in to follow this  
Radu Capan

controls depths

Recommended Posts

Please, I just use it for 2 days: I hade a GUI window, with a button and an edit control. I want to put a picture as background of that main window. But if I put the picture with GUICtrlCreatePic I encounter problems.

If I use GUICtrlCreatePic before I create the button and the edit box, than those are not visible, or not clickable. If I use GUICtrlCreatePic after I create the button and the edit box, are stil invisible, but became visible after a first click (in the place where I supose is the button!).

I really hope in an answer :( Is maybe a z-depth parameter to "fix" the picture below the other controls?

#include <GUIConstants.au3>

GUICreate("Random thougts!", 640, 480, -1, -1)
GUISetBkColor(0xcc0000)

$butcitat= GUICtrlCreateButton("Aleator", 310, 10, 40, 40,$BS_ICON,$WS_EX_TOPMOST)
GUICtrlSetImage ($butcitat, "shell32.dll",20)
GUICtrlSetTip ( $butcitat, "Click for a random thought")

$labcitat = GUICtrlCreateEdit("",0, 300, 640, 100, $ES_AUTOVSCROLL+$WS_VSCROLL+$ES_READONLY)
GUICtrlSetData($labcitat,"ss")
GUICtrlSetBkColor($labcitat,0xffffff)
GUICtrlSetFont($labcitat,11,400,"","Arial")


GUICtrlCreatePic(@Systemdir & "\oobe\images\mslogo.jpg",0,0, 640,480)

GuiSetState ()


; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
        Select
            Case $msg = $butcitat
                $ran = Random(1,2, 1)
                Select
                    Case $ran = 1
                        $results = "Second text"
                    Case $ran = 2
                        $results = "First text"
                EndSelect
            GUICtrlSetData($labcitat, $results)
        EndSelect
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Thanks in advance, rkn

Edited by Radu Capan

Share this post


Link to post
Share on other sites

sylvanie, thanks... but unfortunately, non of the codes from there did not work... at me / for me at lest...

so, to be short: has anyone overlap a control (edit for example) over a picture? the behaviour is strange in this case... what should be done? who knows?

thanks,

rkn

Share this post


Link to post
Share on other sites

Usually control that's overlap lead to strange behavior.

But if you want to have in background a picture just put it in a disabled state GUICtrlSetState(-1,$GUI_DISABLE)

That help a lot

Share this post


Link to post
Share on other sites

Hello,

Try this script, I hope that it's what you are looking for.

#include <GuiConstants.au3>
$gui=GuiCreate("GUI", 392, 320,(@DesktopWidth-392)/2, (@DesktopHeight-320)/2  )
$bouton=GUICtrlCreateButton("test",150,150)
$inp=GUICtrlCreateInput("Hello world",180,10,100)
$edit=GUICtrlCreateEdit("",10,20,100,200)
$pic= GUICtrlCreatePic ("marbre.jpg", 0, 0, 392, 320)
GUICtrlSetState(-1,$GUI_DISABLE)
GuiSetState(@SW_SHOW ,$gui)
_refresh()
$toberefresh=0
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg=$bouton
        MsgBox(0,"test",GUICtrlRead($inp))
        GUICtrlSetData($edit,GUICtrlRead($edit)&@CRLF&guictrlread($inp))
        _refresh()
    Case $msg=$GUI_EVENT_RESTORE
        _refresh()
    Case Else
    EndSelect
    If WinActive("GUI","")=0 Then; if we change of window
        $toberefresh=1
    Else
        If $toberefresh=1 Then
            _refresh()
            $toberefresh=0
        EndIf
    EndIf
    
WEnd
Exit

Func _refresh()
    GuiCtrlSetState($bouton,$GUI_FOCUS)
    GuiCtrlSetState($inp,$GUI_FOCUS)
    GuiCtrlSetState($edit,$GUI_FOCUS)
EndFunc

I use the function _refresh when the main window has to be redrawn

background.zip


Share this post


Link to post
Share on other sites

Sylvanie, nice work. The "refresh" idea work 90%. I don't think that only on my computer (XP Home Edition) your code it make the controls visible and workable over the picture: yeeee! Still.... Not 100%, since the edit control do not show the scrollbars only if you move your mouse over. Also for the input control, to both, the borders are not shown till you move the mouse over. So, it solve the problem, but still unestetically.

In your code, Sylvanie,

GUICtrlSetState(-1,$GUI_DISABLE)

make no difference! With or without it, is the same.

So, jpm, was no "help a lot" :(

Or am I too "young" with this great program?

Anyway, the only workaround I found, is to slice the picture and put it on the window around the controls. In that way, it simulate as the picture is all over the window, but there is no overlap... Anyway, it's not an easy solution, since I have to re-slice the picture everytime I add a new control, or change the position of an already-there-control...

Maybe in future version there will not be needed to make a background as a control, but to set a background as a property of the window itself. It would be nice.

Thanks to both of you. Any future ideas will be welcome. If not, I will remain to "slice solution".

rkn

PS: Again - great program. Where can I found more codes? more snippets? more programs, examples from which to learn? I don't want to waste people time, so with some tens of examples (except from the program itself), I will be able to progress... Please make me know...

Edited by Radu Capan

Share this post


Link to post
Share on other sites

hello

Not 100%, since the edit control do not show the scrollbars only if you move your mouse over.

Humm, you're right, I haven't seen it.

now, replace _refresh by this one :

Func _refresh()
    GuiCtrlSetState($pic,$GUI_FOCUS)
    GuiCtrlSetState($bouton,$GUI_FOCUS)
    GuiCtrlSetState($inp,$GUI_FOCUS)
    GuiCtrlSetState($edit,$GUI_FOCUS)
    GUICtrlSetData($edit,GUICtrlRead($edit))
EndFunc

It' s running in my case, I hope it'll work with you :(


Share this post


Link to post
Share on other sites

Sylvanie, super-thanks. As we spoke on PM, is not working 100%. The only workaround is still to slice the background picture around the controls, so there to be no overlap.

Anyway, I want to repeat a question from above... but I will make a new thread.

Thanks. If anyone will find a better solution than Sylvanie, I will be VERY GLAD!

rkn

Share this post


Link to post
Share on other sites

Hello Radu,

I have noticed that :

1) Create the picture before all controles

2) Disable it like JPM has said

it could be strange, but in this order, I have no more the problem with the Hscroll and Vscroll of edit:

#include <GuiConstants.au3>
$gui=GuiCreate("GUI", 392, 320,(@DesktopWidth-392)/2, (@DesktopHeight-320)/2  )
$pic= GUICtrlCreatePic ("marbre.jpg", 0, 0, 392, 320)
GuiCtrlSetState(-1,$GUI_DISABLE)
$bouton=GUICtrlCreateButton("test",150,150)
$inp=GUICtrlCreateInput("Hello world",180,10,100)
$edit=GUICtrlCreateEdit("",10,20,100,200)
GuiSetState(@SW_SHOW ,$gui)
_refresh()
$toberefresh=0
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg=$bouton
        MsgBox(0,"test",GUICtrlRead($inp))
        GUICtrlSetData($edit,GUICtrlRead($edit)&@CRLF&guictrlread($inp))
        _refresh()
    Case $msg=$GUI_EVENT_RESTORE
        _refresh()
    Case Else
    EndSelect
    If WinActive("GUI","")=0 Then; if we change of window
        $toberefresh=1
    Else
        If $toberefresh=1 Then
            _refresh()
            $toberefresh=0
        EndIf
    EndIf
    
WEnd
Exit

Func _refresh()
    GuiCtrlSetState($bouton,$GUI_FOCUS)
    GuiCtrlSetState($inp,$GUI_FOCUS)
    GuiCtrlSetState($edit,$GUI_FOCUS)
    GUICtrlSetData($edit,GUICtrlRead($edit))
EndFunc

Share this post


Link to post
Share on other sites

WOW! Sylvanie, I should prepare myself to build a statue for you :(

What a great help! Thanks.

THANKS! THANKS! THANKS! Wow, how happy I am! Now I can do it easier! Yeeee!

rkn

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...