Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DT_SetTextColor problem
#1
there seems to be a bug in DT_SetTextColor if u put a static text on top of another control the static control background takes the background of the dialog.
In general i am getting strange behavior from static text controls.
example
Function Dialog6
Code:
Select All      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages


;BEGIN DIALOG
;0 "" 0x90CB0AC8 0x0 0 0 223 135 "Dialog"
;3 Static 0x54000081 0x20 24 62 46 12 "Text1"
;4 Static 0x50000101 0x100020 78 28 48 13 "Text2"
;5 msctls_progress32 0x54030000 0x0 56 28 100 13 ""
;6 ListBox 0x54230101 0x200 0 44 96 48 ""
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030407 "" "" "" ""
if(!ShowDialog("Dialog6" &Dialog6)) ret
ret
;messages
sel message
,case WM_INITDIALOG
,/DT_SetBackgroundColor2(hDlg 0 0xFFFFFF)
,DT_SetTextColor(hDlg 0x0000FF "4")
,DT_SetTextColor(hDlg 0xFF0000 "3")
,case WM_CTLCOLORSTATIC    
,sel GetWinId(lParam)
,,case 3
,,SetBkMode wParam TRANSPARENT
,,ret GetStockObject(NULL_BRUSH) ;;transparent brush
,sel GetWinId(lParam)
,,case 4
,,SetBkMode wParam TRANSPARENT
,,ret GetStockObject(NULL_BRUSH) ;;transparent brush            
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1


Attached Files Image(s)
   
Reply
#2
If DT_SetTextColor used, dialog procedure does not receive WM_CTLCOLORSTATIC messages. Don't remember why, probably there is a reason.
If you need WM_CTLCOLORSTATIC and text color, don't use DT_SetTextColor. It's easy to set color on WM_CTLCOLORSTATIC with SetTextColor.

Function Dialog610
Code:
Select All      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages


;BEGIN DIALOG
;0 "" 0x90CB0AC8 0x0 0 0 223 135 "Dialog"
;3 Static 0x54000081 0x20 24 62 46 12 "Text1"
;4 Static 0x50000101 0x100020 78 28 48 13 "Text2"
;5 msctls_progress32 0x54030000 0x0 56 28 100 13 ""
;6 ListBox 0x54230101 0x200 0 44 96 48 ""
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030407 "" "" "" ""
if(!ShowDialog("" &Dialog610)) ret
ret
;messages
sel message
,case WM_INITDIALOG
,/DT_SetBackgroundColor2(hDlg 0 0xFFFFFF)
,;DT_SetTextColor(hDlg 0x0000FF "4")
,;DT_SetTextColor(hDlg 0xFF0000 "3")
,
,case WM_CTLCOLORSTATIC
,int cid col
,cid=GetWinId(lParam)
,sel cid
,,case [3,4]
,,sel cid
,,,case 3 col=0xFF0000
,,,case 4 col=0x0000FF
,,SetTextColor wParam col
,,SetBkMode wParam TRANSPARENT
,,ret GetStockObject(NULL_BRUSH) ;;transparent brush
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
Reply
#3
yes i know how to do it that way but then i am faced with other issues of the static control if i change the text .was looking for a way to have a transparent static background and not have to hide then show the control to change the text or invalidate it.
Reply
#4
If DT_SetTextColor used, QM private dialog functions on WM_CTLCOLORxx have to return a brush, therefore they don't call your dialog procedure.

Without DT_SetTextColor, after changing control text probably need to call InvalidateRect hDlg 0 1. It redraws the dialog.
Or you can draw text with text API, eg DrawTextEx. Not so easy. Need to subclass controls and draw text on WM_PAINT. Then don't need static controls.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)