March 28, 2024, 05:55:48 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Setting the colour for Unicode control

Started by Andy, August 09, 2018, 03:48:28 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

Fasecero kindly posted the answer to my last question on displaying Unicode characters in a control.

Now I can change the font, size, but I can't change it's colour.

SETCONTROLCOLOR doesn't work here.


$INCLUDE "windowssdk.inc"

CONST BUTTON_1 = 1
CONST BUTTON_2 = 2

WINDOW w1
OPENWINDOW w1,0,0,600,400,@MINBOX|@MAXBOX|@SIZE,NULL,"Simple Window",&w1_handler

CreateWindowW(L"STATIC", L"", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_CENTER, 10,93,550,40, w1.hwnd, BUTTON_1, GetModuleHandle(0), 0)
SetWindowTextW(GetDlgItem(w1.hwnd, BUTTON_1),StaticText(40,"Date"))
SETFONT w1,"Arial",26,400,0,button_1

CreateWindowW(L"STATIC", L"", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_CENTER, 10,193,550,40, w1.hwnd, BUTTON_2, GetModuleHandle(0), 0)
SetWindowTextW(GetDlgItem(w1.hwnd, BUTTON_2),StaticText(40,"Time"))
SETFONT w1,"Arial",26,400,0,button_2

'Doesn't Work!!!!!!!
SETCONTROLCOLOR w1,button_1,RGB(255,255,255),rgb(0,100,0)

' main loop
WAITUNTIL w1 = 0
END

' window procedure
SUB w1_handler
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW w1

CASE @IDCLOSEWINDOW
CLOSEWINDOW w1

CASE @IDCONTROL
SELECT @CONTROLID
CASE BUTTON_1
IF @NOTIFYCODE = 0
/*button clicked*/
MESSAGEBOX(W1,"Button click","hello",@MB_ICONINFORMATION | @MB_OK)
ENDIF
ENDSELECT
ENDSELECT
ENDSUB

SUB StaticText(INT textLen,string TextName), WSTRING
wstring text = L""
pointer p = &text + 0

   restore TimeText
   restore DateText

INT j, a
FOR j = 1 TO textLen

if TextName = "Time"
GETDATA TimeText,a
endif

if TextName = "Date"
GETDATA DateText,a
endif

*<char>p = a
p+=1
NEXT j

RETURN text
ENDSUB

DATABEGIN TimeText
DATA 169,3,193,3,177,3,0,0
DATAEND

DATABEGIN DateText
DATA  151,3,188,3,181,3,193,3,191,3,188,3,183,3,189,3,175,3,177,3,0,0
DATAEND


Is there another way to change the colour of one of these controls?

Thanks,
Andy.

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

The reason SETCONTROLCOLOR didn't work is because you create  buttons using an API.
The buttons, statics, and rgnbuttons in IWB are all custom drawn and have their own custom message handlers. Those and other controls use properties to store color info and the setcontrocolor command just changes those properties.

When you use that API  to create the the "button" you didn't  create an IWB compatible button. You created a window which isn't even an IWB fully compatible window. If it was the following code would have worked.

window temp
temp.hwnd=GetDlgItem(w1.hwnd, BUTTON_1)
SETWINDOWCOLOR(temp,rgb(0,100,0))

unless I missed something.

FYI
SUB SETWINDOWCOLOR(win as WINDOW,colr as UINT)
IF win <> 0
win.m_cWindow = colr
IF win.m_bAutoDraw
RECT win,0,0,GetSystemMetrics(0),GetSystemMetrics(1),colr,colr
ELSE
InvalidateRect(win.hWnd,0,1)
ENDIF
ENDIF
RETURN
ENDSUB


LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

fasecero

Good explanation. When creating something using winapi it will make many of the IWBASIC functions not compatible, thats the catch. However in this case I don't see any other solution for this issue. IWBASIC language is built over the winapi making it infinitely easier, however, at the same time, winapi is so huge which makes it virtually impossible to cover everything, and sometimes you have to relay on winapi stuff as a last resort.

To change the static text/backcolor you have to do it using winapi too, which is quite complicated but achievable. You need to subclass the window, process WM_CTLCOLORSTATIC message and return an HBRUSH with the desired color  :-\


' WHEN YOUR PROGRAM START
INT SUBCLASS_ID = 12345
INT backColor = RGB(255,255,255)
HBRUSH hBrush = CreateSolidBrush(backColor)
SetWindowSubclass(w1.hwnd, &MySubclassProc, SUBCLASS_ID, 0)

' WHEN YOUR PROGRAM ENDS
RemoveWindowSubclass(w1.hwnd, &MySubclassProc, SUBCLASS_ID)
DeleteObject(hBrush)

SUB MySubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
INT hDC
WINRECT rc

SELECT (uMsg)
CASE WM_CTLCOLORSTATIC ' painting static text & back
   hDC = wParam
   SetTextColor(hDC, RGB(100,107,134)) ' TEXT COLOR
   SetBkColor(hDC, backColor) ' HBRUSH BACK COLOR
   return hBrush
ENDSELECT

RETURN DefSubclassProc(hWnd, uMsg, wParam, lParam)
ENDSUB

Andy

Thanks guys,

That sure is getting complicated!

In my case, I think I'll just make some graphics (bitmaps) and load variations of them with different colours no to statics - much easier with the project I'm on at the moment.

Thanks,
Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

Hi,

Thought I would have another look at colours for Unicode controls.

So, my window is called w1, and the static I want to set the background colour for is called Tab1

How do I change the above code to work with Tab1?

Thanks,
Andy.
 
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

One way to do it is to modify your subclass routine something along these lines

SUB MySubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
INT hDC
WINRECT rc

SELECT (uMsg)
CASE WM_CTLCOLORSTATIC ' painting static text & back
   hDC = wParam  ' this is the handle to the control sending the message
                   /* leave the color of the first 2 controls as they were */
                   if (GetDlgItem(w1.hwnd,1)= hDC ) or (GetDlgItem(w1.hwnd,2)= hDC )
      SetTextColor(hDC, RGB(100,107,134)) ' TEXT COLOR
      SetBkColor(hDC, backColor) ' HBRUSH BACK COLOR
                  /* take care of Tab1 if it is a different color*/
                  else if (GetDlgItem(w1.hwnd,TAB1)= hDC )
      SetTextColor(hDC, RGB(255,0,0)) ' TEXT COLOR
      SetBkColor(hDC, backColor) ' HBRUSH BACK COLOR
                 endif
   return hBrush
ENDSELECT

RETURN DefSubclassProc(hWnd, uMsg, wParam, lParam)
ENDSUB
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

December 03, 2018, 05:57:56 AM #6 Last Edit: December 03, 2018, 06:00:44 AM by Andy
Thanks Larry,

Still getting some strange results as the code is also setting some other Unicode controls as well as Tab1.

My point here is this...

In total I have 4 tabs, Tab1,Tab2,Tab3,Tab4 (all Unicode static controls).

I know which tab the user clicked on.

When the user clicks on say tab 2, it turns to a green background, and all other tabs become / have a white background, so you can visually see which tab is "active".

For each of these tabs in the handler I have CASE Tab1 (or CASE Tab2 etc....)

So do I place

hEdit = GETCONTROLHANDLE(mainwindow,Tab1)
SetWindowSubclass(hEdit, &MySubclassProc, SUBCLASSID2, 0)


in each CASE Tab "x" section? (obviously replacing Tab1 with the correct Tab name)

And if I want to change the colour again, what do I do? unsubclass first, then subclass again with the new colour?

Any help is greatly appreciated!!!!

Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

fasecero

Sorry, a small detail easily overlooked.  hDC = wParam is the handle to the device context for the static control. lParam is the handle to the static control.

Andy

Thanks,

But still confused and getting nowhere!

This is what I have (a simple window with a mix of control types)

AUTODEFINE "off"

$include "windowssdk.inc"
$include "commctrl.inc"

INT subclassID2 = 12345
INT backColor = rgb(107,142,35)
HBRUSH hBrush = CreateSolidBrush(backColor)
window mainwin

CONST IDE_PRODUCT = 12
CONST IDS_RECNO = 37
CONST IDS_RECID = 35
CONST IDB_PREV = 30
CONST IDB_NEXT = 31
CONST IDB_UPDATE = 32
CONST IDB_NEW = 33
CONST IDB_DELETE = 34
CONST IDM_QUIT = 100
CONST IDM_NEW = 33
CONST IDM_UPDATE = 32
CONST IDM_DELETE = 34
const BUT_keyboard = 40
const combo = 50
const Tab1 = 60

OPENWINDOW mainwin,0,0,705,620,@CAPTION|@SYSMENU,0,"Unicode DB.",&mainhandler
floodfill mainwin,0,0,rgb(255,255,255)

CreateWindowW(L"EDIT", L"",WS_VISIBLE|WS_CHILD|SS_LEFT|0x200, 99,51,331,25, mainwin.hwnd, IDE_PRODUCT, GetModuleHandle(0), 0)

SETFONT mainwin,"Arial",12,400,0,IDE_PRODUCT
CONTROL mainwin,@STATIC,"Product",24,51,68,17,0x5000010B|0x200,23
SETFONT mainwin,"Arial",12,400,0,23
SETCONTROLCOLOR mainwin,23,rgb(0,0,0),RGB(255,255,255)

CONTROL mainwin,@BUTTON,"<<",99,90,70,25,0x50000000,IDB_PREV
CONTROL mainwin,@BUTTON,">>",178,90,70,25,0x50000000,IDB_NEXT
CONTROL mainwin,@STATIC,"Number of Records:",99,192,150,17,0x5000010B,36
CONTROL mainwin,@STATIC,"100",250,193,70,15,@CTEDITCENTER,IDS_RECNO
CONTROL mainwin,@STATIC,"Record ID:",99,162,70,17,0x5000010B,34
CONTROL mainwin,@STATIC,"1",175,162,70,17,@OPAQUE,IDS_RECID
CONTROL mainwin,@BUTTON,"Update",280,90,70,25,0x50000000,IDB_UPDATE
CONTROL mainwin,@BUTTON,"New",359,90,70,25,0x50000000,IDB_NEW

SETFONT mainwin,"Arial",12,400,0,34
SETFONT mainwin,"Arial",12,400,0,36
SETFONT mainwin,"Arial",12,400,0,IDS_RECNO
SETFONT mainwin,"Arial",12,400,0,IDS_RECID

SETCONTROLCOLOR mainwin,36,rgb(0,0,0),RGB(255,255,255)
SETCONTROLCOLOR mainwin,34,rgb(0,0,0),RGB(255,255,255)
SETCONTROLCOLOR mainwin,IDS_RECNO,rgb(0,0,0),RGB(255,255,255)
SETCONTROLCOLOR mainwin,IDS_RECID,rgb(0,0,0),RGB(255,255,255)

CreateWindowW(L"STATIC",L"1234",WS_VISIBLE|WS_CHILD|SS_CENTER|SS_NOTIFY|0x200,20,400,200,25,mainwin.hWnd,Tab1,GetModuleHandle(0),0)

'SETCONTROLCOLOR mainwin,Tab1,rgb(200,200,200),RGB(0,0,0)


'frontpen mainwin,rgb(107,142,35)
'BACKPEN mainwin, RGB(120,120,120)


SetWindowSubclass(mainwin.hwnd,&MySubclassProc,SUBCLASSID2,0)


WAITUNTIL mainwin = 0
END

'the main WINDOW message handler
SUB mainhandler(),INT
SELECT @MESSAGE
CASE @IDCLOSEWINDOW
         closewindow mainwin
         end

CASE @IDCREATE
CENTERWINDOW mainwin

CASE @IDCONTROL
SELECT @CONTROLID

ENDSELECT

ENDSELECT
RETURN 0
ENDSUB


SUB MySubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
if getcontrolhandle(mainwin,Tab1) = lParam
INT hDC
WINRECT rc
SELECT (uMsg)
CASE WM_CTLCOLORSTATIC ' painting static text & back
hDC = lParam  ' this is the handle to the control sending the message
if (GetDlgItem(mainwin.hwnd,Tab1)= hDC )
SetTextColor(hDC, rgb(0,0,0)) ' TEXT COLOR
SetBkColor(hDC, backColor) ' HBRUSH BACK COLOR
  endif
return hBrush
ENDSELECT
endif
   RETURN DefSubclassProc(hWnd, uMsg, wParam, lParam)
ENDSUB


Several things to note:

1. I have to use if getcontrolhandle(mainwin,Tab1) = lParam ....... endif in the MySubclassProc routine.

2. If I do not use point 1, some other controls (depending on their styles) will also be set with the same green colour.

3. Have tried Front pen, back pen etc... but doesn't work.

4. The text in Tab1 "1234" is black on white, I'm after white text on green - but just can't get the SetTextColor to respond.

Help please!

Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

Well,

Using Fasecero's code posted a while ago, I decided to create the Unicode static with this sub routine:

SUB UnicodeLabelCreate(window w, INT ctrlID, INT x, INT y, INT width, INT height, INT font, INT align)
INT dwStyles = WS_CHILD | WS_VISIBLE | ES_LEFT | align
INT hwndEDIT = CreateWindowExW(0, L"STATIC", NULL, dwStyles, x, y, width, height, w.hwnd, ctrlID, GetModuleHandle(0), NULL)
SendMessageW(hwndEDIT, WM_SETFONT, font, MAKELPARAM(TRUE,0) )
ENDSUB


It uses CreateWindowExW instead of CreateWindowW.

Now the SetTextColor works.

Thanks Fasecero!

I now have to work out how to change the colour to a different one....

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

Finally the solution - at least one of them.

This program has two green statics with white text.

When you click on any of the two statics, the text and background colour changes, click it again and it changes back.

Here is the code.



AUTODEFINE "off"

$include "windowssdk.inc"
$include "commctrl.inc"

'INT subclassID2 = 12345
'INT backColor = rgb(107,142,35)
'HBRUSH hBrush = CreateSolidBrush(backColor)


'------------------------------------------
' VARIBLES
'------------------------------------------

HFONT guiFont = 0
HFONT bigFont = 0
INT backColor = rgb(107,142,35)
HBRUSH hBrush = CreateSolidBrush(backColor)
INT SUBCLASSID2 = 12345
INT SUBCLASSID4 = 24678
int Toggle  = 1
int Toggle2 = 1
wstring DisplayText  = L""




window mainwin

CONST IDE_PRODUCT = 12
CONST IDS_RECNO = 37
CONST IDS_RECID = 35
CONST IDB_PREV = 30
CONST IDB_NEXT = 31
CONST IDB_UPDATE = 32
CONST IDB_NEW = 33
CONST IDB_DELETE = 34
CONST IDM_QUIT = 100
CONST IDM_NEW = 33
CONST IDM_UPDATE = 32
CONST IDM_DELETE = 34
const BUT_keyboard = 40
const combo = 50
const Tab1 = 60
const Tab2 = 61

OPENWINDOW mainwin,0,0,705,620,@CAPTION|@SYSMENU,0,"Unicode DB.",&mainhandler
floodfill mainwin,0,0,rgb(255,255,255)

CreateWindowW(L"EDIT", L"",WS_VISIBLE|WS_CHILD|SS_LEFT|0x200, 99,51,331,25, mainwin.hwnd, IDE_PRODUCT, GetModuleHandle(0), 0)

SETFONT mainwin,"Arial",12,400,0,IDE_PRODUCT
CONTROL mainwin,@STATIC,"Product",24,51,68,17,0x5000010B|0x200,23
SETFONT mainwin,"Arial",12,400,0,23
SETCONTROLCOLOR mainwin,23,rgb(0,0,0),RGB(255,255,255)

CONTROL mainwin,@BUTTON,"<<",99,90,70,25,0x50000000,IDB_PREV
CONTROL mainwin,@BUTTON,">>",178,90,70,25,0x50000000,IDB_NEXT
CONTROL mainwin,@STATIC,"Number of Records:",99,192,150,17,0x5000010B,36
CONTROL mainwin,@STATIC,"100",250,193,70,15,@CTEDITCENTER,IDS_RECNO
CONTROL mainwin,@STATIC,"Record ID:",99,162,70,17,0x5000010B,34
CONTROL mainwin,@STATIC,"1",175,162,70,17,@OPAQUE,IDS_RECID
CONTROL mainwin,@BUTTON,"Update",280,90,70,25,0x50000000,IDB_UPDATE
CONTROL mainwin,@BUTTON,"New",359,90,70,25,0x50000000,IDB_NEW

SETFONT mainwin,"Arial",12,400,0,34
SETFONT mainwin,"Arial",12,400,0,36
SETFONT mainwin,"Arial",12,400,0,IDS_RECNO
SETFONT mainwin,"Arial",12,400,0,IDS_RECID

SETCONTROLCOLOR mainwin,36,rgb(0,0,0),RGB(255,255,255)
SETCONTROLCOLOR mainwin,34,rgb(0,0,0),RGB(255,255,255)
SETCONTROLCOLOR mainwin,IDS_RECNO,rgb(0,0,0),RGB(255,255,255)
SETCONTROLCOLOR mainwin,IDS_RECID,rgb(0,0,0),RGB(255,255,255)

SetWindowSubclass(mainwin.hwnd, &GreenSubclassProc, SUBCLASSID2, 0)

UnicodeLabelCreate(mainwin, Tab1,20, 400, 200, 25, guiFont, SS_CENTER|0x200|SS_NOTIFY)
UnicodeControlSetText(mainwin, Tab1, L"1234")

UnicodeLabelCreate(mainwin, Tab2,20, 440, 200, 25, guiFont, SS_CENTER|0x200|SS_NOTIFY)
UnicodeControlSetText(mainwin, Tab2, L"5678")

WAITUNTIL mainwin = 0
END

'the main WINDOW message handler
SUB mainhandler(),INT
SELECT @MESSAGE
CASE @IDCLOSEWINDOW
RemoveWindowSubclass(mainwin.hwnd, &GreenSubclassProc, SUBCLASSID2)
RemoveWindowSubclass(mainwin.hwnd, &PurpleSubclassProc, SUBCLASSID4)
DeleteObject(hBrush)
         closewindow mainwin
         end

CASE @IDCREATE
CENTERWINDOW mainwin
         DoInit()

CASE @IDCONTROL
SELECT @CONTROLID

            case Tab1
                 if @NOTIFYCODE=0

                    if Toggle = 1
                       Toggle = 2
                    else
                       Toggle = 1
                    endif

if Toggle = 1
DisplayText  = L""
GetWindowTextW(GetDlgItem(mainwin.hwnd,Tab1),DisplayText,512)

                        DestroyWindow(getcontrolhandle(mainwin,Tab1))
                        RemoveWindowSubclass(mainwin.hwnd, &PurpleSubclassProc, SUBCLASSID4)
backColor = rgb(107,142,35)
                        DeleteObject(hBrush)
hBrush = CreateSolidBrush(backColor)
SetWindowSubclass(mainwin.hwnd, &GreenSubclassProc, SUBCLASSID2, 0)
UnicodeLabelCreate(mainwin, Tab1,20, 400, 200, 25, guiFont, SS_CENTER|0x200|SS_NOTIFY)
                        SetWindowTextW(GetDlgItem(mainwin.hWnd,Tab1),DisplayText)

                        setcaption mainwin,str$(Toggle)
                     endif

if Toggle = 2
DisplayText  = L""
GetWindowTextW(GetDlgItem(mainwin.hwnd,Tab1),DisplayText,512)

                        DestroyWindow(getcontrolhandle(mainwin,Tab1))
                        RemoveWindowSubclass(mainwin.hwnd, &GreenSubclassProc, SUBCLASSID2)
                        DeleteObject(hBrush)
backColor = rgb(180,180,255)
hBrush = CreateSolidBrush(backColor)
SetWindowSubclass(mainwin.hwnd, &PurpleSubclassProc, SUBCLASSID4, 0)
UnicodeLabelCreate(mainwin, Tab1,20, 400, 200, 25, guiFont, SS_CENTER|0x200|SS_NOTIFY)
                        SetWindowTextW(GetDlgItem(mainwin.hWnd,Tab1),DisplayText)

                        setcaption mainwin,str$(Toggle)
                     endif
                 endif

            case Tab2
                 if @NOTIFYCODE=0

                    if Toggle2 = 1
                       Toggle2 = 2
                    else
                       Toggle2 = 1
                    endif

if Toggle2 = 1
DisplayText  = L""
GetWindowTextW(GetDlgItem(mainwin.hwnd,Tab2),DisplayText,512)

                        DestroyWindow(getcontrolhandle(mainwin,Tab2))
                        RemoveWindowSubclass(mainwin.hwnd, &PurpleSubclassProc, SUBCLASSID4)
backColor = rgb(107,142,35)
                        DeleteObject(hBrush)
hBrush = CreateSolidBrush(backColor)
SetWindowSubclass(mainwin.hwnd, &GreenSubclassProc, SUBCLASSID2, 0)
UnicodeLabelCreate(mainwin, Tab2,20, 440, 200, 25, guiFont, SS_CENTER|0x200|SS_NOTIFY)
                        SetWindowTextW(GetDlgItem(mainwin.hWnd,Tab2),DisplayText)

                        setcaption mainwin,str$(Toggle2)
                     endif

if Toggle2 = 2
DisplayText  = L""
GetWindowTextW(GetDlgItem(mainwin.hwnd,Tab2),DisplayText,512)

                        DestroyWindow(getcontrolhandle(mainwin,Tab2))
                        RemoveWindowSubclass(mainwin.hwnd, &GreenSubclassProc, SUBCLASSID2)
                        DeleteObject(hBrush)
backColor = rgb(180,180,255)
hBrush = CreateSolidBrush(backColor)
SetWindowSubclass(mainwin.hwnd, &PurpleSubclassProc, SUBCLASSID4, 0)
UnicodeLabelCreate(mainwin, Tab2,20, 440, 200, 25, guiFont, SS_CENTER|0x200|SS_NOTIFY)
                        SetWindowTextW(GetDlgItem(mainwin.hWnd,Tab2),DisplayText)

                        setcaption mainwin,str$(Toggle2)
                     endif
                 endif

ENDSELECT

ENDSELECT
RETURN 0
ENDSUB

sub DoInit()


endsub

'------------------------------------------
' UNICODE FUNCTIONS
'------------------------------------------

SUB GetUnicodeChar(char byte1, char byte2), wstring
iwstring c[4] : pointer p = &c + 0
*<char>p = byte1 : p+=1
*<char>p = byte2 : p+=1
*<char>p = 0 : p+=1
*<char>p = 0
RETURN c
ENDSUB

SUB UnicodeLabelCreate(window w, INT ctrlID, INT x, INT y, INT width, INT height, INT font, INT align)
INT dwStyles = WS_CHILD | WS_VISIBLE | ES_LEFT | align
INT hwndEDIT = CreateWindowExW(0, L"STATIC", NULL, dwStyles, x, y, width, height, w.hwnd, ctrlID, GetModuleHandle(0), NULL)
SendMessageW(hwndEDIT, WM_SETFONT, font, MAKELPARAM(TRUE,0) )
ENDSUB

SUB UnicodeButtonCreate(window w, INT ctrlID, INT x, INT y, INT width, INT height, INT font)
INT dwStyles = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
INT hwndEDIT = CreateWindowExW(0, L"BUTTON", NULL, dwStyles, x, y, width, height, w.hwnd, ctrlID, GetModuleHandle(0), NULL)
SendMessageW(hwndEDIT, WM_SETFONT, font, MAKELPARAM(TRUE,0) )
ENDSUB

SUB UnicodeControlSetText(window w, INT ctrlID, pointer buffer)
INT hwnd = GetDlgItem(w.hwnd, ctrlID)
SetWindowTextW(hwnd, buffer)
ENDSUB

'------------------------------------------
' GUI FONT
'------------------------------------------

SUB CreateGuiFont(), INT
NONCLIENTMETRICSW metrics
metrics.cbSize = LEN(metrics)
SystemParametersInfow(SPI_GETNONCLIENTMETRICS, LEN(metrics), &metrics, 0)
RETURN CreateFontIndirectW(&metrics.lfSmCaptionFont)
ENDSUB

SUB DeleteGuiFont(INT font)
IF font THEN DeleteObject(font)
ENDSUB

'------------------------------------------
' UP-DOWN CONTROL
'------------------------------------------

SUB UpDownCreate(window w, INT ctrlID, INT x, INT y, INT width, INT height, INT font, INT editId)
INT dwStyles = WS_CHILD | WS_VISIBLE | UDS_SETBUDDYINT
INT hwnd = CreateWindowEx(0, UPDOWN_CLASS, NULL, dwStyles, x, y, width, height, w.hwnd, ctrlID, GetModuleHandle(0), NULL)
SendMessageW(hwnd, WM_SETFONT, font, MAKELPARAM(TRUE,0) )
_SendMessage(hwnd, UDM_SETBUDDY , GetDlgItem(w.hwnd, editId), 0)
ENDSUB

SUB UpDownSetRange(window w, INT ctrlID, word min, word max)
INT hwnd = GetDlgItem(w.hwnd, ctrlID)
_SendMessage(hwnd, UDM_SETRANGE, 0, MAKELPARAM(max, min))
ENDSUB

SUB UpDownSetValue(window w, INT ctrlID, word value)
INT hwnd = GetDlgItem(w.hwnd, ctrlID)
_SendMessage(hwnd, UDM_SETPOS, 0, value)
ENDSUB

SUB GreenSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
if lParam = getcontrolhandle(mainwin,Tab1) or lParam = getcontrolhandle(mainwin,Tab2)
SELECT (uMsg)
CASE WM_CTLCOLORSTATIC
   INT hDC = wParam
   SetTextColor(hDC, RGB(255,255,255))
   SetBkColor(hDC, backColor)
   return hBrush
ENDSELECT
endif
RETURN DefSubclassProc(hWnd, uMsg, wParam, lParam)
ENDSUB

SUB PurpleSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
if lParam = getcontrolhandle(mainwin,Tab1) or lParam = getcontrolhandle(mainwin,Tab2)
SELECT (uMsg)
CASE WM_CTLCOLORSTATIC
   INT hDC = wParam
   SetTextColor(hDC, RGB(0,0,0))
   SetBkColor(hDC, backColor)
   return hBrush
ENDSELECT
endif
RETURN DefSubclassProc(hWnd, uMsg, wParam, lParam)
ENDSUB


Here the statics are named Tab1 and Tab2.

These are the steps.....

When Tab1 is clicked:

1. Save the static text.
2. Remove the control from the window.
3. Remove the sub class.
4. Remove the hBrush.
5. Set your new colour.
6. Create a new hBrush with your colour.
7. Set your new sub class.
8. Recreate your static.
9. Set the text to what it was before.
10. Get a stiff drink!  8)

Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

December 04, 2018, 05:35:52 AM #11 Last Edit: December 04, 2018, 06:19:46 AM by Andy
And here is one made much simpler.....



AUTODEFINE "off"

$include "windowssdk.inc"
$include "commctrl.inc"

'------------------------------------------
' VARIBLES
'------------------------------------------

INT backColor = rgb(107,142,35)
INT TColour = rgb(255,255,255)
HFONT guiFont = 0
HBRUSH hBrush = CreateSolidBrush(backColor)

'A sub class ID
INT SUBCLASSID1 = 12345

'Used just for demonstration - not needed in any other program - unless you want to toggle that is
int Toggle  = 1
int Toggle2 = 1

'And a window of course
window mainwin

'Our two static controls
const Tab1 = 60
const Tab2 = 61

'Lets begin....
OPENWINDOW mainwin,0,0,240,200,@CAPTION|@SYSMENU,0,"Unicode Colour Change.",&mainhandler
floodfill mainwin,0,0,rgb(255,255,255)

CONTROL mainwin,@STATIC,"Click a green box...",10,10,160,25,@CTEDITLEFT|0x200,1
SETFONT mainwin,"Arial",11,400,0,1
SETCONTROLCOLOR mainwin,1,rgb(0,0,0),RGB(255,255,255)

SetWindowSubclass(mainwin.hwnd, &ColourSubclassProc, SUBCLASSID1, 0)

UnicodeLabelCreate(mainwin, Tab1,20, 60, 200, 25, guiFont, SS_CENTER|0x200|SS_NOTIFY)
UnicodeControlSetText(mainwin, Tab1, L"1234")

'Uncomment these lines if you want a different colour for Tab2....

'DeleteObject(hBrush)
'backColor = rgb(180,180,255)
'hBrush = CreateSolidBrush(backColor)
'SetWindowSubclass(mainwin.hwnd, &PurpleSubclassProc, SUBCLASSID2, 0)

'Otherwise we will leave it the same colour as Tab1
UnicodeLabelCreate(mainwin, Tab2,20, 100, 200, 25, guiFont, SS_CENTER|0x200|SS_NOTIFY)
UnicodeControlSetText(mainwin, Tab2, L"5678")

WAITUNTIL mainwin = 0
END

'the main WINDOW message handler
SUB mainhandler(),INT
SELECT @MESSAGE
CASE @IDCLOSEWINDOW
RemoveWindowSubclass(mainwin.hwnd,&colourSubclassProc,SUBCLASSID1)
DeleteObject(hBrush)
                        closewindow mainwin
                        end

CASE @IDCREATE
CENTERWINDOW mainwin

CASE @IDCONTROL
SELECT @CONTROLID

            case Tab1
                 if @NOTIFYCODE=0
                    if Toggle = 1
                       Toggle = 2
                    else
                       Toggle = 1
                    endif

     if Toggle = 1
ChangeUniColour(mainwin,Tab1,rgb(255,255,255),rgb(107,142,35),&ColourSubclassProc,SUBCLASSID1)
                        return 0
                     endif

     if Toggle = 2
                        ChangeUniColour(mainwin,Tab1,rgb(0,0,0),rgb(180,180,255),&ColourSubclassProc,SUBCLASSID1)
                        return 0
                     endif
                 endif

            case Tab2
                 if @NOTIFYCODE=0
                    if Toggle2 = 1
                       Toggle2 = 2
                    else
                       Toggle2 = 1
                    endif

     if Toggle2 = 1
ChangeUniColour(mainwin,Tab2,rgb(255,255,255),rgb(107,142,35),&ColourSubclassProc,SUBCLASSID1)
                        return 0
                     endif

     if Toggle2 = 2
ChangeUniColour(mainwin,Tab2,rgb(0,0,0),rgb(180,180,255),&ColourSubclassProc,SUBCLASSID1)
                        return 0
                     endif
                 endif

ENDSELECT

ENDSELECT
RETURN 0
ENDSUB

'------------------------------------------
' UNICODE FUNCTIONS
'------------------------------------------

SUB UnicodeLabelCreate(window w, INT ctrlID, INT x, INT y, INT width, INT height, INT font, INT align)
INT dwStyles = WS_CHILD | WS_VISIBLE | ES_LEFT | align
INT hwndEDIT = CreateWindowExW(0, L"STATIC", NULL, dwStyles, x, y, width, height, w.hwnd, ctrlID, GetModuleHandle(0), NULL)
SendMessageW(hwndEDIT, WM_SETFONT, font, MAKELPARAM(TRUE,0) )
ENDSUB

SUB UnicodeControlSetText(window w, INT ctrlID, pointer buffer)
INT hwnd = GetDlgItem(w.hwnd, ctrlID)
SetWindowTextW(hwnd, buffer)
ENDSUB

SUB ColourSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
if lParam = getcontrolhandle(mainwin,Tab1) or lParam = getcontrolhandle(mainwin,Tab2)
SELECT (uMsg)
CASE WM_CTLCOLORSTATIC
   INT hDC = wParam
   SetTextColor(hDC, TColour)
   SetBkColor(hDC, backColor)
   return hBrush
ENDSELECT
endif
RETURN DefSubclassProc(hWnd, uMsg, wParam, lParam)
ENDSUB

SUB ChangeUniColour(window WinID,uint ControlID,int TColourIn,int BColour,pointer rproc,int rprocID)
    int wposx,wposy,wposw,wposh
    int posx,posy,posw,posh
    int dwStyle = GetWindowLong(GetDlgItem(WinID.hwnd,ControlID),GWL_STYLE)
    wstring SaveText = L""

    GetWindowTextW(GetDlgItem(WinID.hwnd,ControlID),SaveText,512)
    getsize WinID,wposx,wposy,wposw,wposh
    getsize WinID,posx,posy,posw,posh,ControlID
    DestroyWindow(getcontrolhandle(WinID,ControlID))
    RemoveWindowSubclass(WinID.hwnd,rproc,rprocID)
    DeleteObject(hBrush)
    backColor = BColour 'Background colour
    hBrush = CreateSolidBrush(backColor)
    TColour = TColourIn 'Text colour
    SetWindowSubclass(WinID.hwnd,rproc,rprocID,0)
    UnicodeLabelCreate(WinID, ControlID,(posx-wposx)-3,(posy-wposy)-posh,posw,posh, guiFont, dwStyle)
    SetWindowTextW(GetDlgItem(WinID.hWnd,ControlID),SaveText)
ENDSUB


The paramters for ChangeUniColour are quite simple really...

Window name
Control name
Text colour
Background colour
Name of your subclass procedure
Number of your subclass procedure


Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

fasecero

Good. You can simplify ChangeUniColour a bit more without the need of recreating the static each time the state is changed


AUTODEFINE "off"

$include "windowssdk.inc"
$include "commctrl.inc"

'------------------------------------------
' VARIBLES
'------------------------------------------

HFONT guiFont = CreateUnicodeFont()

INT backColor = RGB(107,142,35)
INT textColor = RGB(255,255,255)

INT backTColor = RGB(180,180,255)
INT textTColor = RGB(0,0,0)

HBRUSH hBrush = CreateSolidBrush(backColor)
HBRUSH hBrushT = CreateSolidBrush(backTColor)

'A sub class ID
INT SUBCLASSID1 = 12345

'Used just for demonstration - not needed in any other program - unless you want to toggle that is
int Toggle  = 1
int Toggle2 = 1

'And a window of course
window mainwin

'Our two static controls
const Tab1 = 60
const Tab2 = 61

'Lets begin....
OPENWINDOW mainwin,0,0,240,200,@CAPTION|@SYSMENU,0,"Unicode Colour Change.",&mainhandler
CONTROL mainwin,@STATIC,"Click a green box...",10,10,160,25,@CTEDITLEFT|0x200,1
SETFONT mainwin,"Arial",11,400,0,1
SETCONTROLCOLOR mainwin,1,rgb(0,0,0),RGB(255,255,255)

SetWindowSubclass(mainwin.hwnd, &ColourSubclassProc, SUBCLASSID1, 0)

UnicodeLabelCreate(mainwin, Tab1,20, 60, 200, 25, guiFont, SS_CENTER|0x200|SS_NOTIFY)
UnicodeControlSetText(mainwin, Tab1, L"1234")

UnicodeLabelCreate(mainwin, Tab2,20, 100, 200, 25, guiFont, SS_CENTER|0x200|SS_NOTIFY)
UnicodeControlSetText(mainwin, Tab2, L"5678")

WAITUNTIL mainwin = 0
END

'the main WINDOW message handler
SUB mainhandler(),INT
SELECT @MESSAGE
CASE @IDCLOSEWINDOW
IF guiFont THEN DeleteObject(guiFont) ' delete the unicode font
RemoveWindowSubclass(mainwin.hwnd,&colourSubclassProc,SUBCLASSID1)
DeleteObject(hBrush)
CLOSEWINDOW mainwin

CASE @IDCREATE
CENTERWINDOW mainwin

CASE @IDCONTROL
SELECT @CONTROLID
CASE Tab1
IF @NOTIFYCODE = 0 THEN
IF Toggle = 1 THEN Toggle = 2 ELSE Toggle = 1
InvalidateRect(GetDlgItem(mainwin.hwnd, Tab1), NULL, NULL) ' redraw Tab1
ENDIF
CASE Tab2
IF @NOTIFYCODE = 0 THEN
IF Toggle2 = 1 THEN Toggle2 = 2 ELSE Toggle2 = 1
InvalidateRect(GetDlgItem(mainwin.hwnd, Tab2), NULL, NULL) ' redraw Tab2
ENDIF
ENDSELECT
ENDSELECT

RETURN 0
ENDSUB

SUB ColourSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
SELECT (uMsg)
CASE WM_CTLCOLORSTATIC
SELECT lParam
CASE GetDlgItem(hWnd, Tab1)
RETURN ChangeUniColour(wParam, Toggle)
CASE GetDlgItem(hWnd, Tab2)
RETURN ChangeUniColour(wParam, Toggle2)
ENDSELECT
ENDSELECT

RETURN DefSubclassProc(hWnd, uMsg, wParam, lParam)
ENDSUB

sub ChangeUniColour(int hdc, int toggle), INT
IF toggle = 1 THEN
SetTextColor(hDC, textColor)
SetBkColor(hDC, backColor)
RETURN hBrush
ELSE
SetTextColor(hDC, textTColor)
SetBkColor(hDC, backTColor)
RETURN hBrushT
ENDIF

RETURN 0
ENDSUB

'------------------------------------------
' UNICODE FUNCTIONS
'------------------------------------------

SUB UnicodeLabelCreate(window w, INT ctrlID, INT x, INT y, INT width, INT height, INT font, INT align)
INT dwStyles = WS_CHILD | WS_VISIBLE | ES_LEFT | align
INT hwndEDIT = CreateWindowExW(0, L"STATIC", NULL, dwStyles, x, y, width, height, w.hwnd, ctrlID, GetModuleHandle(0), NULL)
SendMessageW(hwndEDIT, WM_SETFONT, font, MAKELPARAM(TRUE,0) )
ENDSUB

SUB UnicodeControlSetText(window w, INT ctrlID, pointer buffer)
INT hwnd = GetDlgItem(w.hwnd, ctrlID)
SetWindowTextW(hwnd, buffer)
ENDSUB

'------------------------------------------
' FONT FOR UNICODE CONTROLS
'------------------------------------------

SUB CreateUnicodeFont(), INT
RETURN CreateFontW(16, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, L"Arial")
ENDSUB



LarryMc

I fixed my version so it has 4 tabs plus your 2 original. I made all 6 send notify messages for demonstration purposes.
You could easily  have the "tabflag" under program control.
There is nothing complicated in this version. Easy to add more tabs; easy to have different colors for different tabs(pre and post activation), etc...

$INCLUDE "windowssdk.inc"
$include "commctrl.inc"
CONST BUTTON_1 = 1
CONST BUTTON_2 = 2
CONST TAB1 = 3
CONST TAB2 = 4
CONST TAB3 = 5
CONST TAB4 = 6
INT SUBCLASS_ID = 12345
INT backColor = RGB(255,255,255)
INT pickColor = RGB(0,255,0)
int tabflag=0
WINDOW w1

OPENWINDOW w1,0,0,600,400,@MINBOX|@MAXBOX|@SIZE,NULL,"Simple Window",&w1_handler

HBRUSH hBrush = CreateSolidBrush(backColor)

SetWindowSubclass(w1.hwnd, &MySubclassProc, SUBCLASS_ID, 0)

CreateWindowW(L"STATIC", L"", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_CENTER|@SS_NOTIFY, 10,10,550,40, w1.hwnd, BUTTON_1, GetModuleHandle(0), 0)
SetWindowTextW(GetDlgItem(w1.hwnd, BUTTON_1),StaticText(40,"Date"))
SETFONT w1,"Arial",26,400,0,button_1

CreateWindowW(L"STATIC", L"", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_CENTER|@SS_NOTIFY, 10,45,550,40, w1.hwnd, BUTTON_2, GetModuleHandle(0), 0)
SetWindowTextW(GetDlgItem(w1.hwnd, BUTTON_2),StaticText(40,"Time"))
SETFONT w1,"Arial",26,400,0,button_2

CreateWindowW(L"STATIC", L"", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_CENTER|@SS_NOTIFY, 10,80,550,40, w1.hwnd, TAB1, GetModuleHandle(0), 0)
SetWindowTextW(GetDlgItem(w1.hwnd, TAB1),StaticText(40,"Date"))
SETFONT w1,"Arial",26,400,0,TAB1

CreateWindowW(L"STATIC", L"", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_CENTER|@SS_NOTIFY, 10,115,550,40, w1.hwnd, TAB2, GetModuleHandle(0), 0)
SetWindowTextW(GetDlgItem(w1.hwnd, TAB2),StaticText(40,"Time"))
SETFONT w1,"Arial",26,400,0,TAB2

CreateWindowW(L"STATIC", L"", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_CENTER|@SS_NOTIFY, 10,150,550,40, w1.hwnd, TAB3, GetModuleHandle(0), 0)
SetWindowTextW(GetDlgItem(w1.hwnd, TAB3),StaticText(40,"Date"))
SETFONT w1,"Arial",26,400,0,TAB3

CreateWindowW(L"STATIC", L"", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_CENTER|@SS_NOTIFY, 10,185,550,40, w1.hwnd, TAB4, GetModuleHandle(0), 0)
SetWindowTextW(GetDlgItem(w1.hwnd, TAB4),StaticText(40,"Time"))
SETFONT w1,"Arial",26,400,0,TAB4



' main loop
WAITUNTIL w1 = 0
END

' window procedure
SUB w1_handler(),int
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW w1

CASE @IDCLOSEWINDOW
RemoveWindowSubclass(w1.hwnd, &MySubclassProc, SUBCLASS_ID)
DeleteObject(hBrush)
CLOSEWINDOW w1

CASE @IDCONTROL
SELECT @CONTROLID
CASE BUTTON_1
IF @NOTIFYCODE = @BN_CLICKED
/*button clicked*/
tabflag=0
for i= BUTTON_1 to TAB4
InvalidateRect(getcontrolhandle(w1,i),0,1)
next i
ENDIF
CASE BUTTON_2
IF @NOTIFYCODE = @BN_CLICKED
/*button clicked*/
tabflag=0
for i= BUTTON_1 to TAB4
InvalidateRect(getcontrolhandle(w1,i),0,1)
next i
ENDIF
CASE TAB1
IF @NOTIFYCODE = @BN_CLICKED
/*button clicked*/
tabflag=1
for i= BUTTON_1 to TAB4
InvalidateRect(getcontrolhandle(w1,i),0,0)
next i
ENDIF
CASE TAB2
IF @NOTIFYCODE = @BN_CLICKED
/*button clicked*/
tabflag=2
for i= BUTTON_1 to TAB4
InvalidateRect(getcontrolhandle(w1,i),0,0)
next i
ENDIF
CASE TAB3
IF @NOTIFYCODE = @BN_CLICKED
/*button clicked*/
tabflag=3
for i= BUTTON_1 to TAB4
InvalidateRect(getcontrolhandle(w1,i),0,0)
next i
ENDIF
CASE TAB4
IF @NOTIFYCODE = 0
/*button clicked*/
tabflag=4
for i= BUTTON_1 to TAB4
InvalidateRect(getcontrolhandle(w1,i), 0,0)
next i
ENDIF
ENDSELECT
ENDSELECT
return 0
ENDSUB

SUB StaticText(INT textLen,string TextName), WSTRING
wstring text = L""
pointer p = &text + 0

   restore TimeText
   restore DateText

INT j, a
FOR j = 1 TO textLen

if TextName = "Time"
GETDATA TimeText,a
endif

if TextName = "Date"
GETDATA DateText,a
endif

*<char>p = a
p+=1
NEXT j

RETURN text
ENDSUB

SUB MySubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
INT hDC,i
WINRECT rc
uint brush

SELECT (uMsg)
CASE WM_CTLCOLORSTATIC ' painting static text & back
   hDC = wParam
   SetTextColor(hDC, RGB(100,107,134)) ' TEXT COLOR
select 1
case  (GetDlgItem(w1.hwnd,1)= lparam ) or (GetDlgItem(w1.hwnd,2)= lparam )
SetBkColor(hDC, backColor) ' HBRUSH BACK COLOR
case (GetDlgItem(w1.hwnd,TAB1)= lparam)
if tabflag=1
SetBkColor(hDC, pickColor)
else
SetBkColor(hDC, backColor)
endif
case (GetDlgItem(w1.hwnd,TAB2)= lparam)
if tabflag=2
SetBkColor(hDC, pickColor)
else
SetBkColor(hDC, backColor)
endif
case (GetDlgItem(w1.hwnd,TAB3)= lparam)
if tabflag=3
SetBkColor(hDC, pickColor)
else
SetBkColor(hDC, backColor)
endif
case (GetDlgItem(w1.hwnd,TAB4)= lparam)
if tabflag=4
SetBkColor(hDC, pickColor)
else
SetBkColor(hDC, backColor)
endif
default
SetBkColor(hDC, backColor)
endselect
   return hBrush
ENDSELECT

RETURN DefSubclassProc(hWnd, uMsg, wParam, lParam)
ENDSUB

DATABEGIN TimeText
DATA 169,3,193,3,177,3,0,0
DATAEND

DATABEGIN DateText
DATA  151,3,188,3,181,3,193,3,191,3,188,3,183,3,189,3,175,3,177,3,0,0
DATAEND
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

December 04, 2018, 10:45:49 PM #14 Last Edit: December 05, 2018, 04:12:59 AM by Andy
Fasecero and Larry,

You guys are just brilliant!

It took me nearly eight hours yesterday to come up with my version.

I had to modify the sub class procedure like this:

SUB MySubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
INT hDC,i
WINRECT rc
uint brush

SELECT (uMsg)
CASE WM_CTLCOLORSTATIC ' painting static text & back
   hDC = wParam
   SetTextColor(hDC, RGB(100,107,134)) ' TEXT COLOR
select 1

case (GetDlgItem(w1.hwnd,TAB1)= lparam)
if tabflag=1
                                            SetTextColor(hDC, RGB(255,255,255))
    SetBkColor(hDC, pickColor)
                                            return hBrushT
else
    SetBkColor(hDC, backColor)
                                            return hBrush
endif


case (GetDlgItem(w1.hwnd,TAB2)= lparam)
if tabflag=2
                                             SetTextColor(hDC, RGB(255,255,255))
     SetBkColor(hDC, pickColor)
                                             return hBrushT
else
     SetBkColor(hDC, backColor)
                                             return hBrush
endif

case (GetDlgItem(w1.hwnd,TAB3)= lparam)
if tabflag=3
                                              SetTextColor(hDC, RGB(255,255,255))
      SetBkColor(hDC, pickColor)
                                              return hBrushT
else
      SetBkColor(hDC, backColor)
                                              return hBrush
endif

case (GetDlgItem(w1.hwnd,TAB4)= lparam)
if tabflag=4
                                               SetTextColor(hDC, RGB(255,255,255))
       SetBkColor(hDC, pickColor)
                                               return hBrushT
else
       SetBkColor(hDC, backColor)
                                               return hBrush
endif

default
SetBkColor(hDC, backColor)
endselect
        return hBrush
ENDSELECT

RETURN DefSubclassProc(hWnd, uMsg, wParam, lParam)
ENDSUB


And now it does exactly what I need.

Many many thanks!

Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

RitchieF

Hi Larry, how would you explain the result of your code ? Please take a look at the screenshot.

Thanks

Richard

LarryMc

Richard
I assume you are talking about the characters.
Andy lives in Greece and I am assuming the unicode characters represent something in greek.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

RitchieF

QuoteAndy lives in Greece

Okay ! Didn't remember that !

Thanks

Andy

December 05, 2018, 10:07:02 PM #18 Last Edit: December 05, 2018, 10:25:38 PM by Andy
Richard,

Larry is correct, the two words here are examples of how to display non-English (Unicode) characters.

The words are "Date" and "Time" respectively in Greek.

The project I'm working on is very challenging:

1. It's a database with two main screens - one for customer details, and one for for the visits they have had.

2. There can be up to four customers on the customers screen, to view the one you want you click on the tab that has their name displayed in it - see screenshot (the names don't mean anything here).

Each tab shows a last name, first name for a selected customer.

3. The customer's tab who's details you are viewing is in green, the others are a purple kind of colour - hence Larry's four tabs and the colour question.

4. Because there is a need to store / view Unicode details I have Unicode edit, static controls - hence all the Unicode questions.

I wonder if we should "gather" all the Unicode examples and put them in a new Unicode section?

Just an idea - as I have one (hopefully) final question on Unicode which I will ask later.

:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

Quote from: Andy on December 05, 2018, 10:07:02 PM
I wonder if we should "gather" all the Unicode examples and put them in a new Unicode section?

There are 170+ posts about Unicode spanning almost all the different boards.
I don't think I want to tackle the task of trying to separate all of those out and still have them make sense.

If it had been set up that way originally it would probably worked out okay.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

Point taken Larry,

It was just a glancing thought and no more.

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.