AHK Gui, readonly edit, white background?
Posted: 23 Feb 2014, 10:32
How to create a readonly gui edit control with a white background? When I use the readonly option the background goes grey. Thanks.
Let's help each other out
https://www.autohotkey.com/boards/
Code: Select all
#SingleInstance Force
BG_COLOR := 0x995522
FG_COLOR := 0xFAFAFA
OnMessage( 0x138, "WM_CTLCOLOR" ), OnMessage( 0x133, "WM_CTLCOLOR" )
Gui, Add, Edit, w100, ReadWrite
Gui, Add, Edit, w100 ReadOnly, ReadOnly
Gui, Add, Edit, w100, ReadWrite
Gui, Add, Edit, w100 ReadOnly, ReadOnly
Gui, Show
Gui +LastFound
WinSet, Redraw
Return ; // end of auto-execute section //
WM_CTLCOLOR(wParam, lParam, msg, hwnd)
{
static hBrush := ""
if (hBrush = "")
{
SetEnv, hBrush, % DllCall("Gdi32.dll\CreateSolidBrush", "UInt", BG_COLOR)
}
WinGetClass, Class, ahk_id %lParam%
if (Class = "Edit")
{
DllCall("Gdi32.dll\SetTextColor", "UInt", wParam, "UInt", FG_COLOR)
DllCall("Gdi32.dll\SetBkColor", "UInt", wParam, "UInt", BG_COLOR)
DllCall("Gdi32.dll\SetBkMode", "UInt", wParam, "UInt", 2)
return hBrush
}
if (Class = "Static")
{
DllCall("Gdi32.dll\SetTextColor", "UInt", wParam, "UInt", FG_COLOR)
}
}
Code: Select all
Gui, Add, Edit, w200, Normal Edit
hEdit1 := Gui_Add_Edit("w200 h200 cRed ReadOnly", "ReadOnly Edit", "Yellow")
hEdit2 := Gui_Add_Edit("wp-52 c00ff00", "Edit 3", "Black")
Gui, Add, Button, x+5 hp, Modify
Gui, Show
Return
ButtonModify:
ControlSetText,, NewText, ahk_id %hEdit2%
Return
GuiClose:
ExitApp
Gui_Add_Edit(Options = "", Text = "", bkColor = "")
{
Gui, Add, Edit, %Options% hwndhwnd -E0x200 -Multi, %Text%
GuiControlGet, ctrl, pos, %hwnd%
GuiHwnd := DllCall("GetParent", "UInt", hwnd)
Gui, New, -Caption +Parent%hwnd%
if (bkColor != "")
Gui, Color, %bkColor%, %bkColor%
Gui, Margin, 0, 0
Gui, Add, Edit, %Options% w%ctrlW% h%ctrlH% x0 y0 hwndhEdit, %Text%
Gui, Show, x0 y0
Gui, %GuiHwnd%:Default
Return hEdit
}
---------------------------
CtlColors_sample.ahk
---------------------------
Error at line 2.
#Include file "Class_CtlColors.ahk" cannot be opened.
The program will exit.
---------------------------
OK
---------------------------