Post by Walt Decker on Jan 15, 2021 17:03:24 GMT -5
The following dll contains a simple tab control plus the following text and example code:
TABCTL_DLL.ZIP (31.06 KB)
For those not familiar with tab controls here is a little synopsis of what a tab control is.
1. A tab control can be likend to an empty file cabinet drawer. It is just a rectangular box.
2. A window must be defined for each tab. The tab will contain that window.
3. Each tab should have a name.
4. When a tab is clicked the window associated with the tab is displayed. The user can do whatever can be done with the controls on that window.
'=========================================================================================
STRUCTURES:
'=========================================================================================
STRUCT Tab.Struct, _
TabStyle AS ULONG, _ '<--- Style parameters
X AS LONG, _ '<--- Upper left corner of control
Y AS LONG, _ '<--- Upper left corner of control
X1 AS LONG, _ '<--- Width of control
Y1 AS LONG, _ '<--- Height of control
NOTE: If X1 and Y1 are less than zero the width will be X1 units less than the right edge of the parent window client area and Y1 units less than the bottom edge of the client area.
If X1 is less than zero the width of the control will be X1 units less than the right edge of the parent window client area.
If Y1 is less than zero the height of the control will be Y1 units less than the bottom edge of the parent window client area.
TabStyle can be zero. If TabStyle is zero default styles are used. If TabStyle is not zero, all styles you want must be defined including WS.TABSTOP and WS.VISIBLE. WS.CHILD does not have to be defined.
'=========================================================================================
SUPPORTED FUNCTIONS:
'=========================================================================================
"FN_InitTab", WinHndl AS ULONG, _ '<--- Parent of the control
TabStyle AS STRUCT, _ '<--- Tab style (see tab styles below)
TabHndl AS ULONG '<--- Result: Handle of control or ZERO if failed
'Used with all other functions
<--------------------------- TAB STYLES ------------------------------------->
A combination of the following joined with the OR operator
WS.CHILD
WS.VISIBLE
WS.TABSTOP
TCS.TABS
TCS.SINGLELINE
TCS.RAGGEDRIGHT
TCS.FOCUSONBUTTONDOWN
The above styles are defined in the example code toward the end of this document.
"FN_AddTab", TabHndl AS ULONG, _ '<--- Obtained from "FN_InitTab"
WinHndl AS ULONG, _ '<--- Handle associated with this tab
PrntHndl AS ULONG, _ '<--- RESERVERED FOR FUTURE USE
Title AS STRUCT, _ '<--- Text displayed on the tab
TabNum AS LONG '<--- ZERO based index of tab
"UpdateTab", TabHndl AS ULONG, _ '<--- Obtained from "FN_InitTab"
RetVal AS VOID '<--- Nothing returned
'<--- NOTE: This function is used to
'resize the control and its associated
'windows. Controls on its windows are
'NOT resized
"MoveTab", TabHndl AS ULONG, _ '<--- Obtained from "FN_InitTab"
NewPosX AS LONG, _ '<--- Upper left X corner of control
NewPosY AS LONG, _ '<--- Upper left Y corner of control
RetVal AS VOID '<--- NO RETURN VALUD
"FN_GetTabPosition", TabHndl AS ULONG, _ '<--- Obtained from "FN_InitTab"
TabPosX AS STRUCT, _ '<--- RETURN: Current upper left X
_ 'of control
TabPosY AS STRUCT _ '<--- RETURN: Current upper left Y
_ 'of control
RetVal AS LONG 'RETURN: ZERO ON FAIL
"FN_GetTabText", TabHndl AS ULONG, _ '<--- Obtained from "FN_InitTab"
TabNum AS LONG, _ '<--- ZERO based index of tab
PtrTxt AS STRUCT, _ '<--- RETURN: Current title of tab
RetVal AS LONG '<--- ZERO ON FAIL
"SetTabText", TabHndl AS ULONG, _ '<--- Obtained from "FN_InitTab"
TabNum AS LONG, _ '<--- ZERO base index of tab
PtrTxt AS STRUCT, _ '<--- RETURN: Current tab title
RetVal AS VOID '<--- NO RETURN
'=========================================================================================
'=========================================================================================
NOTES
'=========================================================================================
Normally a tab within a tab control can contain a tab control. This control DOES NOT have that capability. Tab controls can support many more functions than this one. If anyone wants additional features, please let me know. If there are enough requests for a given feature, and if LB will support that feature, I will endevor to include it.
'=========================================================================================
FUNCTION "FN_AddTab"
'=========================================================================================
This function changes the supplied window to a CHILD window with no attempt to adjust the style of that window. A child window CANNOT have a menu other than the system menu. Therefore, if your window does have a menu it will be erased. For example, an LB texteditor automatically places an "edit" item in the menu bar. That will be erased. If you want an "edit" item it will have to be placed on the parent of the tab control. The bottom line is any menu items you want for a given tab will have to be placed in the parent window menu bar.
If a window is defined with a caption and system menu and the kill button on the system meny is clicked that window is gone and CAN NOT be recovered.
'=========================================================================================
EXAMPLE CODE FOLLOWS
'=========================================================================================
'
TABCTL_DLL.ZIP (31.06 KB)
For those not familiar with tab controls here is a little synopsis of what a tab control is.
1. A tab control can be likend to an empty file cabinet drawer. It is just a rectangular box.
2. A window must be defined for each tab. The tab will contain that window.
3. Each tab should have a name.
4. When a tab is clicked the window associated with the tab is displayed. The user can do whatever can be done with the controls on that window.
'=========================================================================================
STRUCTURES:
'=========================================================================================
STRUCT Tab.Struct, _
TabStyle AS ULONG, _ '<--- Style parameters
X AS LONG, _ '<--- Upper left corner of control
Y AS LONG, _ '<--- Upper left corner of control
X1 AS LONG, _ '<--- Width of control
Y1 AS LONG, _ '<--- Height of control
NOTE: If X1 and Y1 are less than zero the width will be X1 units less than the right edge of the parent window client area and Y1 units less than the bottom edge of the client area.
If X1 is less than zero the width of the control will be X1 units less than the right edge of the parent window client area.
If Y1 is less than zero the height of the control will be Y1 units less than the bottom edge of the parent window client area.
TabStyle can be zero. If TabStyle is zero default styles are used. If TabStyle is not zero, all styles you want must be defined including WS.TABSTOP and WS.VISIBLE. WS.CHILD does not have to be defined.
'=========================================================================================
SUPPORTED FUNCTIONS:
'=========================================================================================
"FN_InitTab", WinHndl AS ULONG, _ '<--- Parent of the control
TabStyle AS STRUCT, _ '<--- Tab style (see tab styles below)
TabHndl AS ULONG '<--- Result: Handle of control or ZERO if failed
'Used with all other functions
<--------------------------- TAB STYLES ------------------------------------->
A combination of the following joined with the OR operator
WS.CHILD
WS.VISIBLE
WS.TABSTOP
TCS.TABS
TCS.SINGLELINE
TCS.RAGGEDRIGHT
TCS.FOCUSONBUTTONDOWN
The above styles are defined in the example code toward the end of this document.
"FN_AddTab", TabHndl AS ULONG, _ '<--- Obtained from "FN_InitTab"
WinHndl AS ULONG, _ '<--- Handle associated with this tab
PrntHndl AS ULONG, _ '<--- RESERVERED FOR FUTURE USE
Title AS STRUCT, _ '<--- Text displayed on the tab
TabNum AS LONG '<--- ZERO based index of tab
"UpdateTab", TabHndl AS ULONG, _ '<--- Obtained from "FN_InitTab"
RetVal AS VOID '<--- Nothing returned
'<--- NOTE: This function is used to
'resize the control and its associated
'windows. Controls on its windows are
'NOT resized
"MoveTab", TabHndl AS ULONG, _ '<--- Obtained from "FN_InitTab"
NewPosX AS LONG, _ '<--- Upper left X corner of control
NewPosY AS LONG, _ '<--- Upper left Y corner of control
RetVal AS VOID '<--- NO RETURN VALUD
"FN_GetTabPosition", TabHndl AS ULONG, _ '<--- Obtained from "FN_InitTab"
TabPosX AS STRUCT, _ '<--- RETURN: Current upper left X
_ 'of control
TabPosY AS STRUCT _ '<--- RETURN: Current upper left Y
_ 'of control
RetVal AS LONG 'RETURN: ZERO ON FAIL
"FN_GetTabText", TabHndl AS ULONG, _ '<--- Obtained from "FN_InitTab"
TabNum AS LONG, _ '<--- ZERO based index of tab
PtrTxt AS STRUCT, _ '<--- RETURN: Current title of tab
RetVal AS LONG '<--- ZERO ON FAIL
"SetTabText", TabHndl AS ULONG, _ '<--- Obtained from "FN_InitTab"
TabNum AS LONG, _ '<--- ZERO base index of tab
PtrTxt AS STRUCT, _ '<--- RETURN: Current tab title
RetVal AS VOID '<--- NO RETURN
'=========================================================================================
'=========================================================================================
NOTES
'=========================================================================================
Normally a tab within a tab control can contain a tab control. This control DOES NOT have that capability. Tab controls can support many more functions than this one. If anyone wants additional features, please let me know. If there are enough requests for a given feature, and if LB will support that feature, I will endevor to include it.
'=========================================================================================
FUNCTION "FN_AddTab"
'=========================================================================================
This function changes the supplied window to a CHILD window with no attempt to adjust the style of that window. A child window CANNOT have a menu other than the system menu. Therefore, if your window does have a menu it will be erased. For example, an LB texteditor automatically places an "edit" item in the menu bar. That will be erased. If you want an "edit" item it will have to be placed on the parent of the tab control. The bottom line is any menu items you want for a given tab will have to be placed in the parent window menu bar.
If a window is defined with a caption and system menu and the kill button on the system meny is clicked that window is gone and CAN NOT be recovered.
'=========================================================================================
EXAMPLE CODE FOLLOWS
'=========================================================================================
'
NOMAINWIN
'<----------------------- STATIC TEXT STYLES ---------------->
SS.CENTER = HEXDEC("&H00000001")
SS.CENTERIMAGE = HEXDEC("&H00000200")
SS.SUNKEN = HEXDEC("&H00001000")
'<---------------------- TAB STYLES SUPPORTED ---------------->
WS.CHILD = HEXDEC("&H40000000")
WS.VISIBLE = HEXDEC("&H10000000")
WS.TABSTOP = HEXDEC("&H00010000")
TCS.TABS = 0
TCS.SINGLELINE = 0
TCS.RAGGEDRIGHT = HEXDEC("00000800")
TCS.FOCUSONBUTTONDOWN = HEXDEC("00001000")
STRUCT tRect, _
X AS LONG, _
Y AS LONG, _
X1 AS LONG, _
Y1 AS LONG
STRUCT tTab, _
TabStyle AS ULONG, _
X AS LONG, _
Y AS LONG, _
X1 AS LONG, _
Y1 AS LONG
GLOBAL TabHndl
tTab.TabStyle.struct = 0
tTab.X.struct = 20
tTab.Y.struct = 50
tTab.X1.struct = 300
tTab.Y1.struct = -50
UpperLeftX = 300
UpperRightX = 200
WindowWidth = 300
WindowHdight = 300
STYLEBITS #TB1.STAT, SS.CENTER OR SS.CENTERIMAGE OR SS.SUNKEN, 0, WS.EX.TRANSPARENT, 0
STATICTEXT #TB1.STAT, "PETER PIPER", 10, 2, 200, 150
TEXTEDITOR #TB1.ED, 215, 2, 200, 200
TEXTEDITOR #TB2.ED, 25, 50, 200, 200
GRAPHICBOX #TB3.GFX, 10, 10, 100, 100
OPEN "TABCTL" FOR DLL AS #TAB
OPEN "TAB TEST" FOR WINDOW AS #WIN
OPEN "TAB1" FOR WINDOW AS #TB1
OPEN "TAB2" FOR WINDOW AS #TB2
OPEN "TAB3" FOR WINDOW AS #TB3
PRINT #WIN, "RESIZEHANDLER SIZEIT"
PRINT #WIN, "TRAPCLOSE STOPIT"
WinHndl = HWND(#WIN)
Tab1Hndl = HWND(#TB1)
Tab2Hndl = HWND(#TB2)
Tab3Hndl = HWND(#TB3)
Ttl1$ = "TAB1"
Ttl2$ = "TAB2"
Ttl3$ = "TAB3"
CALLDLL #TAB, "FN_InitTab", WinHndl AS ULONG, tTab AS STRUCT, TabHndl AS ULONG
print TabHndl
CALLDLL #TAB, "FN_AddTab", TabHndl AS ULONG, Tab1Hndl AS ULONG, _
0 AS ULONG, Ttl1$ AS STRUCT, Idx AS LONG
CALLDLL #TAB, "FN_AddTab", TabHndl AS ULONG, Tab2Hndl AS ULONG, _
0 AS ULONG, Ttl2$ AS STRUCT, Idx AS LONG
CALLDLL #TAB, "FN_AddTab", TabHndl AS ULONG, Tab3Hndl AS ULONG, _
0 AS ULONG, Ttl3$ AS STRUCT, Idx AS LONG
PRINT Idx
WAIT
END
'----------------------------------------------------------------------------------
'----------------------------------------------------------------------------------
SUB STOPIT Hndl$
CLOSE #WIN
CLOSE #TAB
CLOSE #TB1
CLOSE #TB2
CLOSE #TB3
END
END SUB
'----------------------------------------------------------------------------------
'----------------------------------------------------------------------------------
SUB SIZEIT Hndl$
RetVal = 0
WinHndl = HWND(#WIN)
CALLDLL #TAB, "UpdateTab", TabHndl AS ULONG, RetVal AS VOID
END SUB
'