Jump to content

[Problem] ListView concrete Item font color


Hidix17
 Share

Recommended Posts

Hello!
I wrote this script and...

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>

$VERSION = "1.0"

$GUIWidth = 600
$GUIHeight = 350
$DefaultFontColor = 0xFFFFFF

Func _ConsoleWrite($sUser,$sMessage,$cColor=0xFFFFFF)
   GUICtrlSetColor($Console,$cColor)
   GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&"|"&$sUser&"|"&$sMessage,$Console)
   GUICtrlSetColor($Console,$DefaultFontColor)
EndFunc

#Region GUI
$Form = GUICreate("B;ah blah blah", $GUIWidth, $GUIHeight, -1, -1)
GUISetBkColor(0x111111)
$Console = GUICtrlCreateListView("|||", 0, 0, $GUIWidth, $GUIHeight-21, BitOR($GUI_SS_DEFAULT_LISTVIEW,$LVS_NOCOLUMNHEADER), 0)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 70)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 130)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 400)
GUICtrlSetBkColor(-1,0x222222)
GUICtrlSetColor(-1,$DefaultFontColor)
GUICtrlSetFont(-1,10,400,-1,"System")
$InputCommand = GUICtrlCreateInput("", 0, $GUIHeight-21, $GUIWIdth, 21)
GUISetState(@SW_SHOW)
#EndRegion

for $i=0 to 10 step 1
_ConsoleWrite("Color","I'm green until you scroll down...",0x00EE00)
_ConsoleWrite("Color","I'm yellow until you scroll down...",0xFFDD00)
Next


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

    EndSwitch
WEnd

...the problem appears when I scrolls down the ListView and the colors disappears.
Is anyone knows how to easy solve this problem?
Please help me!

Edited by Hidix17

CVlOH5y.png

Link to comment
Share on other sites

I don't think you are doing anything wrong. It appears to be a glitch with creating items that are out of the limits of the GUI. Try resizing the GUI height to 600 and you will see that your code works as expected.

Now try a simple WinMove and the font color of all lines goes to the default color you set. I don't know why it's doing this, but these are my observations.

Link to comment
Share on other sites

(Had some similar question)

Just added 1 line and now it works perfectly fine:

Func _ConsoleWrite($sUser,$sMessage,$cColor=0xFFFFFF)
   ;GUICtrlSetColor($Console,$cColor)
   GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&"|"&$sUser&"|"&$sMessage,$Console)
   GuiCtrlSetColor(-1,$cColor)
   ;GUICtrlSetColor($Console,$DefaultFontColor)
EndFunc



I think the colors have to be assigned to the ListViewItem, not the console itself, because the console is limited to actually what you see. So you either handle it like abberration stated with WinMove (to let AutoIT know when it was scrolled and to recolor everything again) or by simply using the code above.

Edited by draien
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...