Jump to content

GUI Changes Needed


Jon
 Share

Recommended Posts

  • Administrators

OK, I'm going to attempt the jump to light speed...no wait enough star wars...the multiple GUI thing now.

The plan is to keep the current syntax as is but to add a GuiSwitch() function that tells all the subsequent functions which window to work with. So if you do GuiSwitch(2) then create controls they will be created on Gui #2. This will avoid adding a "gui number" parameter to every single other function - not pretty.

For that to work, and to be able to react correctly to messages returned from GuiMsg() I'll have to ensure that every control created has a unique ID - even across all the various GUIs - so the message loop can stay the same.

I think the only functions I'll have to alter are GuiCreate and GuiDelete, well appart from the gigantic internal changes of course.

Sound reasonable?

Link to comment
Share on other sites

  • Replies 133
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

For that to work, and to be able to react correctly to messages returned from GuiMsg() I'll have to ensure that every control created has a unique ID - even across all the various GUIs - so the message loop can stay the same.

Um, this won't break the Aug 5 change allowing ControlCommand(...., "Control ID", ....) will it?

EDIT: We might be okay if

ControlID = (GUI_INSTANCE - 1 ) * MAX_NUM_CTRLS_PER_GUI + 1

1st GUI goes from 1 to whatever

2nd GUI 513 to whatever

3rd GUI goes from 1025 to whatever

etc...

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

  • Administrators

Um, this won't break the Aug 5 change allowing ControlCommand(...., "Control ID", ....) will it?

Don't see why.

Having browsed the source for a while the mult gui thing is looking very tricky... :ph34r: things I hadn;t considered are the tray icon gui stuff, and returning things like -3 for gui closed (which gui closed?). I think I'll start by creating a test version that has all the functions removed except GuiCreate/Delete/GetMsg and try and get it to compile in a multi mode. Arrgh.

Link to comment
Share on other sites

  • Administrators

1st GUI goes from 1 to whatever

2nd GUI 513 to whatever

3rd GUI goes from 1025 to whatever

That's the formula I was going to use :ph34r:

Edited by Jon
Link to comment
Share on other sites

I initially thought that this was a bad idea as if you had a simple gui with 10 buttons  and you wanted any of them to close the gui it would involve more code in the messageloop part.  But then I realized that even if the notify/close mode made it easier to do the message loop you would _still_ have to do a Guiread() afterwards to work out which button was pressed and then you would have to have a big if/select statement anyway. 

So yeah, unless anyone can think of a reason to keep the notify mode then I'll remove it.

<{POST_SNAPBACK}>

The notify was coming from AU3GUI from Larry.

I think every thing will be much easier if we implement the GUICtrlSetCallback :ph34r:

Link to comment
Share on other sites

I created this test script without looking once in the helpfile.

It's that easy.

Opt("GUINotifyMode", 1)

GUICreate("Test", 250, 200, -1, -1)

$edit_1 = GUICtrlCreateEdit("", 25, 25, 200, 130)

$OK_btn = GUICtrlCreateButton("OK", 50, 170, 70, 20)
$cancel_btn = GUICtrlCreateButton("Cancel", 130, 170, 70, 20)

GUISetState(@SW_SHOW)

$msg = 0

While 1
   Sleep(100)
   $msg = GUIPeekMsg()
   If $msg = $cancel_btn OR $msg = -3 Then
      GUIDelete()
      Exit
   EndIf

WEnd
Link to comment
Share on other sites

Maybe a small bug:

GUICtrlSetBk function don't update the color in a control. :ph34r:

Really, the color it's changed, but don't display correctly.

Here a example:

I update the label's color by "Red".

When I put any window over(or Minimize & Mazimize the Window), the red it's visible.

http://www.autoitscript.com/fileman/users/public/!Josbe/_misc/4forum/sshot_guictrlsetbk.png

Edited by josbe
Link to comment
Share on other sites

At the moment, I use the old trick for "re-paint" over the window:

$wpos = WinGetPos($wintit, "")
SplashTextOn("", "", $wpos[2], $wpos[3], $wpos[0], $wpos[1], 15)
SplashOff()

But, what about this?

Maybe a small bug:

GUICtrlSetBk function don't update the color in a control.  :ph34r:

Really, the color it's changed, but don't display correctly.

...

http://www.autoitscript.com/fileman/users/public/!Josbe/_misc/4forum/sshot_guictrlsetbk.png

<{POST_SNAPBACK}>

Link to comment
Share on other sites

  • Administrators

At the moment, I use the old trick for "re-paint" over the window:

$wpos = WinGetPos($wintit, "")
SplashTextOn("", "", $wpos[2], $wpos[3], $wpos[0], $wpos[1], 15)
SplashOff()

But, what about this?

From the screenshot I don't understand what is the problem :"> Do you have some code and instructions that I can run that is more clear?
Link to comment
Share on other sites

@Jon: yeah, the problem exists.

Here is a small example:

GUICreate("colortest")

$label1 = GUICtrlCreateLabel("Sample Color",10,10,150,20)
GUICtrlSetBKColor(-1,0xFF00D0)
$button = GUICtrlCreateButton("change",50,70,70,20)
GUICtrlSetNotify()
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    
    IF $msg = -3 Then ExitLoop
    If $msg = $button Then GUICtrlSetBKColor($label1,0xFF0000)
WEnd

GUIDelete()
Exit

Maybe this could be a solution:

////////////////////////////////////////////////////////////////////////////////////////////////
// CtrlSetBkColor()
//
////////////////////////////////////////////////////////////////////////////////////////////////

int CGuiBox::CtrlSetBkColor(int nColor)
{
     HWND A = GetControlHWND(m_iLastDefined);
    BYTE cType = GUICtrl[m_iLastDefined].cType;

    if (m_bColorModeBGR == false)
        Util_RGBtoBGR(nColor);

    switch (cType)
    {
        case AUT_GUI_PROGRESS:
            SendMessage(A,(UINT)PBM_SETBKCOLOR,(WPARAM)0,(LPARAM)nColor);
            break;

        case AUT_GUI_TREEVIEW:
            SendMessage(A,(UINT)TVM_SETBKCOLOR,(WPARAM)0,(LPARAM)nColor);
            break;

        case AUT_GUI_CHECKBOX:
        case AUT_GUI_GROUP:
        case AUT_GUI_LABEL:
        case AUT_GUI_RADIO:
            ChangeColor(GUICtrl[m_iLastDefined].nBackColor, nColor);
            GUICtrl[m_iLastDefined].nBackColor = nColor;
             InvalidateRect(A,NULL,true);
            break;
    }

    return m_iLastDefined;

} // CtrlSetBkColor()

Edit: sorry, rect is no needed :ph34r:

Regards Holger

Edited by Holger
Link to comment
Share on other sites

Sorry. :">

I cut a piece of my code for show you.

Opt("GUINotifyMode", "1")
#include "GUIConstants.au3"
_testwin()

GUIDelete()
Exit

Func _testwin()
;// Colours
   Global $_colorList = "White.FFFFFF|Blue.C9EFFC|Green.9BFFCD|Red.FF8080|Yellow.FFFFE6|Magenta.F5C6FF"
   If Not IsDeclared("_WinColor") Then Global $_WinColor = 0
   Global $_fcolor = Dec($_WinColor)
   
   $wintit = "TEST Window - Colors"
   GUICreate($wintit, 340, 130, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_GROUP, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU))
    
   Global $CTRL_colorGroup = GUICtrlCreateGroup("Color", 140, 5, 180, 95)
   
   Global $CTRL_repaintChk = GUICtrlCreateCheckbox('Use the "re-paint trick"', 150, 25, 160, 18)
   
;// Working with Color List
   $arrColors = StringSplit($_colorList, "|")
   $listNColors = ""
   $_lcolorw = ""
   For $y = 1 To $arrColors[ 0 ]
      $cname = StringTrimRight($arrColors[ $y ], 7)
      $ccode = StringRight($arrColors[ $y ], 6)
      If $_WinColor = $ccode Then $_lcolorw = $cname
      $listNColors = $listNColors & "|" & $cname
   Next
   $listNColors = StringTrimLeft($listNColors, 1)
   
   Global $CTRL_colorList = GUICtrlCreateCombo("", 150, 45, 115, 100, $CBS_SORT + $CBS_DROPDOWNLIST + $LBS_STANDARD)
   GUICtrlSetData(-1, $listNColors, $_lcolorw)
   
   Global $CTRL_colorLblSample = GUICtrlCreateLabel("Sample color", 150, 70, 115, 25, $SS_SUNKEN) 
   GUICtrlSetBkColor(-1, $_fcolor)

   $btnClose= GUICtrlCreateButton("Close", 130, 105, 70, 20)
   GUISetState()
   
   While 1
      $msg = GUIGetMsg()
      Select
         Case $msg = -3 Or $msg = -1 Or $msg = $btnClose
            ExitLoop
            
         Case $msg = $CTRL_colorList
            $_mColorw = GUIRead($CTRL_colorList)
            For $y = 1 To $arrColors[ 0 ]
               $cname = StringTrimRight($arrColors[ $y ], 7)
               $ccode = StringRight($arrColors[ $y ], 6)
               If $_mColorw = $cname Then
                  Global $_WinColor = $ccode
                  ExitLoop
               EndIf
            Next
         ;// Updating color
            GUICtrlSetBkColor($CTRL_colorLblSample, Dec($_WinColor))
            
            If GUIRead($CTRL_repaintChk) = $GUI_CHECKED Then
            ;// Re-paint trick
               $wpos = WinGetPos($wintit, "")
               SplashTextOn("", "", $wpos[2], $wpos[3], $wpos[0], $wpos[1], 15)
               SplashOff()
            EndIf
            
      EndSelect
   Wend
EndFunc

EDIT: oops! thxs holger.... :ph34r:

Edited by josbe
Link to comment
Share on other sites

  • Administrators

Ah, thanks Holger and Josbe. Fixed at this end :ph34r:

(H, The ChangeColor is no longer required at that point as it automagically allocates brushes during the paint process now)

Link to comment
Share on other sites

@Jon: the same problem at "CtrlSetColor" :(

Here is one more extended sample.

The problem is in the "AboutGUI":

#include "GUIConstants.au3"

$maingui = GUICreate("Main",400,300)

$generalmenu = GUICtrlCreateMenu("General")
$preferencemenuitem = GUICtrlCreateMenuItem("Preferences...",$generalmenu)
$helpmenu = GUICtrlCreateMenu("?")
$helpmenuitem = GUICtrlCreateMenuItem("Help",$helpmenu)
GUICtrlCreateMenuItem("",$helpmenu)
$aboutmenuitem = GUICtrlCreateMenuItem("About...",$helpmenu)

$aboutgui = GUICreate("About",340,120,-1,-1,BitOr($WS_POPUP,$WS_CAPTION,$WS_SYSMENU),-1,$maingui)
$urlx = 140
$urly = 40
$urlw = 63
$urlh = 16
$gotourl = GUICtrlCreateLabel("Homepage",$urlx,$urly,$urlw,$urlh)
GUICtrlSetFont(-1,-1,-1,4)
GUICtrlSetColor(-1,0x0020FF)
$aboutok = GUICtrlCreateButton("OK",250,85,70,20)

$preferencegui = GUICreate("Options",340,190,-1,-1,BitOr($WS_POPUP,$WS_CAPTION,$WS_SYSMENU),-1,$maingui)
$prefstree = GuiCtrlCreateTreeView(10,10,320,140,BitOr($TVS_CHECKBOXES,$TVS_DISABLEDRAGDROP),$WS_EX_CLIENTEDGE)
$pref1 = GuiCtrlCreateTreeViewItem("Pref 1",$prefstree)
$pref2 = GuiCtrlCreateTreeViewItem("Pref 2",$prefstree)
$pref3 = GuiCtrlCreateTreeViewItem("Pref 3",$prefstree)
$pref4 = GuiCtrlCreateTreeViewItem("Pref 4",$prefstree)
$pref5 = GuiCtrlCreateTreeViewItem("Pref 5",$prefstree)
$prefok = GUICtrlCreateButton("OK",135,160,70,20)

GUISwitch($maingui)
GuiSetState(@SW_SHOW)

$urlset = 0
While 1
    $msg = GUIGetMsg(1)
;Msgbox(0,"",$msg[0] & @LF & $msg[1] & @LF & $msg[2] & @LF & $msg[3] & @LF & $msg[4])
    $ctrlmsg = $msg[0]
    $win = $msg[1]
    $posx = $msg[3]
    $posy = $msg[4]
    
    Select
        Case $ctrlmsg = -3 And $win = $maingui
            ExitLoop
            
        Case $ctrlmsg = $preferencemenuitem
            GUISwitch($preferencegui)
            GuiSetState(@SW_SHOW)
            
        Case $ctrlmsg = $prefok Or ($ctrlmsg = -3 And $win = $preferencegui)
               GUISwitch($preferencegui)
               GuiSetState(@SW_HIDE)
            
        Case $ctrlmsg = $aboutmenuitem
            GUISwitch($aboutgui)
            GuiSetState(@SW_SHOW)
            
        Case $ctrlmsg = $aboutok Or ($ctrlmsg = -3 And $win = $aboutgui)
             GUISwitch($aboutgui)
             GuiSetState(@SW_HIDE)
        
        Case ($ctrlmsg = $GUI_EVENT_MOUSEMOVE Or $ctrlmsg = $GUI_EVENT_PRIMARYDOWN) And $win = $aboutgui
            If $posx >= $urlx And $posx <= $urlx + $urlw And $posy >= $urly And $posy <= $urly + $urlh Then
                If $urlset = 0 Then
                    GUICtrlSetColor($gotourl,0x20C020)
                    GUISetCursor(0)
                    $urlset = 1
                EndIf
                If $ctrlmsg = $GUI_EVENT_PRIMARYDOWN Then Run(RegRead("HKEY_CLASSES_ROOT\http\shell\open\command","") & " http://www.autoitscript.com/forum")
            Else
                If $urlset = 1 Then
                    GUICtrlSetColor($gotourl,0x0020FF)
                    GUISetCursor(-1)
                    $urlset = 0
                EndIf
            EndIf
        
    EndSelect
WEnd

GUIDelete()

Exit

Regards Holger :ph34r:

Edited by Holger
Link to comment
Share on other sites

Wow! the new gui capabilities are wonderful. Thanks to all those who are responsible...

If it isn't too late, maybe syslistview can also be added? similar to windows explorer's right pane where items can be sorted by column...  :)

<{POST_SNAPBACK}>

Another great idea :)
Link to comment
Share on other sites

Wow! the new gui capabilities are wonderful. Thanks to all those who are responsible...

If it isn't too late, maybe syslistview can also be added? similar to windows explorer's right pane where items can be sorted by column...  :)

<{POST_SNAPBACK}>

Come'on, please add this.

I found some sites:

http://www.codeguru.com/Cpp/controls/listview/

http://www.codeguru.com/Cpp/controls/listv...ticle.php/c909/

http://msdn.microsoft.com/library/default....c_clistctrl.asp

http://www.codeproject.com/listctrl/supergrid.asp

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...