InunoTaishou

Setting color of richedit

14 posts in this topic

I know how to select, set color, then deselect but I'm trying to get more of a Microsoft word style richedit.

In word you can Highlight and change color, it only changes color of highlighted text, or you can change the color and it changes the color the text after the caret position.

Just doing _GUICtrlRichEdit_SetCharColor($hRichEdit, $color) changes the color for all of the text in the richedit and I'm trying to avoid that.

Is this possible?

Share this post


Link to post
Share on other sites



Which version of AutoIt you are using ?

in the current 3.3.14.2 you should first select text and then use  _GUICtrlRichEdit_SetCharColor($hRichEdit, $color)

 

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

I can use _GUICtrlRichEdit_SetSel($hRichEdit, $iAnchor, $iActive) to set that specific text but I'm trying to make it so that when I set the char color, all characters after the current point is the color and nothing in front of it is changed.

I'm trying to avoid checking the RichEdit control to see if the length has changed and selecting then changing the color

Share this post


Link to post
Share on other sites

Well I guess I just needed a couple of hours of tinkering away and it and going back to one of my old projects.

The solution is to use _SendMessage

Local $tCharFormat = DllStructCreate($tagCHARFORMAT)
        
        DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat))
        DllStructSetData($tCharFormat, 2, $CFM_COLOR)
        DllStructSetData($tCharFormat, 6, _ColorSetCOLORREF(_ColorGetRGB("0x" & Hex($selected_color, 6))))
        
        _SendMessage($rtfEdit, $EM_SETCHARFORMAT, $SCF_SELECTION, DllStructGetPtr($tCharFormat))

And here's an example of how to use it.

#include <GuiRichEdit.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Color.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>

AutoItSetOption("GuiOnEventMode", 1)

Global $frmMain = GUICreate("RichEdit Example", 580, 400)
Global $frmColorSelector = CreateColorSelector()
Global $rtfEdit = _GUICtrlRichEdit_Create($frmMain, "Default Black Text", 0, 0, 580, 400, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))

GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $frmMain)

GUISetState(@SW_SHOW, $frmMain)
GUISetState(@SW_SHOW, $frmColorSelector)

While (1)
    Sleep(100)
Wend

Func Close()
    GUIDelete($frmColorSelector)
    GUIDelete($frmMain)
    
    Exit(0)
EndFunc

Func CreateColorSelector()
Local $hWnd_gui = GUICreate("Text color",116,93, 18,20,$WS_POPUP+$WS_BORDER,$WS_EX_MDICHILD,$frmMain)
GUICtrlCreateLabel("",2,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x000000")
GUICtrlCreateLabel("",2,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x800000")
GUICtrlCreateLabel("",2,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF0000")
GUICtrlCreateLabel("",2,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF00FF")
GUICtrlCreateLabel("",2,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF99CC")
GUICtrlCreateLabel("",16,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x993300")
GUICtrlCreateLabel("",16,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF6600")
GUICtrlCreateLabel("",16,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF9900")
GUICtrlCreateLabel("",16,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFFCC00")
GUICtrlCreateLabel("",16,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFFCC99")
GUICtrlCreateLabel("",30,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x333300")
GUICtrlCreateLabel("",30,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x808000")
GUICtrlCreateLabel("",30,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x99CC00")
GUICtrlCreateLabel("",30,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFFFF00")
GUICtrlCreateLabel("",30,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFFFF99")
GUICtrlCreateLabel("",44,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x003300")
GUICtrlCreateLabel("",44,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x008000")
GUICtrlCreateLabel("",44,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x339966")
GUICtrlCreateLabel("",44,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x00FF00")
GUICtrlCreateLabel("",44,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xCCFFCC")
GUICtrlCreateLabel("",58,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x003366")
GUICtrlCreateLabel("",58,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x008080")
GUICtrlCreateLabel("",58,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x33CCCC")
GUICtrlCreateLabel("",58,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x00FFFF")
GUICtrlCreateLabel("",58,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xCCFFFF")
GUICtrlCreateLabel("",72,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x000080")
GUICtrlCreateLabel("",72,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x0000FF")
GUICtrlCreateLabel("",72,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x3366FF")
GUICtrlCreateLabel("",72,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x00CCFF")
GUICtrlCreateLabel("",72,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x99CCFF")
GUICtrlCreateLabel("",86,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x333399")
GUICtrlCreateLabel("",86,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x666699")
GUICtrlCreateLabel("",86,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x800080")
GUICtrlCreateLabel("",86,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x993366")
GUICtrlCreateLabel("",86,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xCC99FF")
GUICtrlCreateLabel("",100,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x333333")
GUICtrlCreateLabel("",100,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x808080")
GUICtrlCreateLabel("",100,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x999999")
GUICtrlCreateLabel("",100,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xC0C0C0")
GUICtrlCreateLabel("",100,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlCreateLabel("Drag", 0, 72, 116, 20, -1, BitOR($WS_EX_TRANSPARENT, $GUI_WS_EX_PARENTDRAG))
Return $hWnd_gui
EndFunc

Func SetColor()
    Local $selected_color = GUICtrlGetBkColor(@GUI_CtrlId)
    
    If ($selected_color > -1) Then
        Local $tCharFormat = DllStructCreate($tagCHARFORMAT)
        
        DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat))
        DllStructSetData($tCharFormat, 2, $CFM_COLOR)
        DllStructSetData($tCharFormat, 6, _ColorSetCOLORREF(_ColorGetRGB("0x" & Hex($selected_color, 6))))
        
        _SendMessage($rtfEdit, $EM_SETCHARFORMAT, $SCF_SELECTION, DllStructGetPtr($tCharFormat))
    EndIf
    
    _WinAPI_SetFocus($rtfEdit)
EndFunc   ;==>SetColor

Func GUICtrlGetBkColor($iControlID)
    Local $hHandle = GUICtrlGetHandle($iControlID)
    Local $hDC = _WinAPI_GetDC($hHandle)
    Local $bGetBkColor = _WinAPI_GetPixel($hDC, 2, 2)
    
    Return $bGetBkColor
EndFunc ;==>GUICtrlGetBkColor

 

Share this post


Link to post
Share on other sites

Which version of AutoIt you are using ?

You did not answer.
This is important, as in the last relaese there were changes.


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

3.3.12.0

Share this post


Link to post
Share on other sites

Amazing, looks look in 3.3.14 it did exactly what I needed.

Spent 3 hours trying to get this to work, could have just updated and had it fixed in 15 seconds.

Share this post


Link to post
Share on other sites

I told you 2 hours ago :)

 

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

I was deep in code lol

Thanks for the help!

Share this post


Link to post
Share on other sites

Since we're talking about rich edit...

Whenever I do _GUICtrlRichEdit_StreamToFile or _GUICtrlRichEdit_StreamFromFile (Idk which is doing it) it will append an extra line to the RichEdit. Any particular reason why? I'm not using any extra parameters other than the handle and the file

Share this post


Link to post
Share on other sites

Make a repro snippet, to show what you mean.

btw.
Cool idea with this draging color palette.


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Same example as the one above except I added

_GUICtrlRichEdit_StreamFromFile($rtfEdit, @ScriptDir & "\Edit.rtf")

Right after creating the RichEdit and

_GUICtrlRichEdit_StreamToFile($rtfEdit, @ScriptDir & "\Edit.rtf")

Right before deleting the GUI

Opening and closing it constantly adds an extra new line to the end. I don't know if it's coming from StreamFromFile or StreamToFile

#include <GuiRichEdit.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Color.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>

AutoItSetOption("GuiOnEventMode", 1)

Global $frmMain = GUICreate("RichEdit Example", 580, 400)
Global $frmColorSelector = CreateColorSelector()
Global $rtfEdit = _GUICtrlRichEdit_Create($frmMain, "Default Black Text", 0, 0, 580, 400, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
_GUICtrlRichEdit_StreamFromFile($rtfEdit, @ScriptDir & "\Edit.rtf")

GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $frmMain)

GUISetState(@SW_SHOW, $frmMain)
GUISetState(@SW_SHOW, $frmColorSelector)

While (1)
    Sleep(100)
Wend

Func Close()
    _GUICtrlRichEdit_StreamToFile($rtfEdit, @ScriptDir & "\Edit.rtf")
    GUIDelete($frmColorSelector)
    GUIDelete($frmMain)
    
    Exit(0)
EndFunc

Func CreateColorSelector()
Local $hWnd_gui = GUICreate("Text color",116,93, 18,20,$WS_POPUP+$WS_BORDER,$WS_EX_MDICHILD,$frmMain)
GUICtrlCreateLabel("",2,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x000000")
GUICtrlCreateLabel("",2,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x800000")
GUICtrlCreateLabel("",2,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF0000")
GUICtrlCreateLabel("",2,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF00FF")
GUICtrlCreateLabel("",2,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF99CC")
GUICtrlCreateLabel("",16,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x993300")
GUICtrlCreateLabel("",16,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF6600")
GUICtrlCreateLabel("",16,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF9900")
GUICtrlCreateLabel("",16,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFFCC00")
GUICtrlCreateLabel("",16,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFFCC99")
GUICtrlCreateLabel("",30,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x333300")
GUICtrlCreateLabel("",30,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x808000")
GUICtrlCreateLabel("",30,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x99CC00")
GUICtrlCreateLabel("",30,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFFFF00")
GUICtrlCreateLabel("",30,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFFFF99")
GUICtrlCreateLabel("",44,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x003300")
GUICtrlCreateLabel("",44,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x008000")
GUICtrlCreateLabel("",44,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x339966")
GUICtrlCreateLabel("",44,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x00FF00")
GUICtrlCreateLabel("",44,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xCCFFCC")
GUICtrlCreateLabel("",58,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x003366")
GUICtrlCreateLabel("",58,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x008080")
GUICtrlCreateLabel("",58,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x33CCCC")
GUICtrlCreateLabel("",58,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x00FFFF")
GUICtrlCreateLabel("",58,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xCCFFFF")
GUICtrlCreateLabel("",72,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x000080")
GUICtrlCreateLabel("",72,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x0000FF")
GUICtrlCreateLabel("",72,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x3366FF")
GUICtrlCreateLabel("",72,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x00CCFF")
GUICtrlCreateLabel("",72,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x99CCFF")
GUICtrlCreateLabel("",86,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x333399")
GUICtrlCreateLabel("",86,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x666699")
GUICtrlCreateLabel("",86,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x800080")
GUICtrlCreateLabel("",86,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x993366")
GUICtrlCreateLabel("",86,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xCC99FF")
GUICtrlCreateLabel("",100,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x333333")
GUICtrlCreateLabel("",100,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x808080")
GUICtrlCreateLabel("",100,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x999999")
GUICtrlCreateLabel("",100,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xC0C0C0")
GUICtrlCreateLabel("",100,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlCreateLabel("Drag", 0, 72, 116, 20, -1, BitOR($WS_EX_TRANSPARENT, $GUI_WS_EX_PARENTDRAG))
Return $hWnd_gui
EndFunc

Func SetColor()
    Local $selected_color = GUICtrlGetBkColor(@GUI_CtrlId)
    
    If ($selected_color > -1) Then
        Local $tCharFormat = DllStructCreate($tagCHARFORMAT)
        
        DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat))
        DllStructSetData($tCharFormat, 2, $CFM_COLOR)
        DllStructSetData($tCharFormat, 6, _ColorSetCOLORREF(_ColorGetRGB("0x" & Hex($selected_color, 6))))
        _SendMessage($rtfEdit, $EM_SETCHARFORMAT, $SCF_SELECTION, DllStructGetPtr($tCharFormat))
    EndIf
    
    _WinAPI_SetFocus($rtfEdit)
EndFunc   ;==>SetColor

Func GUICtrlGetBkColor($iControlID)
    Local $hHandle = GUICtrlGetHandle($iControlID)
    Local $hDC = _WinAPI_GetDC($hHandle)
    Local $bGetBkColor = _WinAPI_GetPixel($hDC, 2, 2)
    
    Return $bGetBkColor
EndFunc ;==>GUICtrlGetBkColor

 

Share this post


Link to post
Share on other sites

This was asked before:

Some other discussion over the internet:

http://codeverge.com/embarcadero.delphi.vcl.using/problem-with-trichedit-in-xe5-em/1079375

http://www.devsuperpage.com/search/Articles.aspx?G=2&ArtID=106552

I have no Idea why, first I can think this is internal MS Component behavior, but I'm not sure.


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Kind of annoying but I went ahead and just use StringReplace to replace the last instance of the \par. I guess it's StreamToFile (and StreamToVar) both append an extra new line.

StringReplace(_GUICtrlRichEdit_StreamToVar($rtfEdit, True), "\par", "", -1)

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

  • Similar Content

    • AndyS19
      By AndyS19
      I have a listview with 3 columns and I want to set the 3rd column's color based on the item's 'Param' value, but even though I set up for the 3rd column, the entire row always gets the color.
      My test code is below, but here is the pertinent code:
      Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam, $ilParam Local $hWndFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $iDrawStage, $tCustDraw $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $ilParam) $iDrawStage = DllStructGetData($tCustDraw, 'dwDrawStage') Switch $iDrawStage Case BitOR(0, $CDDS_ITEMPREPAINT) ;, $CDDS_SUBITEM) setItemColor($tCustDraw, $hWndFrom) Return $CDRF_NOTIFYSUBITEMDRAW EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func setItemColor($tCustDraw, $hWnd) Local $iIndex, $color, $iSubitem $iIndex = DllStructGetData($tCustDraw, 'dwItemSpec') ; item number $color = _GUICtrlListView_GetItemParam($hWnd, $iIndex) $iSubitem = DllStructGetData($tCustDraw, 'iSubItem') ; Here, I want to only change the color of the 3rd col, and not the 1st and 2nd cols DllStructSetData($tCustDraw, 'iSubItem', 2) ; always use the 3rd column (the 'sample' col) logmsg("+++: setItemColor($tCustDraw, 0x" & Hex($hWnd) & ") entered ... " _ & ", $iIndex = " & $iIndex & ", $iSubItem = " & $iSubitem & ", $color = " & Hex($color)) DllStructSetData($tCustDraw, 'clrText', $color) ; set the Text color DllStructSetData($tCustDraw, 'clrTextBk', bitnot($color)) ; set the background color EndFunc ;==>setItemColor Func logmsg($msg, $lnum = @ScriptLineNumber) ConsoleWrite("+++:" & $lnum & ": " & $msg & @CRLF) EndFunc ;==>logmsg
      Here is the full test code:
      #include-once ;#cs #NoTrayIcon #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_UseX64=N Opt("GUICloseOnESC", 1) ; ESC closes GUI? (0 = no, 1 = yes) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Opt('MustDeclareVars', 1) OnAutoItExitRegister("_test_exit") Opt("GUIEventOptions", 1) ;0=default, 1=just notification, 2=GuiCtrlRead tab index Opt("WinTitleMatchMode", -2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase #include <GuiListBox.au3> #include <ListViewConstants.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <ColorConstants.au3> Global $__MCP_obj, $__MCP_GUI_hWnd, $idListView, $hListView Global $hMainWin test() Exit Func test() $hMainWin = GUICreate("Test window", 120, 100, @DesktopWidth / 2, -1) GUICtrlCreateButton("Hwnd", 10, 10, 40, 20) GUICtrlSetOnEvent(-1, "handle_1stTEST_btn") GUICtrlCreateButton("ID", 50, 10, 40, 20) GUICtrlSetOnEvent(-1, "handle_2ndTEST_btn") GUISetOnEvent($GUI_EVENT_CLOSE, "_test_exit") GUISetState(@SW_SHOW) While (1) Sleep(17) WEnd EndFunc ;==>test Func _myColorPicker($obj) logmsg("+++: $obj = 0x" & Hex($obj) & @CRLF) Local $flags = 0 Local $ww, $wh, $x, $y, $w, $h $__MCP_obj = $obj $ww = 350 $wh = 500 $x = 200 $y = 150 $__MCP_GUI_hWnd = GUICreate("myColorPicker", $ww, $wh, $x, $y, $flags) $x = 10 $y = 10 $w = 150 $h = 20 GUICtrlCreateButton("Set caller's color", $x, $y, $w, $h) GUICtrlSetOnEvent(-1, "__MCP_handle_SetColor_btn") $y += $h + 5 $w = $ww - 25 $h = $wh - 100 $idListView = GUICtrlCreateListView("", $x, $y, $w, $h, -1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) $hListView = GUICtrlGetHandle($idListView) $x = $ww / 2 - 50 $y = $wh - 60 $w = 100 $h = 25 GUICtrlCreateButton("Quit Popup", $x, $y, $w, $h) GUICtrlSetOnEvent(-1, "__MCP_handle_QUIT_btn") GUICtrlSetFont($idListView, 8.5, -1, -1, "courier new") _GUICtrlListView_AddColumn($idListView, "Name", 100) _GUICtrlListView_AddColumn($idListView, "Value", 100) _GUICtrlListView_AddColumn($idListView, "Sample", 100) _GUICtrlListView_SetColumnWidth($idListView, 0, 100) _GUICtrlListView_SetColumnWidth($idListView, 1, 80) logmsg("+++: $idListView = " & $idListView) logmsg("+++: $hListView = 0x" & Hex($hListView)) __MCP_populateListView($hListView) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW, $__MCP_GUI_hWnd) EndFunc ;==>_myColorPicker Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam, $ilParam Local $hWndFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $iDrawStage, $tCustDraw $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $ilParam) $iDrawStage = DllStructGetData($tCustDraw, 'dwDrawStage') Switch $iDrawStage Case BitOR(0, $CDDS_ITEMPREPAINT) ;, $CDDS_SUBITEM) setItemColor($tCustDraw, $hWndFrom) Return $CDRF_NOTIFYSUBITEMDRAW EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func setItemColor($tCustDraw, $hWnd) Local $iIndex, $color, $iSubitem $iIndex = DllStructGetData($tCustDraw, 'dwItemSpec') ; item number $color = _GUICtrlListView_GetItemParam($hWnd, $iIndex) $iSubitem = DllStructGetData($tCustDraw, 'iSubItem') ; Here, I want to only change the color of the 3rd col, and not the 1st and 2nd cols DllStructSetData($tCustDraw, 'iSubItem', 2) ; always use the 3rd column (the 'sample' col) logmsg("+++: setItemColor($tCustDraw, 0x" & Hex($hWnd) & ") entered ... " _ & ", $iIndex = " & $iIndex & ", $iSubItem = " & $iSubitem & ", $color = " & Hex($color)) DllStructSetData($tCustDraw, 'clrText', $color) ; set the Text color DllStructSetData($tCustDraw, 'clrTextBk', bitnot($color)) ; set the background color EndFunc ;==>setItemColor Func logmsg($msg, $lnum = @ScriptLineNumber) ConsoleWrite("+++:" & $lnum & ": " & $msg & @CRLF) EndFunc ;==>logmsg Func __MCP_exit() GUIDelete($__MCP_GUI_hWnd) EndFunc ;==>__MCP_exit Func __MCP_handle_SetColor_btn() If (IsHWnd($__MCP_obj)) Then GUISetBkColor($COLOR_BLUE, $__MCP_obj) Else GUICtrlSetBkColor($__MCP_obj, $COLOR_BLUE) EndIf EndFunc ;==>__MCP_handle_SetColor_btn Func __MCP_populateListView($hWnd) Local $text, $parts, $iIndex Local Static $aItems[] = [ _ "BLACK | " & $CLR_BLACK & "|" & "", _ "BLUE | " & $CLR_BLUE & "|" & "", _ "RED | " & $CLR_RED & "|" & "", _ "WHITE | " & $CLR_WHITE & "|" & "", _ "YELLOW | " & $CLR_YELLOW & "|" & "" _ ] _GUICtrlListView_BeginUpdate($hWnd) _GUICtrlListView_DeleteAllItems($hWnd) For $ndx = 0 To UBound($aItems) - 1 $text = $aItems[$ndx] $parts = StringSplit($text, "|", 2) $parts[0] = StringStripWS($parts[0], 3) $parts[2] = StringStripWS($parts[2], 3) $iIndex = _GUICtrlListView_AddItem($hWnd, $parts[0], -1, $parts[1]) _GUICtrlListView_AddSubItem($hWnd, $iIndex, Hex($parts[1]), 1) _GUICtrlListView_AddSubItem($hWnd, $iIndex, $parts[0], 2) Next _GUICtrlListView_EndUpdate($hWnd) EndFunc ;==>__MCP_populateListView Func __MCP_handle_QUIT_btn() GUIDelete($__MCP_GUI_hWnd) EndFunc ;==>__MCP_handle_QUIT_btn Func handle_1stTEST_btn() _myColorPicker($hMainWin) EndFunc ;==>handle_1stTEST_btn Func handle_2ndTEST_btn() _myColorPicker(@GUI_CtrlId) EndFunc ;==>handle_2ndTEST_btn Func _test_exit() Exit EndFunc ;==>_test_exit  
    • astrionn
      By astrionn
      So I had this Idea of creating a tooltip which shows me my ping.
      That itself was made quickly and I thought too add a couple features.
      I want the tooltip background to be a different color depending on the ping. (good ping is green, medium ping is yellow,...)
      So how do I color in a tooltip? google brought me to this: 
       
      where in the comments I found this:
      $s = "LOW" ToolTip($s, 0, 0, "Battery Information");, $icon) $H_TOOLTIP1 = WinGetHandle($s) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $H_TOOLTIP1, "wstr", "", "wstr", "") DllCall("user32.dll", "int", "SendMessage", "hwnd", $H_TOOLTIP1, "int", 1043, "int", 2552550, "int", 0) Sleep(1000) Which I then used in my code with different color codes... Trial and Error brought me these that I wanted to use:
       
      The Problem is if I loop through my code it only sets the color for the 1st loop and then sticks to it.
      The real problem is tho that I don't exactly understand the dllcalls... And I guess that's why it isn't working
      So if someone would be so awesome to explain to me how they work, or at least can give me a list of these parameters then I would really appreciate that and learn something new
      Obviously a solution to my problem is awesome aswell ^^
      I run this under Windows 8.1
      There is my code in a paste.
      https://pastebin.com/q525f7mS
    • cosmos
      By cosmos
      I must be missing something but I can't seem to work out how to open the standard Windows Color dialog box?
      Basically the equivalent of InputBox but for colors (so that the user can select a color). I think there are some external UDFs for this, but are there any ways of doing it with included UDFs, standard AutoIt functions or interfacing with Windows directly?
      Usage info: I'm making a database-like program and there are Categories (which work similar to Tables), and the user will be able to select unique colors for Categories so when they display multiple Categories at once (like displaying multiple Tables with similar columns in one list ) they can easily differentiate the Categories at quick glance.
      Thanks!
    • chacoya121
      By chacoya121
      Local $count = 1 Local $x1= 100,$y1 = 100,$x2 = 110,$y2 = 110 $area = ($x2+$x1)*($y2+$y1) Local $array[$area][2] For $i = $x1 to $x2 Step 1 For $j = $y1 to $y2 Step 1 $color = PixelGetColor($i,$j) $scolor = Hex($color,6) $array[$count][2] = [$scolor,1] $position = _ArraySearch($array,$scolor,0,0,0,0,1) If $array[$position][0] = $scolor Then $array[$position][1] +=1 Else $count += 1 EndIf Next Next _ArrayDisplay($array) plz help adjust and shrink it down soo confusing playing with array
    • StMaSi
      By StMaSi
      Two questions...
      When presenting a form containing a richedit control, is there any way to make the displayed text, within said richedit control, non-selectable?
      In addition, is there any way to hide the vertical line cursor, within said richedit control?
      Thanx.