Jump to content

Change text in list box to bold/italic on the fly


archrival
 Share

Recommended Posts

Is it possible to have on item in a listbox be bold and the next not and the next 3 bold? I have a script that returns the status of services on a remote machine, I've split the resulting text into 3 separate arrays. What I'd like to do is check if the service is running then make that line of text bold, but the next item could be normal or bold depending on the status of the service. I've tried GuiCtrlSetFont and GuiSetFont, they both seem to set the font type for the entire list box. Any suggestions? I would prefer to continue using the listbox, I could probably used another GUI type and display the status of the service somewhere else. Looking at the listbox and having Bold text obviously is the easiest way to determine if the service is running or not.

Here's a snippet of what I've got:

For $i = 1 to ($lines[0] - 1)
   $service1occur[$i] = StringInStr($lines[$i], " : ", "", 1)
   $service2occur[$i] = StringInStr($lines[$i], " : ", "", 2)
   $servicerealname[$i] = StringLeft($lines[$i], ($service1occur[$i] - 1))
   $servicename[$i] = StringMid($lines[$i], ($service1occur[$i] + 3), ($service2occur[$i] - $service1occur[$i] - 3))
   $servicestatus[$i] = StringTrimLeft($lines[$i], $service2occur[$i] + 2)
   GUICtrlSetData($combo, $servicerealname[$i],"|")
   If $servicestatus[$i] = "Running" Then
      GUICtrlSetFont($combo, 9, 800)
   EndIf
   If $servicestatus[$i] = "Stopped" Then
      GUICtrlSetFont($combo, 9, 400)
   EndIf
Next
Link to comment
Share on other sites

Here's a sample of what I'm talking about. I would like the lines representing a running service to be bold while stopped services are not and paused services are in italics. Now I have labels that change depending on the status. It works, not what I want.

http://www.autoitscript.com/fileman/users/public/archrival/nobold.png

Link to comment
Share on other sites

Looks very nice, but what I meant is a 'real' Windows-program so I can study it how this could be made :idiot:

<{POST_SNAPBACK}>

Sorry, I can't think of one off of the top of my head. I'm sure some program that implements this exists though. It's not that big of a deal, I know I'm trying to re-invent the wheel with what I'm doing, since another free program, Advanced Remote Info already exists that implements what I'm trying to do (remote domain pc management and info). It seems to be very buggy though. I'm only doing this for my own knowledge and experience. Since I've had to write some vbscripts to accomplish this anyway, it seems as though AutoIt has become basically just a GUI in this project. I would love to be able to use autoit for everything I'm trying to do. Someday I'm sure I will be able to.
Link to comment
Share on other sites

Guest lucindrea

um if your trying to stop and start a service on another machine .. as long as the client and host are both w2k or xp , use mmc .. no reasion to write up an entire app for viewing the status of another machine when it's allready part of the os.

Link to comment
Share on other sites

um if your trying to stop and start a service on another machine .. as long as the client and host are both w2k or xp , use mmc .. no reasion to write up an entire app for viewing the status of another machine when it's allready part of the os.

<{POST_SNAPBACK}>

Firstly, I know this. That's not the only thing I'm doing, just a small part of it. My final goal is to create something like Advanced Remote Info. It seems very buggy to me though but that's not even my reasoning for doing this. It's more or less for my personal use and gain, no one elses. Secondly, no need to be rude about it. It's a good thing people don't create other text editors because notepad exists in the OS, or explorer replacements, web browsers, etc...
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...