Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Static Text not taking background color
#1
Hi Gintaras,
I am having a frustrating problem.
I would like various static text objects to take the background color of the dialog. It works very well in this simple example (based on Dialog_fon_sample but with the addition of the GdiObject for the dialog color.

Function Dialog_font_sample
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;Shows how to set fonts and colors.
GdiObject- CustomColor =CreateSolidBrush(ColorFromRGB(70 130 180))


;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 173 99 "Dialog Fonts"
;4 Static 0x54000000 0x4 6 6 48 14 "Text"
;1 Button 0x54030001 0x4 4 82 48 14 "OK"
;2 Button 0x54030000 0x4 56 82 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030208 "*" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,__Font-- f
,f.Create("Courier New" 14 1)
,f.SetDialogFont(hDlg "4")
,f.SetDialogFontColor(hDlg 0x0 "4")

,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_CTLCOLORDLG ret CustomColor ;;and this
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

But when I apply it to a much more complex dialog, the static texts don't take the background color. I have checked that all their def's are the same (0x54000000 0x4).
I even tried

Code:
Copy      Help
,case WM_CTLCOLORSTATIC
,,GdiObject- LtBlue=SetBkColor(wParam ColorFromRGB(70 130 180))
,,ret LtBlue

But it worked for only 1 of the many static texts...so strange in that there was nothing different about that one item. Also strange behavior in that it only applied to the background where there was text but if the size of the element went beyond the text, it didn't get the color.
I hope I have explained well enough. I can send images but I hope this suggests an easy answer.
Stuart
#2
I would need a dialog that has this problem.

----------------

Try this code. Delete f.SetDialogFontColor(...).
Function Dialog_font_sample4
Code:
Copy      Help
,case WM_CTLCOLORSTATIC
,SetBkMode wParam TRANSPARENT
,SetTextColor wParam 0xff ;;red text
,ret GetStockObject(NULL_BRUSH) ;;transparent brush
#3
thanks!!! will be able to test in a few hours.
will let you know
S


Forum Jump:


Users browsing this thread: 1 Guest(s)