Sign in to follow this  
Followers 0
lsakizada

Why my button disapear?

13 posts in this topic

Hi,

Can you please help me to understand why the button (named $RegisterButton (in line 51))

is disapearing on RESIZING the vetical and Horizontal splitters?

Can you please correct the script to make the button viewable?

by the way this code created by other user, I just modified it alittle bit ...

#include <GUIConstants.au3>
#include <GuiTab.au3>
;#include <GuiStatusbar.au3>

;===============================================================================
; FileName:         splitterdemo.au3
; Description:    Splitter Bar demo
;
; Requirement:    Beta;!!! with this version beta is not required
; Author(s):        eltorro (Steve Podhajecki <gehossafats@netmdc.com>) modified by Tresa
; Note(s):          This is just a proof of concept at the moment.
;                   This could be tweaked into a udf with a little more work
;                   The basic principle is to create a pic box or label and drag it
;                   then resize the controls.
;                   I bowwored some filler for the tree and list from the help files.
;===============================================================================
;$WM_SIZE =0x0005
    Global $Form1Height=448
    Global $Form1Width=622
    Global $splitWidth=5
    Global $leftVSplit=144
    Global $topHSplit=320
    Global $topMargin=6
    Global $leftMargin=4
    Global $rigthMargin=4
    Global $bottomMargin=6
    Global $statusBarHeight

$Form1  = GUICreate("Splitter Demo", $Form1Width, $Form1Height,192,125, BitOr($WS_SIZEBOX,  $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU,$WS_CLIPCHILDREN))

$TreeView1  = GUICtrlCreateTreeView($leftMargin, $topMargin, $leftVSplit-$leftMargin, $topHSplit-$topMargin, BitOR($TVS_HASBUTTONS,  $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP,  $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
    $generalitem = GUICtrlCreateTreeViewItem("General", $TreeView1)
    GUICtrlSetColor(-1, 0x0000C0)
    $displayitem = GUICtrlCreateTreeViewItem("Display", $TreeView1)
    GUICtrlSetColor(-1, 0x0000C0)
    $aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem)
    $compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem)
    $useritem = GUICtrlCreateTreeViewItem("User", $generalitem)
    $resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem)
    $otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem)
    GUICtrlSetState($generalitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "General"-item and paint in bold
    GUICtrlSetState($displayitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "Display"-item and paint in bold


    
$Tab1 = GUICtrlCreateTab(120, 56, 393, 281)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")

$RegisterButton = GUICtrlCreateButton("Register", 304, 195, 75, 25, 0)

GUICtrlCreateTabItem("")

;vertical divider
$Pic1 = GUICtrlCreateLabel("", $leftVSplit, $topMargin, $splitWidth, $topHSplit-$topMargin, $SS_NOTIFY)
GUICtrlSetCursor($Pic1, 13)

;horizontal divider.
$Pic2 = GUICtrlCreatePic("", $leftMargin, $topHSplit, $Form1Width-$leftMargin-$rigthMargin, $splitWidth,$SS_NOTIFY);!!! BitOR($SS_NOTIFY, $SS_ETCHEDFRAME), $WS_EX_CLIENTEDGE)
GUICtrlSetCursor($Pic2, 11)

Global $current = _GUICtrlTabGetCurFocus ($Tab1)


Local $DragCtrl=""


$Edit1 = GUICtrlCreateEdit("", $leftMargin, $topHSplit+$splitWidth, $Form1Width-$leftMargin-$rigthMargin, $Form1Height-$bottomMargin-$statusBarHeight-$topHSplit-$splitWidth, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetData($Edit1, "Drag the bars between the controls and they will resize." & @CRLF & _
        "Resize the screen and see what happens."& @CRLF & _
        "The Status bar show True the left mouse button is down and over a splitter.")

opt("MouseCoordMode", 2)

GUISetState(@SW_SHOW)
dim $precedingMsg,$stopTime
ResizeControls()
GUIRegisterMsg($WM_SIZE,"RESIZE_CONTROLS")


While 1
    $msg = GUIGetMsg()
    Select
    ;Case $msg = $aboutitem
    ;   MsgBox(0,0,"",4)
        Case $msg = $GUI_EVENT_PRIMARYDOWN
          ; _GuiCtrlStatusBarSetText ($Status1, "Primary Down", 0)
        Case $msg = $Pic1
           ;if $DragCtrl="" then _GuiCtrlStatusBarSetText ($Status1, "Pic1 Primary Down",0)
            $DragCtrl = $Pic1

        Case $msg = $Pic2
          ; _GuiCtrlStatusBarSetText ($Status1, "Pic2 Primary Down", 0)
            $DragCtrl = $Pic2
        Case $msg = $GUI_EVENT_PRIMARYUP
          ; _GuiCtrlStatusBarSetText ($Status1, "Primary Up", 0)
            saveSplitPos()
          ; _GuiCtrlStatusBarSetText ($Status1, "", 1)
            Select
                Case $DragCtrl = $Pic1
                    SplitterVert($TreeView1, $Tab1, $Pic1, $Pic2)
                    $DragCtrl = ""
                Case $DragCtrl = $Pic2
                    SplitterHort($TreeView1, $Tab1, $Edit1, $Pic2)
                    $DragCtrl = ""
            EndSelect
            
        Case $msg = $GUI_EVENT_SECONDARYDOWN
           ;_GuiCtrlStatusBarSetText ($Status1, "Secondary Down", 0)
        Case $msg = $GUI_EVENT_SECONDARYUP
           ;_GuiCtrlStatusBarSetText ($Status1, "Secondary Up", 0)
        Case $msg = $GUI_EVENT_MOUSEMOVE
            $stopTime=TimerInit()
            if $DragCtrl<>"" then
              ; _GuiCtrlStatusBarSetText ($Status1, "Dragging", 1)
                Local $picpos = ControlGetPos("", "", $DragCtrl)
                Local $mousepos = MouseGetPos()
                Local $winpos = WinGetClientSize("")
                If $DragCtrl = $Pic1 Then
                     If $mousepos[0] > 25 And $mousepos[0]<  ($winpos[0] - 25) Then GUICtrlSetPos($Pic1, $mousepos[0], $picpos[1],2)
                EndIf
                If $DragCtrl = $Pic2 Then
                     If $mousepos[1] > 25 And $mousepos[1]<  ($winpos[1] - 25) Then GUICtrlSetPos($Pic2, $picpos[0], $mousepos[1],$picpos[2],2)
                EndIf
            Else
              ; _GuiCtrlStatusBarSetText ($Status1, "Mouse Move", 0)
            EndIf
        Case $msg = $GUI_EVENT_RESIZED or $msg = $GUI_EVENT_MAXIMIZE or $msg=$GUI_EVENT_RESTORE;!!!
            ResizeControls()
            saveSplitPos()

        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            $idleTime=TimerDiff($stopTime)
            if $idleTime>100 Then
                $stopTime=TimerInit()
                if $DragCtrl<>"" then
               ;    _GuiCtrlStatusBarSetText ($Status1, "Idling", 1)
                Else
                ;   _GuiCtrlStatusBarSetText ($Status1, "Idling", 0)
                EndIf
            EndIf
    EndSelect
WEnd
Exit

Func saveSplitPos()
    Local $winpos = WinGetClientSize("")
    $Form1Width=$winpos[0]
    $Form1Height=$winpos[1]
    Local $splitpos1 = ControlGetPos("", "", $Pic1)
    $leftVSplit=$splitpos1[0]
    Local $splitpos2 = ControlGetPos("", "", $Pic2)
    $topHSplit=$splitpos2[1]
EndFunc
        
Func RESIZE_CONTROLS($hWnd, $Msg, $wParam, $lParam)
    Local $winpos = WinGetClientSize("")
    Local $Hcoef=($winpos[0]-$leftMargin-$rigthMargin-$splitWidth)/($Form1Width-$leftMargin-$rigthMargin-$splitWidth)
    Local $Vcoef=($winpos[1]-$topMargin-$bottomMargin-$splitWidth-$statusBarHeight)/($Form1Height-$topMargin-$bottomMargin-$splitWidth-$statusBarHeight)

    GUICtrlSetPos($pic2,$leftMargin,$topMargin+($topHSplit-$topMargin)*$Vcoef,$winpos[0])
    GUICtrlSetPos($pic1,$leftMargin+($leftVSplit-$leftMargin)*$Hcoef,$topMargin,$splitWidth,($topHSplit-$topMargin)*$Vcoef)
    
    ResizeControls()
    Return $GUI_RUNDEFMSG
EndFunc

Func ResizeControls()
   ;_GuiCtrlStatusBarResize ($Status1)

    SplitterHort($TreeView1, $Tab1, $Edit1, $Pic2)
    SplitterVert($TreeView1, $Tab1, $Pic1, $Pic2)
EndFunc;==>ResizeControls

Func SplitterVert($ctrl1, $ctrl2, $split1,$iop)
    GUICtrlSetState($split1,$gui_hide);!!!
    Local $splitpos1 = ControlGetPos("", "", $split1)
    Local $winpos = WinGetClientSize("")

    GUICtrlSetPos($split1,$splitpos1[0],$splitpos1[1],$splitWidth,$splitpos1[3]);!!!

    GUICtrlSetPos($ctrl1, $leftMargin, $splitpos1[1], _
            ($splitpos1[0] - $leftMargin), _
            $splitpos1[3])
    
    GUICtrlSetPos($ctrl2, $splitpos1[0] + $splitWidth, _
            $splitpos1[1], _
            $winpos[0] -$rigthMargin- $splitpos1[0] - $splitWidth, _
            $splitpos1[3])
    GUICtrlSetState($split1,$gui_show);!!!
EndFunc;==>SplitterVert

Func SplitterHort($ctrl1, $ctrl2, $ctrl3, $split)
    Local $splitpos = ControlGetPos("", "", $split)
    Local $splitpic1 = ControlGetPos("", "", $pic1);!!!
    $splitpos[3]=$splitWidth
    GUICtrlSetPos($split,$splitpos[0],$splitpos[1],$splitpos[2],$splitWidth);!!!
    GUICtrlSetState($split,$gui_hide);!!!

    Local $winpos = WinGetClientSize("")

    Local $nh
    $nh = $splitpos[1]-$topMargin;jcd - 9

    GUICtrlSetPos($ctrl1, $leftMargin, $topMargin, $splitpic1[0]-$leftMargin,$nh)
    GUICtrlSetPos($ctrl2, $splitpic1[0]+$splitWidth,$topMargin,$winpos[0]-$rigthMargin-($splitpic1[0]+$splitWidth),$nh)
    
    Local $top = $splitpos[1] + $splitWidth
    GUICtrlSetPos($pic1, $splitpic1[0], $splitpic1[1], $splitpic1[2], $nh);!!!

    $nh = $winpos[1] - $top - $bottomMargin-$statusBarHeight; move this up above the status bar

    GUICtrlSetPos($ctrl3, $leftMargin, _
                              $top, _
                            $winpos[0]-$leftMargin-$rigthMargin, _
                            $nh)
 
    GUICtrlSetState($split,$gui_show);!!!
EndFunc;==>SplitterHort

Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites



that's kinda wierd.... could you make a smaller example of this happening? there is alot of extra code in there that can make reading though this a chore (unless someone else wants to spend the time)

Share this post


Link to post
Share on other sites

that's kinda wierd.... could you make a smaller example of this happening? there is alot of extra code in there that can make reading though this a chore (unless someone else wants to spend the time)

it is the minimum that I can do. maybe deleting some line but this not make the difference.

it is important to solve it.


Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

I added one line and it seems to work:

While 1
        guictrlsetstate($RegisterButton,$GUI_ONTOP)     ; <<<<<<<<<<<<<Added this line

    $msg = GUIGetMsg()

Hi,

Can you please help me to understand why the button (named $RegisterButton (in line 51))

is disapearing on RESIZING the vetical and Horizontal splitters?


...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

It's not the minimum you can do to reproduce the problem... for example something like this

#include <GUIConstants.au3>
#include <GuiTab.au3>
;#include <GuiStatusbar.au3>

;===============================================================================
; FileName:            splitterdemo.au3
; Description:      Splitter Bar demo
;
; Requirement:      Beta;!!! with this version beta is not required
; Author(s):        eltorro (Steve Podhajecki <gehossafats@netmdc.com>) modified by Tresa
; Note(s):            This is just a proof of concept at the moment.
;                    This could be tweaked into a udf with a little more work
;                    The basic principle is to create a pic box or label and drag it
;                    then resize the controls.
;                    I bowwored some filler for the tree and list from the help files.
;===============================================================================
;$WM_SIZE =0x0005
    Global $Form1Height=448
    Global $Form1Width=622
    Global $splitWidth=5
    Global $leftVSplit=144
    Global $topHSplit=320
    Global $topMargin=6
    Global $leftMargin=4
    Global $rigthMargin=4
    Global $bottomMargin=6
    Global $statusBarHeight
$Form1  = GUICreate("Splitter Demo", $Form1Width, $Form1Height,192,125, BitOr($WS_SIZEBOX,  $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU,$WS_CLIPCHILDREN))
$TreeView1  = GUICtrlCreateTreeView($leftMargin, $topMargin, $leftVSplit-$leftMargin, $topHSplit-$topMargin, BitOR($TVS_HASBUTTONS,  $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP,  $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$Tab1 = GUICtrlCreateTab(120, 56, 393, 281)
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$RegisterButton = GUICtrlCreateButton("Register", 304, 195, 75, 25, 0)
$Pic1 = GUICtrlCreateLabel("", $leftVSplit, $topMargin, $splitWidth, $topHSplit-$topMargin, $SS_NOTIFY)
GUICtrlSetCursor($Pic1, 13)
$Pic2 = GUICtrlCreatePic("", $leftMargin, $topHSplit, $Form1Width-$leftMargin-$rigthMargin, $splitWidth,$SS_NOTIFY);!!! BitOR($SS_NOTIFY, $SS_ETCHEDFRAME), $WS_EX_CLIENTEDGE)
GUICtrlSetCursor($Pic2, 11)
Global $current = _GUICtrlTabGetCurFocus ($Tab1)
Local $DragCtrl=""
opt("MouseCoordMode", 2)
GUISetState(@SW_SHOW)
dim $precedingMsg,$stopTime
SplitterVert($TreeView1, $Tab1, $Pic1, $Pic2)
GUIRegisterMsg($WM_SIZE,"RESIZE_CONTROLS")
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED or $msg = $GUI_EVENT_MAXIMIZE or $msg=$GUI_EVENT_RESTORE;!!!
            SplitterVert($TreeView1, $Tab1, $Pic1, $Pic2)
            saveSplitPos()
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            $idleTime=TimerDiff($stopTime)
            if $idleTime>100 Then $stopTime=TimerInit()
    EndSelect
WEnd
Exit
Func saveSplitPos()
    Local $winpos = WinGetClientSize("")
    $Form1Width=$winpos[0]
    $Form1Height=$winpos[1]
    Local $splitpos1 = ControlGetPos("", "", $Pic1)
    $leftVSplit=$splitpos1[0]
    Local $splitpos2 = ControlGetPos("", "", $Pic2)
    $topHSplit=$splitpos2[1]
EndFunc
Func RESIZE_CONTROLS($hWnd, $Msg, $wParam, $lParam)
    Local $winpos = WinGetClientSize("")
    Local $Hcoef=($winpos[0]-$leftMargin-$rigthMargin-$splitWidth)/($Form1Width-$leftMargin-$rigthMargin-$splitWidth)
    Local $Vcoef=($winpos[1]-$topMargin-$bottomMargin-$splitWidth-$statusBarHeight)/($Form1Height-$topMargin-$bottomMargin-$splitWidth-$statusBarHeight)

    GUICtrlSetPos($pic2,$leftMargin,$topMargin+($topHSplit-$topMargin)*$Vcoef,$winpos[0])
    GUICtrlSetPos($pic1,$leftMargin+($leftVSplit-$leftMargin)*$Hcoef,$topMargin,$splitWidth,($topHSplit-$topMargin)*$Vcoef)
    
    SplitterVert($TreeView1, $Tab1, $Pic1, $Pic2)
    Return $GUI_RUNDEFMSG
EndFunc
Func SplitterVert($ctrl1, $ctrl2, $split1,$iop)
    GUICtrlSetState($split1,$gui_hide);!!!
    Local $splitpos1 = ControlGetPos("", "", $split1)
    Local $winpos = WinGetClientSize("")

    GUICtrlSetPos($split1,$splitpos1[0],$splitpos1[1],$splitWidth,$splitpos1[3]);!!!

    GUICtrlSetPos($ctrl1, $leftMargin, $splitpos1[1], _
            ($splitpos1[0] - $leftMargin), _
            $splitpos1[3])
    
    GUICtrlSetPos($ctrl2, $splitpos1[0] + $splitWidth, _
            $splitpos1[1], _
            $winpos[0] -$rigthMargin- $splitpos1[0] - $splitWidth, _
            $splitpos1[3])
    GUICtrlSetState($split1,$gui_show);!!!
EndFunc;==>SplitterVert

Is much less code but the underlying problem is the same... see if you can skim it down to a basic exmplae of the button disapearing when you resize it.

Share this post


Link to post
Share on other sites

I added one line and it seems to work:

While 1
        guictrlsetstate($RegisterButton,$GUI_ONTOP)     ; <<<<<<<<<<<<<Added this line

    $msg = GUIGetMsg()
Thanks! You helped me much.

I was not aware when to use the $GUI_ONTOP option. now I know :)


Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

Well,

How to change the position of the button relative to the horizontal/vertical splitter?

The point now is how to move all controls in the tab items controls, all together to the right/left when the vertical splitter is moved???

I was not able to figure it out.

Anyone else want try and send the idea?


Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

I think you've already have been doing things liek this with GUictrlsetpos()... just use that on the controls of the tab?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I think you've already have been doing things liek this with GUictrlsetpos()... just use that on the controls of the tab?

Yes, but with 6 tabitems and 10 controls (at least)on each of then my project will never be finished!

must be way to set the control position relative to the tabitems.

Edited by lsakizada

Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

#10 ·  Posted

GUICtrlSetResizing ( controlID, $GUI_DOCKLEFT ) ?

Share this post


Link to post
Share on other sites

#11 ·  Posted

GUICtrlSetResizing ( controlID, $GUI_DOCKLEFT ) ?

No! the GUICtrlSetResizing is intended for resizing the main gui and not control.

beside of that no control is resized. they are changing their position only.


Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

#12 ·  Posted

what about making the names of the controls something like $TabXControlY then using eval() to loop though and set them?

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

what about making the names of the controls something like $TabXControlY then using eval() to loop though and set them?

Eval is not for arrays. it returns variables so its not good to set position of control.

The fast solution tahat i sees right now is to use something like that:

If $DragCtrl = $Pic1 Then
    If $mousepos[0] > 25 And $mousepos[0]<  ($winpos[0] - 25) Then 
        GUICtrlSetPos($Pic1, $mousepos[0], $picpos[1],1)
        GUICtrlSetPos($RegisterButton, $picpos[0]+$picpos2[1] , $picpos2[1],$picpos2[2],$picpos2[3])
    endif
EndIf
    If $DragCtrl = $Pic2 Then
                         If $mousepos[1] > 25 And $mousepos[1]<  ($winpos[1] - 25) 
Then GUICtrlSetPos($Pic2, $picpos[0], $mousepos[1],$picpos[2],2)
                EndIf
Edited by lsakizada

Be Green Now or Never (BGNN)!

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  
Followers 0