'Below are the WM_INITDIALOG AND WM_CTLCOLORSTATIC areas of my dialog callback procedure
'ID's 1501-1512 I've predefined as labels that have the %SS_NOTIFY style and
'Question:
'Is this the best way to get a hover effect. The purpose of the code in WM_CTLCOLORSTATIC is to get the label to
'turn red and underlined when the cursor is over it as well as change the cursor to a handcursor.
'Sometimes if these labels are too close, they don't turn off when the other turns on (rarely).
'I'm probably not doing this the right way.
'The WM_SETCURSOR code just tells when the cursor has moved away from a control onto the background of the dialog
'and signals a redraw of that control to return to normal. When the cursor moves over another control id in the
'range of 1501 to 1512 it triggers a redraw of the current control to turn it red and underlined. When clicked, other
'code is fired to do the work.
'Any suggestions?
Bob Mechler
'ID's 1501-1512 I've predefined as labels that have the %SS_NOTIFY style and
'Question:
'Is this the best way to get a hover effect. The purpose of the code in WM_CTLCOLORSTATIC is to get the label to
'turn red and underlined when the cursor is over it as well as change the cursor to a handcursor.
'Sometimes if these labels are too close, they don't turn off when the other turns on (rarely).
'I'm probably not doing this the right way.
'The WM_SETCURSOR code just tells when the cursor has moved away from a control onto the background of the dialog
'and signals a redraw of that control to return to normal. When the cursor moves over another control id in the
'range of 1501 to 1512 it triggers a redraw of the current control to turn it red and underlined. When clicked, other
'code is fired to do the work.
'Any suggestions?
Code:
SELECT CASE CBMSG CASE %WM_INITDIALOG hFontlb = MakeFont("Tahoma",9) hFontlbul = MakeFontul("Tahoma",9) LOCAL Lb AS LOGBRUSH Lb.lbstyle = %BS_SOLID ' DOS BASIC COLORS Lb.lbColor = RGB(0,0,0) : V_Brush(0) = CreateBrushIndirect(Lb) ' 0 black Lb.lbColor = RGB(0,0,128) : V_Brush(1) = CreateBrushIndirect(Lb) ' 1 blue Lb.lbColor = RGB(0,128,0) : V_Brush(2) = CreateBrushIndirect(Lb) ' 2 green Lb.lbColor = RGB(0,128,128) : V_Brush(3) = CreateBrushIndirect(Lb) ' 3 cyan 'was 0,128,128 Lb.lbColor = RGB(196,0,0) : V_Brush(4) = CreateBrushIndirect(Lb) ' 4 red (maroon) Lb.lbColor = RGB(128,0,128) : V_Brush(5) = CreateBrushIndirect(Lb) ' 5 magenta Lb.lbColor = RGB(128,64,0) : V_Brush(6) = CreateBrushIndirect(Lb) ' 6 brown Lb.lbColor = RGB(224,224,224) : V_Brush(7) = CreateBrushIndirect(Lb) ' 7 l gray Lb.lbColor = RGB(128,128,128) : V_Brush(8) = CreateBrushIndirect(Lb) ' 8 gray Lb.lbColor = RGB(0,0,196) : V_Brush(9) = CreateBrushIndirect(Lb) ' 9 l blue Lb.lbColor = RGB(0,255,0) : V_Brush(10) = CreateBrushIndirect(Lb) ' 10 l green Lb.lbColor = RGB(0,255,255) : V_Brush(11) = CreateBrushIndirect(Lb) ' 11 l cyan Lb.lbColor = RGB(255,0,0) : V_Brush(12) = CreateBrushIndirect(Lb) ' 12 l red Lb.lbColor = RGB(255,0,255) : V_Brush(13) = CreateBrushIndirect(Lb) ' 13 l magenta Lb.lbColor = RGB(255,255,0) : V_Brush(14) = CreateBrushIndirect(Lb) ' 14 yellow lb.lbColor = RGB(255,255,255) : V_Brush(15) = CreateBrushIndirect(Lb) ' 15 b white lb.lbColor = RGB(128,255,128) : V_Brush(16) = CreateBrushIndirect(Lb) ' 16 'User defined Background,Title and Active field lb.lbColor = PB_BACK& : V_Brush(17) = CreateBrushIndirect(Lb) ' Created in program using colorpicker lb.lbColor = PB_TITL& : V_Brush(18) = CreateBrushIndirect(Lb) ' Created in program using colorpicker lb.lbColor = PB_ACTV& : V_Brush(19) = CreateBrushIndirect(Lb) ' Created in program using colorpicker CASE %WM_CTLCOLORSTATIC SELECT CASE GetDlgCtrlID(CBLPARAM) 'Standard Captions and extended captions CASE 1501 TO 1512 IF GetDlgCtrlID(CBLPARAM) = CUR_CTRL_ID& THEN SetCursor HandMousePointer SelectObject CBWPARAM, hFontlbul SetTextColor CBWPARAM, V_COLOR(4) ' change red when hover ELSE SelectObject CBWPARAM, hFontlb SetTextColor CBWPARAM, V_COLOR(1) END IF SetBkColor CBWPARAM, V_COLOR(15) SetBkMode CBWPARAM, %Transparent FUNCTION = V_Brush(17) CASE %WM_SETCURSOR CUR_CTRL_ID& = GetDlgCtrlID(CBWPARAM) IF CUR_CTRL_ID& >= 1501 AND CUR_CTRL_ID& <= 1512 THEN CONTROL HANDLE CBHNDL, CUR_CTRL_ID& TO CUR_CTRL& RedrawWindow CUR_CTRL&, BYVAL 0, 0, %RDW_ERASE OR %RDW_INVALIDATE PRESS_ENTER_ON = -1 PRV_BUT_ID& = CUR_CTRL_ID& ELSEIF ABS(CUR_CTRL_ID&) > 100000& AND PRESS_ENTER_ON THEN CONTROL HANDLE CBHNDL, PRV_BUT_ID& TO PRV_BUT& RedrawWindow PRV_BUT&, BYVAL 0, 0, %RDW_ERASE OR %RDW_INVALIDATE PRESS_ENTER_ON = 0 END IF
Comment