ReneMiner
10-11-2012, 21:53
How can I make canvas keep the focus so it does not change to Tab-Control/Button if I use arrow-keys. The switch %TCS_FOCUSNEVER doesn't do what it says.
But they still are supposed to work by clicking at. I think it has something to do with callback but I'm lost in hf. bcs of a.t. abbrv. and " " It doesn't tell me what I have to ask for like which Control Got Focus and if I set focus (commented out) it does not respond to clicks any more.
This is my script:
'
' The most basic skeleton for TBGL
' Suitable for developing editor apps
' , started on 11-08-2012
'
Uses "UI", "TBGL"
' -- ID numbers of controls
Begin ControlID
%cCanvas
%cClose
%cTabcontrol
%cTreeView
%cListView
%cTimer
End ControlID
Begin Const
%MAIN_WIDTH = 800
%MAIN_HEIGHT = 600
'---------------
%timeOut = 20 ' -- Determines graphics refresh rate in milliseconds
End Const
Dim hDlg As DWord
Function TBMain()
Dialog New Pixels, 0, "Dialog with TBGL",-1,-1, %MAIN_WIDTH, %MAIN_HEIGHT, _
%WS_POPUP Or %WS_VISIBLE Or _
%WS_CLIPCHILDREN Or %WS_CAPTION Or _
%WS_SYSMENU Or %WS_MINIMIZEBOX Or %WS_MAXIMIZEBOX Or %WS_THICKFRAME, 0 To hDlg
' -- Place controls here
Control Add Label, hDlg, %cCanvas, "", 244, 4, %MAIN_WIDTH-248, %MAIN_HEIGHT-40
Control Set Color hDlg, %cCanvas, %BLACK, %BLACK
Control Set Resize hDlg, %cCanvas, 1, 1, 1, 1
Control Add Button, hDlg, %cClose, "Close", %MAIN_WIDTH-100, %MAIN_HEIGHT-32, 96, 28
Control Set Resize hDlg, %cClose, 0, 1, 0, 1
Control Add Tab, hDlg, %cTabControl, "", 4, 4, 236, %Main_Height - 8 ,%TCS_FOCUSNEVER ',%WS_EX_CLIENTEDGE
Control Set Resize hDlg, %cTabControl, 1, 0, 1, 0
TAB_PageInsert hDlg, %cTabControl, 1, , "TREE" Call cbTab1
TAB_PageInsert hDlg, %cTabControl, 1, , "LIST" Call cbTab2
Dialog Set Minsize hDlg, 640, 480
Dialog Show Modal hDlg, Call dlgCallback
End Function
CallBack Function dlgCallback()
Static hCtrl As DWord
Select Case CBMSG
Case %WM_INITDIALOG
Dialog Set Timer CBHNDL, %cTimer, %timeOut, %NULL
Control Handle CBHNDL, %cCanvas To hCtrl
' -- Init OpenGL
TBGL_BindCanvas(hCtrl)
TBGL_UseLighting(%TRUE)
TBGL_UseLightSource(%GL_LIGHT0, %TRUE)
TBGL_SetLightParameter(%GL_LIGHT0, %TBGL_LIGHT_POSITION, 15, 10, 15, 1)
Case %WM_SIZE, %WM_SIZING
TBGL_UpdateCanvasProportions(hCtrl)
RenderMyImage(hCtrl)
TAB_OnResize(CBHNDL, %cTabControl)
Case %WM_TIMER
If CBWPARAM = %cTIMER Then
Dialog Kill Timer CBHNDL, %cTIMER
RenderMyImage(hCtrl)
'Control Set Focus CBHNDL, %lCanvas
Dialog Set Timer CBHNDL, %cTIMER, %TIMEOUT
EndIf
Case %WM_CLOSE
TBGL_ReleaseCanvas(hCtrl)
Dialog Kill Timer CBHNDL, %cTimer
Case %WM_COMMAND
Select Case CBCTL
Case %cClose
If CBCTLMSG = %BN_CLICKED Then Dialog End CBHNDL
End Select
End Select
End Function
CallBack Function cbTab1()
Local lW, lH As Long
Select Case CBMSG
Case %WM_INITDIALOG
Control Add TreeView, CBHNDL, %cTreeView,, 0, 0, 236, %Main_Height - 32 ', %WS_CHILD
Case %WM_SIZE
Dialog Get Client, CBHNDL To lW, lH
Control Set Size, CBHNDL, %cTreeView, 236, lH
End Select
End Function
CallBack Function cbTab2()
Local lW, lH As Long
Select Case CBMSG
Case %WM_INITDIALOG
Control Add Listview, CBHNDL, %cListView, , 0, 0, 236, %Main_Height - 32 ', %WS_CHILD
Case %WM_SIZE
Dialog Get Client, CBHNDL To lW, lH
Control Set Size, CBHNDL, %cListView, 236, lH
End Select
End Function
Function RenderMyImage( hCtrl As DWord )
Static FrameRate As Double
If TBGL_CanvasBound(hCtrl) Then
FrameRate = TBGL_GetFrameRate
TBGL_ClearFrame
TBGL_Camera(5, 5, 5, 0, 0, 0)
TBGL_Box(1, 1, 1)
TBGL_DrawFrame
End If
End Function
and: how can I make a control inside tab keeping it's proportions inside the tab-window (maybe a listview or treeview that should always cover the whole client of tab) - if I use Set Resize inside callback-function it instantly crashes. If I do it like described in Example-Script (TabControl_AdressBook) the treeView and Listview do not resize as they are supposed to. I'm really frustrated by now since I've tried for many hours any logical combinations without any success. I'm gonna skip UI and do all per TBGL now, even the controls. I 'm starting to hate that callback-stuff :evil:
BUGS:
Control Show State does not do anything on ListView + Treeview... only works at Buttons
Dialog Set Text does nothing
TAB_GetSelected returns always the same i.e. returns the value that was set using Tab_SetSelected
But they still are supposed to work by clicking at. I think it has something to do with callback but I'm lost in hf. bcs of a.t. abbrv. and " " It doesn't tell me what I have to ask for like which Control Got Focus and if I set focus (commented out) it does not respond to clicks any more.
This is my script:
'
' The most basic skeleton for TBGL
' Suitable for developing editor apps
' , started on 11-08-2012
'
Uses "UI", "TBGL"
' -- ID numbers of controls
Begin ControlID
%cCanvas
%cClose
%cTabcontrol
%cTreeView
%cListView
%cTimer
End ControlID
Begin Const
%MAIN_WIDTH = 800
%MAIN_HEIGHT = 600
'---------------
%timeOut = 20 ' -- Determines graphics refresh rate in milliseconds
End Const
Dim hDlg As DWord
Function TBMain()
Dialog New Pixels, 0, "Dialog with TBGL",-1,-1, %MAIN_WIDTH, %MAIN_HEIGHT, _
%WS_POPUP Or %WS_VISIBLE Or _
%WS_CLIPCHILDREN Or %WS_CAPTION Or _
%WS_SYSMENU Or %WS_MINIMIZEBOX Or %WS_MAXIMIZEBOX Or %WS_THICKFRAME, 0 To hDlg
' -- Place controls here
Control Add Label, hDlg, %cCanvas, "", 244, 4, %MAIN_WIDTH-248, %MAIN_HEIGHT-40
Control Set Color hDlg, %cCanvas, %BLACK, %BLACK
Control Set Resize hDlg, %cCanvas, 1, 1, 1, 1
Control Add Button, hDlg, %cClose, "Close", %MAIN_WIDTH-100, %MAIN_HEIGHT-32, 96, 28
Control Set Resize hDlg, %cClose, 0, 1, 0, 1
Control Add Tab, hDlg, %cTabControl, "", 4, 4, 236, %Main_Height - 8 ,%TCS_FOCUSNEVER ',%WS_EX_CLIENTEDGE
Control Set Resize hDlg, %cTabControl, 1, 0, 1, 0
TAB_PageInsert hDlg, %cTabControl, 1, , "TREE" Call cbTab1
TAB_PageInsert hDlg, %cTabControl, 1, , "LIST" Call cbTab2
Dialog Set Minsize hDlg, 640, 480
Dialog Show Modal hDlg, Call dlgCallback
End Function
CallBack Function dlgCallback()
Static hCtrl As DWord
Select Case CBMSG
Case %WM_INITDIALOG
Dialog Set Timer CBHNDL, %cTimer, %timeOut, %NULL
Control Handle CBHNDL, %cCanvas To hCtrl
' -- Init OpenGL
TBGL_BindCanvas(hCtrl)
TBGL_UseLighting(%TRUE)
TBGL_UseLightSource(%GL_LIGHT0, %TRUE)
TBGL_SetLightParameter(%GL_LIGHT0, %TBGL_LIGHT_POSITION, 15, 10, 15, 1)
Case %WM_SIZE, %WM_SIZING
TBGL_UpdateCanvasProportions(hCtrl)
RenderMyImage(hCtrl)
TAB_OnResize(CBHNDL, %cTabControl)
Case %WM_TIMER
If CBWPARAM = %cTIMER Then
Dialog Kill Timer CBHNDL, %cTIMER
RenderMyImage(hCtrl)
'Control Set Focus CBHNDL, %lCanvas
Dialog Set Timer CBHNDL, %cTIMER, %TIMEOUT
EndIf
Case %WM_CLOSE
TBGL_ReleaseCanvas(hCtrl)
Dialog Kill Timer CBHNDL, %cTimer
Case %WM_COMMAND
Select Case CBCTL
Case %cClose
If CBCTLMSG = %BN_CLICKED Then Dialog End CBHNDL
End Select
End Select
End Function
CallBack Function cbTab1()
Local lW, lH As Long
Select Case CBMSG
Case %WM_INITDIALOG
Control Add TreeView, CBHNDL, %cTreeView,, 0, 0, 236, %Main_Height - 32 ', %WS_CHILD
Case %WM_SIZE
Dialog Get Client, CBHNDL To lW, lH
Control Set Size, CBHNDL, %cTreeView, 236, lH
End Select
End Function
CallBack Function cbTab2()
Local lW, lH As Long
Select Case CBMSG
Case %WM_INITDIALOG
Control Add Listview, CBHNDL, %cListView, , 0, 0, 236, %Main_Height - 32 ', %WS_CHILD
Case %WM_SIZE
Dialog Get Client, CBHNDL To lW, lH
Control Set Size, CBHNDL, %cListView, 236, lH
End Select
End Function
Function RenderMyImage( hCtrl As DWord )
Static FrameRate As Double
If TBGL_CanvasBound(hCtrl) Then
FrameRate = TBGL_GetFrameRate
TBGL_ClearFrame
TBGL_Camera(5, 5, 5, 0, 0, 0)
TBGL_Box(1, 1, 1)
TBGL_DrawFrame
End If
End Function
and: how can I make a control inside tab keeping it's proportions inside the tab-window (maybe a listview or treeview that should always cover the whole client of tab) - if I use Set Resize inside callback-function it instantly crashes. If I do it like described in Example-Script (TabControl_AdressBook) the treeView and Listview do not resize as they are supposed to. I'm really frustrated by now since I've tried for many hours any logical combinations without any success. I'm gonna skip UI and do all per TBGL now, even the controls. I 'm starting to hate that callback-stuff :evil:
BUGS:
Control Show State does not do anything on ListView + Treeview... only works at Buttons
Dialog Set Text does nothing
TAB_GetSelected returns always the same i.e. returns the value that was set using Tab_SetSelected