Post by Walt Decker on Jan 23, 2021 13:15:32 GMT -5
I have been playing with the tab control and run into a few small(perhaps) problems.
First, as I mentioned before, the tab control makes your "tab window" a child of a parent. The child window cannot have menu items other than the system menu. With the LB "texteditor" widgit, LB automatically places an "Edit" menu item on the "tab" window which making it a child window removes. This process causes LB to place an "OS warning: Invalid menu handle" in the LB error log. Whether this will affect the creation of a .TKN I have no idea.
Second, even though STYLEBITS is set to remove WS.OVERLAPPEDWINDOW which contains WS.CAPTION, LB will remove the resize frame, i. e. WS.THICKFRAME, but places WS.CAPTION back in the "tab" window style. The caption can be removed using the User32.dll function SetWindowLong(); however, LB automatically places the resize frame back in the style. Therefore the "tab" window will either have no caption and a resize border or a caption with no resize border.
A third error has to do with LB's "graphicbox" control. The same occurances apply as with the "texteditor". However, removing the caption produces:
Runtime error: Invalid device context (DC) handle. (OS error 16r591). See error log.
on shutdown of the app and freezes the LB app editor. By leaving the "tab" window caption in place, no error is generated on shutdown. I have not tried drawing on the control either with or without a caption, but I suspicion that removing the caption will produce the error when using the LB graphic statements. I do not know if producing a .TKN will allieviate the problem.
The problem with the graphic box window makes me question whether the tab control dll is a viable tool for LB.
The following code illustrates the problem. The code was produced using LB PRO. For convience the tab control dll is in the attached zip file.
TABCTL_DLL.ZIP (31.06 KB)
First, as I mentioned before, the tab control makes your "tab window" a child of a parent. The child window cannot have menu items other than the system menu. With the LB "texteditor" widgit, LB automatically places an "Edit" menu item on the "tab" window which making it a child window removes. This process causes LB to place an "OS warning: Invalid menu handle" in the LB error log. Whether this will affect the creation of a .TKN I have no idea.
Second, even though STYLEBITS is set to remove WS.OVERLAPPEDWINDOW which contains WS.CAPTION, LB will remove the resize frame, i. e. WS.THICKFRAME, but places WS.CAPTION back in the "tab" window style. The caption can be removed using the User32.dll function SetWindowLong(); however, LB automatically places the resize frame back in the style. Therefore the "tab" window will either have no caption and a resize border or a caption with no resize border.
A third error has to do with LB's "graphicbox" control. The same occurances apply as with the "texteditor". However, removing the caption produces:
Runtime error: Invalid device context (DC) handle. (OS error 16r591). See error log.
on shutdown of the app and freezes the LB app editor. By leaving the "tab" window caption in place, no error is generated on shutdown. I have not tried drawing on the control either with or without a caption, but I suspicion that removing the caption will produce the error when using the LB graphic statements. I do not know if producing a .TKN will allieviate the problem.
The problem with the graphic box window makes me question whether the tab control dll is a viable tool for LB.
The following code illustrates the problem. The code was produced using LB PRO. For convience the tab control dll is in the attached zip file.
TABCTL_DLL.ZIP (31.06 KB)
'NOMAINWIN
WS.OVERLAPPED = HEXDEC("&H00000000")
WS.POPUP = HEXDEC("&H80000000")
WS.CHILD = HEXDEC("&H40000000")
WS.MINIMIZE = HEXDEC("&H20000000")
WS.VISIBLE = HEXDEC("&H10000000")
WS.DISABLED = HEXDEC("&H08000000")
WS.CLIPSIBLINGS = HEXDEC("&H04000000")
WS.CLIPCHILDREN = HEXDEC("&H02000000")
WS.MAXIMIZE = HEXDEC("&H01000000")
WS.CAPTION = HEXDEC("&H00C00000") ' WS.BORDER OR WS.DLGFRAME
WS.BORDER = HEXDEC("&H00800000")
WS.DLGFRAME = HEXDEC("&H00400000")
WS.VSCROLL = HEXDEC("&H00200000")
WS.HSCROLL = HEXDEC("&H00100000")
WS.SYSMENU = HEXDEC("&H00080000")
WS.THICKFRAME = HEXDEC("&H00040000")
WS.GROUP = HEXDEC("&H00020000")
WS.TABSTOP = HEXDEC("&H00010000")
WS.MINIMIZEBOX = HEXDEC("&H00020000")
WS.MAXIMIZEBOX = HEXDEC("&H00010000")
WS.OVERLAPPEDWINDOW = (WS.OVERLAPPED _
OR WS.CAPTION _
OR WS.SYSMENU _
OR WS.THICKFRAME _
OR WS.MINIMIZEBOX _
OR WS.MAXIMIZEBOX)
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
OPEN "User32" FOR DLL AS #USER
OPEN "E:\PBWIN10\DLLS\TABCTL" FOR DLL AS #TAB
GLOBAL TabHndl
Style = 0
RemStyle = 0
TabHndl = 0
WinHndl = 0
Tab.1Hndl = 0
Tab.2Hndl = 0
RetVal = 0
Clx = 0
Cly = 0
Clszx = 0
Clszy = 0
Ttl.1$ = ""
Ttl.2$ = ""
UpperLeftX = 1
UpperLeftY = 1
WindowWidth = 600
WindowHeight = 400
OPEN "TABCTL TEST" FOR WINDOW AS #MAIN
PRINT #MAIN, "TRAPCLOSE STOPIT"
WinHndl = HWND(#MAIN)
CALLDLL #USER, "GetClientRect", WinHndl AS ULONG, tRect AS STRUCT, RetVal AS VOID
Clx = 4
Cly = 4
Clszx = tRect.X1.struct - Clx - 12
Clszy = tRect.Y1.struct - Cly - 60
TEXTEDITOR #TAB1.ED, Clx, Cly, Clszx, Clszy
UpperLeftX = 1
UpperLeftY = 1
WindowWidth = tRect.X1.struct
WindowHeight = tRect.Y1.struct
Style = WS.VISIBLE OR WS.CLIPCHILDREN OR WS.DLGFRAME OR WS.VISIBLE 'WS.POPUP OR
RemStyle = WS.OVERLAPPEDWINDOW
STYLEBITS #TAB1, Style, RemStyle, 0, 0 '<--- Remove RemStyle and add Style
OPEN "EDIT TAB" FOR WINDOW AS #TAB1
GRAPHICBOX #TAB2.GFX, Clx, Cly, Clszx, Clszy
STYLEBITS #TAB2, Style, RemStyle, 0, 0 '<--- Remove RemStyle and add Style
OPEN "GFXBOX" FOR WINDOW AS #TAB2
tTab.X.struct = 5
tTab.Y.struct = 5
tTab.X1.struct = tRect.X1.struct - tRect.X.struct - 6
tTab.Y1.struct = tRect.Y1.struct - tRect.Y.struct - 10
Ttl.1$ = "TEXT EDITOR"
Ttl.2$ = "GRAPHIC BOX"
Tab.1Hndl = HWND(#TAB1)
Tab.2Hndl = HWND(#TAB2)
CALLDLL #TAB, "FN_InitTab", WinHndl AS ULONG, tTab AS STRUCT, TabHndl AS ULONG
CALLDLL #TAB, "FN_AddTab", TabHndl AS ULONG, Tab.1Hndl AS ULONG, _
0 AS ULONG, Ttl.1$ AS STRUCT, Idx AS LONG
CALLDLL #TAB, "FN_AddTab", TabHndl AS ULONG, Tab.2Hndl AS ULONG, _
0 AS ULONG, Ttl.2$ AS STRUCT, Idx AS LONG
CALLDLL #USER, "GetWindowLongA",_ '<--- Get current style
Tab.1Hndl as ULONG,_
_GWL_STYLE as LONG,_
Style as LONG
'<-------------- LB HAS REMOVED WS.THICKFRAME BUT ADDED WS.CAPTION ------------------->
' TO THE TEXT EDIT WINDOW
IF (Style AND WS.CAPTION) = WS.CAPTION THEN '<--- Remove caption and LB
Style = Style XOR WS.CAPTION 'adds WS.THICKFRAME to the edit window
CALLDLL #USER, "SetWindowLongA",_
Tab.1Hndl as ULONG,_
_GWL_STYLE as LONG,_
Style as LONG
END IF
CALLDLL #USER, "GetWindowLongA",_
Tab.2Hndl as ULONG,_
_GWL_STYLE as LONG,_
Style as LONG
'<-------------- LB HAS REMOVED WS.THICKFRAME BUT ADDED WS.CAPTION ------------------->
' TO THE GRAPHIC BOX WINDOW
' THIS PRODUCES OS ERROR 16r591 ON SHUTDOWN
' COMMENTING THIS OUT PRODUCES NO ERROR
'<------------------------------------------------------------------------------------->
IF (Style AND WS.CAPTION) = WS.CAPTION THEN '<--- Remove caption and LB
Style = Style XOR WS.CAPTION 'adds WS.THICKFRAME to the edit window
CALLDLL #USER, "SetWindowLongA",_
Tab.2Hndl as ULONG,_
_GWL_STYLE as LONG,_
Style as LONG
END IF
WAIT
'----------------------------------------------------------------------------------------
'----------------------------------------------------------------------------------------
SUB STOPIT Hndl$
CLOSE #MAIN
CLOSE #TAB1
CLOSE #TAB2
CLOSE #USER
CLOSE #TAB
END
END SUB