Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "win32api.inc"
#Include "commctrl.inc"
#Resource "gbsnippets.pbr"
%IDM_Close = 500
%IDC_Tab = 501
Global hDlg, hTab, hImgListTab,hPage1,hPage2 As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "TAB Test",300,300,200,200, %WS_SysMenu, 0 To hDlg
'tab control
Control Add Tab, hDlg, %IDC_Tab, "", 10,20,150,150
Control Handle hDlg, %IDC_Tab To hTab
'image list
ImageList New Icon 8,8,24,2 To hImgListTab ' w,h,depth,size
ImageList Add Icon hImgListTab, "open" '1
ImageList Add Icon hImgListTab, "save" '2
Tab Set ImageList hDlg, %IDC_Tab, hImgListTab
'pages
Tab Insert Page hDlg, %IDC_Tab, 1,1,"Page1" To hPage1
Tab Insert Page hDlg, %IDC_Tab, 2,2,"Page2" To hPage2
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local x,y,iReturn,iSelTab As Long, pt As PointAPI, HT As TC_HitTestInfo
Select Case CB.Msg
Case %WM_SetCursor
If CB.wParam = hTab AND hTab AND Hi(Word,CB.lParam) = %WM_LButtonDown Then
Dialog Set Text hDlg, "tab click"
GetCursorPos pt : ScreenToClient htab, pt 'pt now has dialog client coordinates
HT.pt = pt
iReturn = SendMessage(hTab, %TCM_HitTest, 0, VarPTR(HT))+1 'zero based
Tab Get Select hDlg, %IDC_Tab To iSelTab 'one based
If (HT.flags = %TCHT_OnItemIcon) AND (iReturn = iSelTab) Then
Dialog Set Text hDlg, "icon click"
End If
End If
End Select
End Function
'gbs_00804
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm