Jump to content

Border / GuiCtrlCreateGroup alternative?


Cusem
 Share

Recommended Posts

Hey Guys,

does anyone have a tip on how to create an "border group" (don't know what to call it exactly) like in the example picture below?

I want to group certain controls in a embossed/extruded/kind of box. So basically what GuiCtrlCreateGroup does, but with a bit more dramatic effect. I thought I accomplished this by creating a treeview box with the following code (this is the code for the right-lower "border group" in the picture):

$BORDERqz1 = GUICtrlCreateTreeView($mX1 + $tvW + $tvS , $mY1 + 50, $GuiWidth - 100 - $tvS - $tvW, $GuiHeight - 150, Default, BitOr($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE))
GUICtrlSetBkColor($BORDERqz1, 0xDFDEE1)
GUICtrlSetState($BORDERqz1, @SW_DISABLE)

And although this works fine with labels and buttons, I can not use the Inputs. If I click on them, the cursor doesn't appear. I figure this has something to do with putting the controls on top of another control.

Anybody has an idea how to either make the inputboxes work or how to create a "border group" effect as desired?

Thanks!

Example pic:

Posted Image

Link to comment
Share on other sites

No I have not! This appears to be a great solution, however the result is kinda, surprising (see pic) >_<

Guess that has to do with using XSkin. But I'll definitely have a look at $SS_SUNKEN. Didn't know about that one. Thanks a lot!

Posted Image

Link to comment
Share on other sites

If you've got the patience then it just needs a lot of lines in the right place with the right colour. (which I suppose is how the Mona Lisa was created.)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 270, 197, 123)
$Label1 = GUICtrlCreateLabel("", 90, 37, 398, 1, $WS_CLIPSIBLINGS)
GUICtrlSetBkColor(-1, 0x808080)
$Label2 = GUICtrlCreateLabel("", 91, 35, 401, 2)
GUICtrlSetBkColor(-1, 0xD4D0C8)
$Label3 = GUICtrlCreateLabel("", 91, 196, 400, 2)
GUICtrlSetBkColor(-1, 0xA0A0A4)
$Label4 = GUICtrlCreateLabel("", 94, 195, 395, 1, $WS_CLIPSIBLINGS)
GUICtrlSetBkColor(-1, 0xFFFFE1)
$Label5 = GUICtrlCreateLabel("", 90, 35, 2, 162)
GUICtrlSetBkColor(-1, 0xD4D0C8)
$Label6 = GUICtrlCreateLabel("", 92, 38, 1, 157)
GUICtrlSetBkColor(-1, 0xA0A0A4)
$Label7 = GUICtrlCreateLabel("", 487, 37, 3, 159)
GUICtrlSetBkColor(-1, 0xDDDDDD)
$Label8 = GUICtrlCreateLabel("", 490, 35, 1, 163)
GUICtrlSetBkColor(-1, 0xA0A0A4)
$Label9 = GUICtrlCreateLabel("", 104, 51, 369, 1, $WS_CLIPSIBLINGS)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$Label10 = GUICtrlCreateLabel("", 102, 184, 371, 1, $WS_CLIPSIBLINGS)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$Label11 = GUICtrlCreateLabel("", 104, 50, 1, 135, $WS_CLIPSIBLINGS)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$Label12 = GUICtrlCreateLabel("", 472, 51, 1, 134, $WS_CLIPSIBLINGS)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$Input1 = GUICtrlCreateInput("Input1", 132, 69, 121, 21)
$Button1 = GUICtrlCreateButton("Button1", 352, 75, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I created a function based on Martin's code.

It's different though, I moved the inner box against the outer box and changed the color of the right-bar. So I guess it loses it's 3D effect, at this moment I thought it looked better this way (haven't tested a lot).

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 470, 197, 123)


;--->>> Example
GroupBox(30, 30, 300, 200)
;<<<--- Example


Func GroupBox($x, $y, $w, $h) ;X-Pos, Y-Pos, Width, Height
    
    ;--->>> Top
    Local $lblto = GUICtrlCreateLabel("", $x+1, $y, $w, 2)
    Local $lblti = GUICtrlCreateLabel("", $x, $y+2, $w-2, 1, $WS_CLIPSIBLINGS)
    Local $lblrb = GUICtrlCreateLabel("", $x+4, $y+4, $w-8, 1, $WS_CLIPSIBLINGS)
    GUICtrlSetBkColor($lblto, 0xD4D0C8)
    GUICtrlSetBkColor($lblti, 0x808080)
    GUICtrlSetBkColor($lblrb, 0xC0C0C0)
    ;<<<--- Top
    
    ;--->>> Bottom
    Local $lblbo = GUICtrlCreateLabel("", $x, $y+$h+1, $w, 2)
    Local $lblbi = GUICtrlCreateLabel("", $x+1, $y+$h, $w-3, 1, $WS_CLIPSIBLINGS)
    Local $lblbb = GUICtrlCreateLabel("", $x+4, $y+$h-1, $w-8, 1, $WS_CLIPSIBLINGS)
    GUICtrlSetBkColor($lblbo, 0xA0A0A4)
    GUICtrlSetBkColor($lblbi, 0xFFFFE1)
    GUICtrlSetBkColor($lblbb, 0xC0C0C0)
    ;<<<--- Bottom
    
    ;--->>> Left
    Local $lbllo = GUICtrlCreateLabel("", $x, $y, 2, $h+2)
    Local $lblli = GUICtrlCreateLabel("", $x+2, $y+3, 1, $h-3)
    Local $lbllb = GUICtrlCreateLabel("", $x+4, $y+4, 1, $h-4, $WS_CLIPSIBLINGS)
    GUICtrlSetBkColor($lbllo, 0xD4D0C8)
    GUICtrlSetBkColor($lblli, 0xA0A0A4)
    GUICtrlSetBkColor($lbllb, 0xC0C0C0)
    ;<<<--- Left
    
    ;--->>> Right
    Local $lblro = GUICtrlCreateLabel("", $x+$w-1, $y, 2, $h+3)
    Local $lblri = GUICtrlCreateLabel("", $x+$w-2, $y+2, 1, $h-1)
    Local $lblrb = GUICtrlCreateLabel("", $x+$w-4, $y+4, 1, $h-4, $WS_CLIPSIBLINGS)
    GUICtrlSetBkColor($lblro, 0xD4D0C8)
    GUICtrlSetBkColor($lblri, 0x808080)
    GUICtrlSetBkColor($lblrb, 0xC0C0C0)
    ;<<<--- Right
    
EndFunc

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Link to comment
Share on other sites

That works quite well Cusem. Here's a variation.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("Form1", 633, 300, 197, 123)


;--->>> Example
GroupBox(30, 30, 300, 100, 120, 26, "Group box Number 1")
GroupBox(30, 170, 300, 100, 120, 0, "Group box Number 2")
;<<<--- Example

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func GroupBox($x, $y, $w, $h, $lw = 0, $lh = 0, $lText = '') ;X-Pos, Y-Pos, Width, Height
    If $lh = 0 And $lText = '' Then $lw = 0
    ;--->>> Top
    Local $lbltoL = GUICtrlCreateLabel("", $x + 1, $y, 10 - 1, 2)
    Local $lbltoR = GUICtrlCreateLabel("", $x + 10 + $lw, $y, $w - 10 - $lw, 2)
    Local $lbltiL = GUICtrlCreateLabel("", $x, $y + 2, 10, 1, $WS_CLIPSIBLINGS)
    Local $lbltiR = GUICtrlCreateLabel("", $x + 10 + $lw, $y + 2, $w - 2 - 10 - $lw, 1, $WS_CLIPSIBLINGS)
    Local $lblrbL = GUICtrlCreateLabel("", $x + 4, $y + 4, 10 - 4, 1, $WS_CLIPSIBLINGS)
    Local $lblrbR = GUICtrlCreateLabel("", $x + 10 + $lw, $y + 4, $w - 4 - 10 - $lw, 1, $WS_CLIPSIBLINGS)
    GUICtrlSetBkColor($lbltoL, 0xD4D0C8)
    GUICtrlSetBkColor($lbltiL, 0x808080)
    GUICtrlSetBkColor($lblrbL, 0xC0C0C0)
    GUICtrlSetBkColor($lbltoR, 0xD4D0C8)
    GUICtrlSetBkColor($lbltiR, 0x808080)
    GUICtrlSetBkColor($lblrbR, 0xC0C0C0)
    ;<<<--- Top

    ;--->>> Bottom
    Local $lblbo = GUICtrlCreateLabel("", $x, $y + $h + 1, $w, 2)
    Local $lblbi = GUICtrlCreateLabel("", $x + 1, $y + $h, $w - 3, 1, $WS_CLIPSIBLINGS)
    Local $lblbb = GUICtrlCreateLabel("", $x + 4, $y + $h - 1, $w - 8, 1, $WS_CLIPSIBLINGS)
    GUICtrlSetBkColor($lblbo, 0xA0A0A4)
    GUICtrlSetBkColor($lblbi, 0xFFFFE1)
    GUICtrlSetBkColor($lblbb, 0xC0C0C0)
    ;<<<--- Bottom

    ;--->>> Left
    Local $lbllo = GUICtrlCreateLabel("", $x, $y, 2, $h + 2)
    Local $lblli = GUICtrlCreateLabel("", $x + 2, $y + 3, 1, $h - 3)
    Local $lbllb = GUICtrlCreateLabel("", $x + 4, $y + 4, 1, $h - 4, $WS_CLIPSIBLINGS)
    GUICtrlSetBkColor($lbllo, 0xD4D0C8)
    GUICtrlSetBkColor($lblli, 0xA0A0A4)
    GUICtrlSetBkColor($lbllb, 0xC0C0C0)
    ;<<<--- Left

    ;--->>> Right
    Local $lblro = GUICtrlCreateLabel("", $x + $w - 1, $y, 2, $h + 3)
    Local $lblri = GUICtrlCreateLabel("", $x + $w - 2, $y + 2, 1, $h - 1)
    Local $lblrb = GUICtrlCreateLabel("", $x + $w - 4, $y + 4, 1, $h - 4, $WS_CLIPSIBLINGS)
    GUICtrlSetBkColor($lblro, 0xD4D0C8)
    GUICtrlSetBkColor($lblri, 0x808080)
    GUICtrlSetBkColor($lblrb, 0xC0C0C0)
    ;<<<--- Right
    If $lw > 0 And $lh > 0 Then GroupBox($x + 10, $y - $lh / 2, $lw, $lh)
    If $lText <> "" Then
        If $lh = 0 Then $lh = 22;needs real way to decide label height here, just done to make example work
        GUICtrlCreateLabel($lText, $x + 18, $y - $lh / 2 + 7)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

    EndIf

EndFunc   ;==>GroupBox
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 2 years later...

You all make my life easier on a daily basis.

Joshua, I might just take this chance to let you know that it is frowned upon for someone to bump an old thread unless they are asking a question about the given topic. Even then, it is more common practice to start up a new thread with your question, referring back to the previous thread. While thanks are appreciated as soon as the problem has been resolved, they are not necesary with an old thread.
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...