Sign in to follow this  
Followers 0
ame1011

Inputbox Background Color + Remove Focus

5 posts in this topic

#1 ·  Posted (edited)

Hi, I have a bunch of input boxes set up as a grid, On hover, the background color of the whole row changes so that it's highlighted. If this is done with any speed, a visible flicker occurs.

My first question is: is there any way that I can change the bg color of an input box without the noticeable flicker? Possibly use GDI or some graphics library? I'm not sure as I've never used those types of functions before.

Secondly, is there any way (without disabling the control) to not allow the text within the input box to be selectable? I want the same exact functionality of a disabled control but without the greyed out text. I have readonly enabled but clicking on the box still selects the text.

Edited by ame1011

[font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]

Share this post


Link to post
Share on other sites



The script is gigantic. $ES_READONLY is being used as stated in my first post as well as why using only readonly is not what I want. I am setting the background colors with GuiCtrlSetBkColor().


[font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

then why is it an inputbox and not a label.?

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 338, 137, 193, 125)
$Label1 = GUICtrlCreateLabel("Is this what you want.?", 32, 40, 189, 28, $SS_SUNKEN)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

    EndSwitch
WEnd

guictrlsetstate($handle,$GUI_NOFOCUS)

Edited by Aceguy

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

thanks, that's exactly what i wanted to accomplish!

I didn't even know about the sunken style, this fixes so many problems for me. I never wanted to use input boxes but It was the easiest way to accomplish the 'grid' effect in my eyes.

EDIT: this is part of the code that I'm currently using, my first question remains, is there any way to change the bg color of the labels that would reduce the amount of flicker?

;variables
Dim $y = 0
Dim $SchedCurY = 0
Dim $ScheduleYStart = 0
Dim $ScheduleBoxHeight =25
Dim $ScheduleTimeBoxWidth = 86
Dim $SchedulePlayerBoxWidth = 164
Dim $ScheduleXLocs[5] = [0,$ScheduleTimeBoxWidth-1, $ScheduleTimeBoxWidth + $SchedulePlayerBoxWidth - 2,$ScheduleTimeBoxWidth + ($SchedulePlayerBoxWidth*2) - 3,$ScheduleTimeBoxWidth + ($SchedulePlayerBoxWidth*3) - 5]
Dim $ScheduleList[$SchedNumSlots + 1][5]
Dim $ScheduleListIds[$SchedNumSlots + 1]
Dim $scroll_size = Ceiling($SchedNumSlots * 1.50)


;create header boxes
$ScheduleList[$y][0] = GUICtrlCreateLabel("Time"    , $ScheduleXLocs[0], $ScheduleYStart, $ScheduleTimeBoxWidth, $ScheduleBoxHeight, BitOR($ES_CENTER, $SS_SUNKEN))
GUICtrlSetCursor(-1, 2)
$ScheduleList[$y][1] = GUICtrlCreateLabel("Player 1", $ScheduleXLocs[1], $ScheduleYStart, $SchedulePlayerBoxWidth, $ScheduleBoxHeight, BitOR($ES_CENTER, $SS_SUNKEN))
GUICtrlSetCursor(-1, 2)
$ScheduleList[$y][2] = GUICtrlCreateLabel("Player 2", $ScheduleXLocs[2], $ScheduleYStart, $SchedulePlayerBoxWidth, $ScheduleBoxHeight, BitOR($ES_CENTER, $SS_SUNKEN))
GUICtrlSetCursor(-1, 2)
$ScheduleList[$y][3] = GUICtrlCreateLabel("Player 3", $ScheduleXLocs[3], $ScheduleYStart, $SchedulePlayerBoxWidth, $ScheduleBoxHeight, BitOR($ES_CENTER, $SS_SUNKEN))
GUICtrlSetCursor(-1, 2)
$ScheduleList[$y][4] = GUICtrlCreateLabel("Player 4", $ScheduleXLocs[4], $ScheduleYStart, $SchedulePlayerBoxWidth, $ScheduleBoxHeight, BitOR($ES_CENTER, $SS_SUNKEN))
GUICtrlSetCursor(-1, 2)

;create main boxes (times + player boxes)
for $y = 1 to $SchedNumSlots
    $SchedCurY = $ScheduleYStart+($ScheduleBoxHeight*$y) - $y
    $ScheduleList[$y][0] = GUICtrlCreateLabel(_ConvertSecondsToTime(_ConvertTimeToSeconds($DailyStartTime) + ($Increment * 60 * ($y-1))), $ScheduleXLocs[0], $SchedCurY, $ScheduleTimeBoxWidth, $ScheduleBoxHeight,BitOR($ES_CENTER, $SS_SUNKEN))
    GUICtrlSetCursor(-1, 2)
    for $x = 1 to 4
        $ScheduleList[$y][$x] = GUICtrlCreateLabel("", $ScheduleXLocs[$x], $SchedCurY, $SchedulePlayerBoxWidth, $ScheduleBoxHeight, $SS_SUNKEN)
        GUICtrlSetCursor(-1, 2)
    Next
Next

;style all boxes
for $y = 0 to $SchedNumSlots
    for $x = 0 to 4
        if $y = 0 Then
            GUICtrlSetBkColor($ScheduleList[$y][$x], $ScheduleHeaderBoxColour)
            GUICtrlSetFont($ScheduleList[$y][$x], 11, 600, "", $FontName)
            GUICtrlSetColor($ScheduleList[$y][$x], $ScheduleHeaderBoxFontColour)
        elseif $x = 0 Then
            GUICtrlSetBkColor($ScheduleList[$y][$x], $ScheduleTimeBoxColour)
            GUICtrlSetFont($ScheduleList[$y][$x], 11, 400, "", $FontName)
        Else
            GUICtrlSetFont($ScheduleList[$y][$x], 11, 400, "", $FontName)
            GUICtrlSetBkColor($ScheduleList[$y][$x], $ScheduleBoxColour)
        EndIf
    Next
Next

;Change BG color code
while 1
$nMsg = GuiGetMsg()
;Row Hover Actions
    $nMouseInfo = GUIGetCursorInfo($cSched)
    $nMPos = $nMouseInfo[4]
    $nMPressed = $nMouseInfo[2]
    for $y = 1 to $SchedNumSlots
        ;if hovered over one of the schedule boxes, set current hover row, if clicked set as current clicked row
        if $nMPos = $ScheduleList[$y][0] Or $nMPos = $ScheduleList[$y][1] Or $nMPos = $ScheduleList[$y][2] Or $nMPos = $ScheduleList[$y][3] Or $nMPos = $ScheduleList[$y][4] Then 
            $CurHoverRow = $y
            if $nMPressed Then
                ;get 2nd mouse info and wait for release
                $nMouseInfo2 = GUIGetCursorInfo($cSched)
                $nMPressed2 = $nMouseInfo2[2]
                while $nMPressed2 <> 0
                    sleep(50)
                    $nMouseInfo2 = GUIGetCursorInfo($cSched)
                    $nMPressed2 = $nMouseInfo2[2]
                WEnd
                ;set clicked row
                $CurClickedRow = $y
                ;if is a double click
                if $CurClickedRow = $LastClickedRow Then
                    if $ScheduleListIds[$CurClickedRow] = 0 Then
                        ;function omitted
                    Else
                        ;function omitted
                    EndIf
                    ;update schedule
                    ;function omitted
                    ;update rentals
                    ;function omitted
                    ExitLoop
                Else
                    if $LastClickedRow <> 0 Then
                        ;set old row to white
                        GUICtrlSetBkColor($ScheduleList[$LastClickedRow][1], $ScheduleBoxColour)
                        GUICtrlSetBkColor($ScheduleList[$LastClickedRow][2], $ScheduleBoxColour)
                        GUICtrlSetBkColor($ScheduleList[$LastClickedRow][3], $ScheduleBoxColour)
                        GUICtrlSetBkColor($ScheduleList[$LastClickedRow][4], $ScheduleBoxColour)
                    EndIf
                    $LastHoverRow = 0
                    ;set new row to clicked
                    if $CurClickedRow <> 0 Then
                        GUICtrlSetBkColor($ScheduleList[$CurClickedRow][1], $ScheduleBoxClickedColour)
                        GUICtrlSetBkColor($ScheduleList[$CurClickedRow][2], $ScheduleBoxClickedColour)
                        GUICtrlSetBkColor($ScheduleList[$CurClickedRow][3], $ScheduleBoxClickedColour)
                        GUICtrlSetBkColor($ScheduleList[$CurClickedRow][4], $ScheduleBoxClickedColour)
                    EndIf
                    ;set last clicked row as current
                    $LastClickedRow = $CurClickedRow
                EndIf
            EndIf
        EndIf
        if $LastHoverRow <> $CurHoverRow Then
            ;set old row back to non highlighted Color
            if $LastHoverRow <> 0 Then
                if $LastHoverRow = $CurClickedRow Then
                    GUICtrlSetBkColor($ScheduleList[$LastHoverRow][1], $ScheduleBoxClickedColour)
                    GUICtrlSetBkColor($ScheduleList[$LastHoverRow][2], $ScheduleBoxClickedColour)
                    GUICtrlSetBkColor($ScheduleList[$LastHoverRow][3], $ScheduleBoxClickedColour)
                    GUICtrlSetBkColor($ScheduleList[$LastHoverRow][4], $ScheduleBoxClickedColour)
                Else
                    GUICtrlSetBkColor($ScheduleList[$LastHoverRow][1], $ScheduleBoxColour)
                    GUICtrlSetBkColor($ScheduleList[$LastHoverRow][2], $ScheduleBoxColour)
                    GUICtrlSetBkColor($ScheduleList[$LastHoverRow][3], $ScheduleBoxColour)
                    GUICtrlSetBkColor($ScheduleList[$LastHoverRow][4], $ScheduleBoxColour)
                EndIf
            EndIf
            ;set new row to highlighted
            if $CurHoverRow <> 0 Then
                GUICtrlSetBkColor($ScheduleList[$CurHoverRow][1], $ScheduleBoxHighlightColour)
                GUICtrlSetBkColor($ScheduleList[$CurHoverRow][2], $ScheduleBoxHighlightColour)
                GUICtrlSetBkColor($ScheduleList[$CurHoverRow][3], $ScheduleBoxHighlightColour)
                GUICtrlSetBkColor($ScheduleList[$CurHoverRow][4], $ScheduleBoxHighlightColour)
            EndIf
            ;update last hover row
            $LastHoverRow = $CurHoverRow
        EndIf
    Next
wend
Edited by ame1011

[font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]

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