José,
I'm using your CWindow, Add_Listview. I set the default font to "Arial", point size to 12. I'm new to adding tooltips to listviews and want to know how to change the font of the tooltip, which is using the default font that I'm using for the listview.
Here is an example of what I'm talking about.
#COMPILE EXE
#DIM ALL
%UNICODE = 1
#INCLUDE ONCE "CWindow.inc"
#INCLUDE ONCE "Listviewctrl.inc"
%Common_Controls = %WM_USER + 1
FUNCTION PBMAIN () AS LONG
local LV_Style, hListview as dword
'--------------------------------------------------------------------------------------------------------------------------
' Loads the CWindow CLASS
'--------------------------------------------------------------------------------------------------------------------------
local pWindow as IWindow
pWindow = CLASS "CWindow"
IF ISNOTHING(pWindow) THEN EXIT FUNCTION
'--------------------------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------------------------------
' Create Window
'--------------------------------------------------------------------------------------------------------------------------
pWindow.ClassName = "Listview Test"
pWindow.CreateWindow(%HWND_DESKTOP, "Listview Test", 0, 0, 0, 0, %WS_SYSMENU OR %WS_CAPTION OR %WS_MINIMIZEBOX, %WS_EX_CONTROLPARENT, CODEPTR(WndProc))
' // Set the client size
pWindow.SetClientSize 300, 350
' // Center the window
pWindow.CenterWindow
'--------------------------------------------------------------------------------------------------------------------------
' Create fonts needed for program
'--------------------------------------------------------------------------------------------------------------------------
pWindow.DefaultFontName = "Arial"
pWindow.DefaultFontSize = 12
pWindow.SetFont(pWindow.DefaultFontName, pWindow.DefaultFontSize, %FW_NORMAL, %FALSE, %FALSE, %FALSE, %DEFAULT_CHARSET)
'--------------------------------------------------------------------------------------------------------------------------
' Add Common Control Listview
'--------------------------------------------------------------------------------------------------------------------------
hListView = pWindow.AddListview(pWindow.hWnd, %Common_Controls, "", 10, 10, 210, 290, _
%WS_VISIBLE OR %WS_CLIPCHILDREN OR %WS_TABSTOP OR %LVS_REPORT OR %LVS_SHOWSELALWAYS OR %LVS_SHAREIMAGELISTS OR %LVS_AUTOARRANGE OR %LVS_ALIGNTOP)
Listview_AddColumn(hListview, 0, "Common Controls", 206, %LVCFMT_LEFT)
Listview_AddItem(hListview, 0, 0, "Buttons")
Listview_AddItem(hListview, 1, 0, "Checkboxes")
Listview_AddItem(hListview, 2, 0, "Comboboxes")
Listview_AddItem(hListview, 3, 0, "Custom Controls")
Listview_AddItem(hListview, 4, 0, "Frames")
Listview_AddItem(hListview, 5, 0, "Graphics")
Listview_AddItem(hListview, 6, 0, "Labels")
Listview_AddItem(hListview, 7, 0, "Listboxes")
Listview_AddItem(hListview, 8, 0, "Listviews")
Listview_AddItem(hListview, 9, 0, "Radio Buttons")
Listview_AddItem(hListview, 10, 0, "Textboxes")
LV_Style = ListView_GetExtendedListViewStyle(hListView)
ListView_SetExtendedListViewStyle hListView, LV_Style Xor %LVS_Ex_CheckBoxes or %LVS_EX_INFOTIP
'--------------------------------------------------------------------------------------------------------------------------
' // Default message pump (you can replace it with your own)
pWindow.DoEvents(%SW_SHOW)
end function
'--------------------------------------------------------------------------------------------------------------------------
' Windows Callback function
'--------------------------------------------------------------------------------------------------------------------------
FUNCTION WndProc(BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
local wzText as wstringz * 80
'--------------------------------------------------------------------------------------------------------------------------
SELECT CASE LONG wMsg
'--------------------------------------------------------------------------------------------------------------------------
case %WM_NOTIFY
' Listview Tooltips
Local LVTT_Info As NMLVGetInfoTip ptr
LVTT_Info = lParam
Select Case long @LVTT_Info.hdr.code
Case %LVN_GETINFOTIP
select case long @LVTT_Info.hdr.idFrom
case %Common_Controls
prefix "IF @LVTT_Info.iItem = "
0 then wzText = "Add Buttons"
1 then wzText = "Add Checkbox Controls"
2 then wzText = "Add Combobox Controls"
3 then wzText = "Add Custom Controls"
4 then wzText = "Add Frame Controls"
5 then wzText = "Add Graphic Controls"
6 then wzText = "Add Label Controls"
7 then wzText = "Add Listbox Controls"
8 then wzText = "Add Listview Controls"
9 then wzText = "Add Radio Button Controls"
10 then wzText = "Add Textbox Controls"
end prefix
case else
wzText = ""
end select
if isnotnull(wzText) then @LVTT_Info.@pszText = wzText
end select
'--------------------------------------------------------------------------------------------------------------------------
CASE %WM_CLOSE
PostQuitMessage(0)
EXIT FUNCTION
'--------------------------------------------------------------------------------------------------------------------------
END SELECT
'--------------------------------------------------------------------------------------------------------------------------
FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
END FUNCTION
You need to get the handle of the tooltip control used by the ListView and set the font:
#COMPILE EXE
#DIM ALL
%UNICODE = 1
#INCLUDE ONCE "CWindow.inc"
#INCLUDE ONCE "Listviewctrl.inc"
%Common_Controls = %WM_USER + 1
FUNCTION PBMAIN () AS LONG
local LV_Style, hListview as dword
'--------------------------------------------------------------------------------------------------------------------------
' Loads the CWindow CLASS
'--------------------------------------------------------------------------------------------------------------------------
local pWindow as IWindow
pWindow = CLASS "CWindow"
IF ISNOTHING(pWindow) THEN EXIT FUNCTION
'--------------------------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------------------------------
' Create Window
'--------------------------------------------------------------------------------------------------------------------------
pWindow.ClassName = "Listview Test"
pWindow.CreateWindow(%HWND_DESKTOP, "Listview Test", 0, 0, 0, 0, %WS_SYSMENU OR %WS_CAPTION OR %WS_MINIMIZEBOX, %WS_EX_CONTROLPARENT, CODEPTR(WndProc))
' // Set the client size
pWindow.SetClientSize 300, 350
' // Center the window
pWindow.CenterWindow
'--------------------------------------------------------------------------------------------------------------------------
' Create fonts needed for program
'--------------------------------------------------------------------------------------------------------------------------
pWindow.DefaultFontName = "Arial"
pWindow.DefaultFontSize = 12
pWindow.SetFont(pWindow.DefaultFontName, pWindow.DefaultFontSize, %FW_NORMAL, %FALSE, %FALSE, %FALSE, %DEFAULT_CHARSET)
LOCAL hTooltipFont AS DWORD
hTooltipFont = pWindow.CreateFont("Times New Roman", 10, %FW_BOLD, %FALSE, %FALSE, %FALSE, %DEFAULT_CHARSET)
'--------------------------------------------------------------------------------------------------------------------------
' Add Common Control Listview
'--------------------------------------------------------------------------------------------------------------------------
hListView = pWindow.AddListview(pWindow.hWnd, %Common_Controls, "", 10, 10, 210, 290, _
%WS_VISIBLE OR %WS_CLIPCHILDREN OR %WS_TABSTOP OR %LVS_REPORT OR %LVS_SHOWSELALWAYS OR %LVS_SHAREIMAGELISTS OR %LVS_AUTOARRANGE OR %LVS_ALIGNTOP)
Listview_AddColumn(hListview, 0, "Common Controls", 206, %LVCFMT_LEFT)
Listview_AddItem(hListview, 0, 0, "Buttons")
Listview_AddItem(hListview, 1, 0, "Checkboxes")
Listview_AddItem(hListview, 2, 0, "Comboboxes")
Listview_AddItem(hListview, 3, 0, "Custom Controls")
Listview_AddItem(hListview, 4, 0, "Frames")
Listview_AddItem(hListview, 5, 0, "Graphics")
Listview_AddItem(hListview, 6, 0, "Labels")
Listview_AddItem(hListview, 7, 0, "Listboxes")
Listview_AddItem(hListview, 8, 0, "Listviews")
Listview_AddItem(hListview, 9, 0, "Radio Buttons")
Listview_AddItem(hListview, 10, 0, "Textboxes")
LV_Style = ListView_GetExtendedListViewStyle(hListView)
ListView_SetExtendedListViewStyle hListView, LV_Style Xor %LVS_Ex_CheckBoxes or %LVS_EX_INFOTIP
'--------------------------------------------------------------------------------------------------------------------------
LOCAL hTooltiphWnd AS DWORD
IF hTooltipFont THEN
hTooltiphWnd = ListView_GetToolTips(hListview)
IF hTooltiphWnd THEN AfxSetWindowFont(hTooltiphWnd, hTooltipFont)
END IF
' // Default message pump (you can replace it with your own)
pWindow.DoEvents(%SW_SHOW)
IF hTooltipFont THEN DeleteObject hTooltipFont
end function
'--------------------------------------------------------------------------------------------------------------------------
' Windows Callback function
'--------------------------------------------------------------------------------------------------------------------------
FUNCTION WndProc(BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
local wzText as wstringz * 80
'--------------------------------------------------------------------------------------------------------------------------
SELECT CASE LONG wMsg
'--------------------------------------------------------------------------------------------------------------------------
case %WM_NOTIFY
' Listview Tooltips
Local LVTT_Info As NMLVGetInfoTip ptr
LVTT_Info = lParam
Select Case long @LVTT_Info.hdr.code
Case %LVN_GETINFOTIP
select case long @LVTT_Info.hdr.idFrom
case %Common_Controls
prefix "IF @LVTT_Info.iItem = "
0 then wzText = "Add Buttons"
1 then wzText = "Add Checkbox Controls"
2 then wzText = "Add Combobox Controls"
3 then wzText = "Add Custom Controls"
4 then wzText = "Add Frame Controls"
5 then wzText = "Add Graphic Controls"
6 then wzText = "Add Label Controls"
7 then wzText = "Add Listbox Controls"
8 then wzText = "Add Listview Controls"
9 then wzText = "Add Radio Button Controls"
10 then wzText = "Add Textbox Controls"
end prefix
case else
wzText = ""
end select
if isnotnull(wzText) then @LVTT_Info.@pszText = wzText
end select
'--------------------------------------------------------------------------------------------------------------------------
CASE %WM_CLOSE
PostQuitMessage(0)
EXIT FUNCTION
'--------------------------------------------------------------------------------------------------------------------------
END SELECT
'--------------------------------------------------------------------------------------------------------------------------
FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
END FUNCTION
Thanks José, I tried something like that but mine didn't work. Thanks again José.