Sign in to follow this  
Followers 0
mdwerne

Set the color of inline variables?

9 posts in this topic

Hello,

I was wondering if there was a way to set the color of a variable so that wherever in my GUI I put that variable, it was that color. In the example below, I'd like to set $BitNess to be red no matter where in the GUI I place it. Possible without stacking the GUICtrlCreateLabel tags? Hopefully my ramblings make sense.

For example:

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=net.ico
#AutoIt3Wrapper_Outfile=Installer.exe
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include
#include
Global $gui, $guiPos, $pic, $picPos

$CurrentOS = _GetOSVersion()

InstallerGUI()

Func _GetOSVersion()
Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Local $colSettings = $objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For $objOperatingSystem In $colSettings
Return "Windows " & StringMid($objOperatingSystem.Caption, 19)
Next
EndFunc ;==>_GetOSVersion

Func InstallerGUI()
Local $n, $msg
GUICreate("Installer", 300, 200, -1, -1)

$n = GUICtrlCreatePic("Installer.bmp", 0, 0, 300, 200, $WS_EX_TRANSPARENT)

If @OSArch = "X86" Then
$BitNess = "32bit"
GUICtrlSetColor(-1, 0xff0000) ;I realize this is bad code. This is what I'm after without stacking GUICtrlCreateLabel tags on the same line.
ElseIf @OSArch = "X64" Then
$BitNess = "64bit"
GUICtrlSetColor(-1, 0xff0000) ;I realize this is bad code. This is what I'm after without stacking GUICtrlCreateLabel tags on the same line.
EndIf

GUICtrlCreateGroup("", 10, 5, 280, 95)
GUICtrlCreateLabel("OS Detected: " & $CurrentOS & " " & $BitNess, 20, 20, 200, 25)
GUICtrlCreateLabel("Program " & $BitNess & " will be installed", 20, 40, 200, 25)

$bContinue = GUICtrlCreateButton("Continue", 60, 63, 75)
$bCancel = GUICtrlCreateButton("Cancel", 170, 63, 75)
GUISetState()

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop

Case $msg = $bCancel
ExitLoop

Case $msg = $bContinue
GUISetState(@SW_HIDE)
MsgBox(0, 'Testing', 'Installer)
ExitLoop
EndSelect
WEnd

GUIDelete()
EndFunc ;==>InstallerGUI

I did search the help and the forums and the web, maybe my internal search engine is broken, but I could not find what I'm after.

Thanks for any suggestions,

-Mike

Share this post


Link to post
Share on other sites



You do not set the color of a variable, you set the color of a control (text color, background color ...).

Have a look at the example script of function GUICtrlSetColor.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks for the quick reply water. And thanks for the clarification of what actually gets set. I've used GUICtrlSetColor before for an entire line, but the only way to do what I'm after is by using GUICtrlSetColor in the following way:

GUICtrlCreateLabel("Black text", 10, 20)
GUICtrlCreateLabel($BitNess,40, 20)
GUICtrlSetColor(-1, 0xff0000) ; Red
GUICtrlCreateLabel("more Black text", 70, 20)

This is what I was talking about when I mentioned stacking GUICtrlCreateLabel tags on the same line. Doing it this method I can never get the text spacing on the line correct between different machines...so sometimes $BitNess is closer to the text, sometimes it's further. I apologize if I'm further confusing the issue. Hope this post helped.

-Mike

Edited by mdwerne

Share this post


Link to post
Share on other sites

If I understand you correctly you would like to create ONE label control and mark a word in the text of the Control in a different color like: "Your OS runs 64 bit more black text"


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

If I understand you correctly you would like to create ONE label control and mark a word in the text of the Control in a different color like: "Your OS runs 64 bit more black text"

That is correct, the only caveat being that the one word may show up multiple times and in multiple locations in the same GUI (different tabs, different lines, etc...).

-Mike

Share this post


Link to post
Share on other sites

Maybe helps. Haven't tested or used it myself.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Maybe helps. Haven't tested or used it myself.

On the surface this looks to be exactly what I'm after!

I'd love to know what you typed in the search to find this...or if you just rememberred it from MrCreatoR's original post.

Thank you for the help and for being my search engine... :>

-Mike

Edited by mdwerne

Share this post


Link to post
Share on other sites

IIRC I was looking for "label set color text". The link I posted was near the end of result page 1.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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