INSTALL @lib$+"WINLIB5A"
INSTALL @lib$+"WINLIB2A"
REM!WC
SW_HIDE = 0
SW_SHOW = 5
TCM_SETCURSEL = 4876
_LOGPIXELSX = 88
TCIF_TEXT = 1
TCM_GETCURSEL = 4875
TCM_INSERTITEMA = 4871
WS_CLIPCHILDREN = &2000000
WS_CLIPSIBLINGS = &4000000
_ICC_TAB_CLASSES = 8
Width%=300 : REM Dialogue box sizes
Height%=200
font%=8
size%=10000
SYS "GetDeviceCaps", @memhdc%, _LOGPIXELSX TO Dpi% :REM Find the screen resolution in use
Scale = Dpi%/96 :REM Scale relative to standard 96 dpi
REM Items in the main window have to be scaled to match the dialog boxes which change with dpi.
H1%= FN_button(@hwnd%,"Back",20*Scale,380*Scale,60*Scale,40*Scale,201,0)
H2%= FN_button(@hwnd%,"Fwd",80*Scale,380*Scale,60*Scale,40*Scale,202,0)
DIM dlg%(2)
dlg%(0)=FNdefine_diag1
dlg%(1)=FNdefine_diag2
dlg%(2)=FNdefine_diag3
REM Now to find the size of the dialog so we can match the tab control to it. (If needed)
REM to do this we have to open a dilaog and measure it as the font chnages the size as well!
PROC_showdialog(dlg%(0))
DIM rc{l%,t%,r%,b%}
rc.l% = 0
rc.r% = Width%
rc.t% = 0
rc.b% = Height%
SYS "MapDialogRect", !dlg%(0), rc{}
pixx% = rc.r%-rc.l%
pixy% = rc.b%-rc.t%
PROC_closedialog(dlg%(0)) :REM Destroy the dialog once we have done with it.
DIM icex{dwSize%, dwICC%}
icex.dwSize% = DIM(icex{})
icex.dwICC% = _ICC_TAB_CLASSES
SYS "InitCommonControlsEx", icex{}
ON ERROR SYS "MessageBox", @hwnd%, REPORT$, 0, 48 : END
Click% = 0
ON SYS Click% = @wparam% : RETURN
REM --------------- Create the ControlTab window: ------------------
hTC% = FN_createwindow(@hwnd%, "SysTabControl32", "", 0, 0, pixx%, pixy%, 0, WS_CLIPSIBLINGS OR WS_CLIPCHILDREN, 0)
IF hTC% = 0 ERROR 100, "Couldn't create tab control window"
PROCAdd_Tab(hTC%,"First",0) : REM send add tab message to controltab window
PROCAdd_Tab(hTC%,"Second",1) : REM send add tab message to controltab window
PROCAdd_Tab(hTC%,"Third",2) : REM send add tab message to controltab window
REM Make the tab control the parent of the dialog box!
!(dlg%(0)!4+8) = hTC%
!(dlg%(1)!4+8) = hTC%
!(dlg%(2)!4+8) = hTC%
REM Dock window
DIM rc{l%,t%,r%,b%}
SYS "GetWindowRect", hTC%, rc{}
SYS "GetWindowLong", @hwnd%, -16 TO style%
SYS "SetWindowLong", @hwnd%, -16, style% AND NOT &50000
SYS "AdjustWindowRect", rc{}, style% AND NOT &50000, 0
SYS "SetWindowPos", @hwnd%, 0, 0, 0, rc.r%-rc.l%, rc.b%-rc.t%+100,102 :REM allow space (100) for controls in main window.
REM Needed only if dialogs not closed as tab changes, Wiki method.
PROC_showdialog(dlg%(2)): SYS"ShowWindow", !dlg%(2), SW_HIDE
PROC_showdialog(dlg%(1)): SYS"ShowWindow", !dlg%(1), SW_HIDE
PROC_showdialog(dlg%(0))
cursel% = -1
REPEAT
click% = 0
SWAP click%,Click%
CASE click% OF
WHEN 201: IF cursel% >0 THEN SYS "SendMessage", hTC%, TCM_SETCURSEL, cursel%-1, 0
WHEN 202: IF cursel% <2 THEN SYS "SendMessage", hTC%, TCM_SETCURSEL, cursel%+1, 0
ENDCASE
SYS "SendMessage", hTC%, TCM_GETCURSEL, 0, 0 TO id%
IF id% <> cursel% THEN
REM MSDN preferred method closes dialogs. (not Wiki method).
REM https://msdn.microsoft.com/en-us/library/windows/desktop/hh298366(v=vs.85).aspx
REM IF cursel% >= 0 PROC_closedialog(dlg%(cursel%))
REM PROC_showdialog(dlg%(id%))
REM cursel% = id%
REM With this Wiki method the focus is not transfered to default dialog control automatically.
IF cursel% >= 0 SYS"ShowWindow", !dlg%(cursel%), SW_HIDE
SYS"ShowWindow", !dlg%(id%), SW_SHOW
cursel% = id%
SYS "GetDlgItem",!dlg%(id%),101 TO H%
PROC_setfocus(H%)
ENDIF
UNTIL INKEY(1) = 0
END
REM
-----------------------------------------------------------------
DEFPROCAdd_Tab(htc%,text$,id%)
LOCAL cti{}, fn%, res%
DIM cti{mask%,dwState%,dwStateMask%,pszText%,cchTextMax,iImage,lparam%}
text$ += CHR$0
cti.mask%=TCIF_TEXT
cti.iImage=-1
cti.pszText%=!^text$
SYS "SendMessage", htc%, TCM_INSERTITEMA, id%, cti{} TO res%
IF res% = -1 ERROR 100, "Couldn't send Tab Control info"
ENDPROC
REM
-----------------------------------------------------------------
DEF FNdefine_diag1
LOCAL dlg%
dlg%=FN_newdialog("",0,14,Width%,Height%,font%,size%)
dlg%!16=&508800C4 : REM remove title bar and make child window
PROC_static(dlg%,"Test1",100,84,6,20,20,0)
PROC_editbox(dlg%,"",101,84,30,50,14,0)
= dlg%
DEF FNdefine_diag2
LOCAL dlg%
dlg%=FN_newdialog("",0,14,Width%,Height%,font%,size%)
dlg%!16=&508800C4 : REM remove title bar and make child window
PROC_static(dlg%,"Test2",100,84,6,20,20,0)
PROC_editbox(dlg%,"",101,84,30,50,14,0)
= dlg%
DEF FNdefine_diag3
LOCAL dlg%
dlg%=FN_newdialog("",0,14,Width%,Height%,font%,size%)
dlg%!16=&508800C4 : REM remove title bar and make child window
PROC_static(dlg%,"Test3",100,84,6,20,20,0)
PROC_editbox(dlg%,"",101,84,30,50,14,0)
= dlg%