View Full Version : problem with statusbar sizegrip
I created a statusbar but somehow the window does not stretch when I click on the sizegrip (and hold the left mousekey).
I saw the sizegrip working correctly in other thinbasic examples, but I can't figure out what I am doing wrong.
This is my code for the statusbar:
Control Add statusbar, cbhndl, %statusbar1, "", , , , , %SBARS_SIZEGRIP | %CCS_BOTTOM | %WS_CHILD
Any help?
Petr Schreiber
11-07-2009, 18:53
Hi Martin,
if I understand it correctly, you want to be able to resize your window?
To do this, simply add style %WS_THICKFRAME to dialog.
USES "UI"
' -- ID numbers of controls
Begin Const
%sbrStatus = 1000
End Const
' -- Create dialog here
FUNCTION TBMAIN()
LOCAL hDlg AS DWORD
DIALOG New 0, "<Enter title here>",-1,-1, 160, 120, _
%WS_MAXIMIZEBOX | _
%WS_MINIMIZEBOX | _
%WS_SYSMENU | _
%WS_THICKFRAME | _ ' <-- HERE
%WS_CLIPCHILDREN | _
%WS_CLIPSIBLINGS _
to hDlg
' -- Place controls here
CONTROL ADD STATUSBAR, hDlg, %sbrStatus, "Status bar", 0, 0, 0, 0, %SBARS_SIZEGRIP | %CCS_BOTTOM | %WS_CHILD | %WS_VISIBLE
DIALOG SHOW MODAL hDlg, CALL dlgProc
END FUNCTION
' -- Callback for dialog
CALLBACK FUNCTION dlgProc()
' -- Test for messages
SELECT CASE CBMSG
CASE %WM_INITDIALOG
' -- Put code to be executed after dialog creation here
CASE %WM_COMMAND
' -- You can handle controls here
'SELECT CASE CBCTL
'
' CASE ...
' IF CBCTLMSG = ... THEN
'
' END IF
'
'END SELECT
CASE %WM_CLOSE
' -- Put code to be executed before dialog end here
END SELECT
END FUNCTION
Petr
Hi Petr,
My form (window) can be resized by the user, that works fine. But I also want that the form can be resized when the user drags the sizegrip of the statusbar. %WS_THICKFRAME does not what I want. Thanks anyway for your help!
Petr Schreiber
11-07-2009, 19:37
Hi Martin,
could you explain more on your idea?
On my PC, when I click on the grip ( little triangle in the lower-right corner ), I can then size the dialog as I want, I thought this is what you need.
Do you use latest beta or older release?
Petr
Hi Martin,
could you explain more on your idea?
On my PC, when I click on the grip ( little triangle in the lower-right corner ), I can then size the dialog as I want, I thought this is what you need.
Do you use latest beta or older release?
Petr
That's exactly what I mean. I use the latest beta version, but as i said TB-examples with statusbar are working fine but it seems there's something wrong with my own script. Very strange :-S
Petr Schreiber
11-07-2009, 20:05
Do you use CALLBACK mechanism or older GetMessage queries?
I use getMessage queries, but if it helps I can use callback too. But as far as I have seen in the examples a callback or message-check is not necessary. Maybe I should post my code here, but my script is large and i don't want to make it public at this moment.
Petr Schreiber
11-07-2009, 21:28
Hi Martin,
I think we found the reason :)
GetMessage, as help file says, is deprecated function. Please port your code to CALLBACK syntax as soon as possible, it has only benefits, you will see.
If you need guide how to do so, please read brief article in ThinBASIC Journal #2 (http://community.thinbasic.com/index.php?topic=2310.msg17554#msg17554). On page 9 there is side by side comparison of old and new approach, you will see the changes are little, but speed and precision will go up and CPU usage down.
Petr
Petr, Thank you very much!
I will study this and let you know if it helped.
I need some sleep now, good night!
Martin
Sorry I was confused yesterday, I AM using callback method. However i still don't know how to solve this problem :?
Here are snippets of my script:
DIALOG New 0, "Mart Mix Player v1.0",-1,-1, val(xx),val(yy),%WS_CLIPCHILDREN or %WS_OVERLAPPEDWINDOW, 0 To WindowMain
DIALOG SHOW MODAL WindowMain CALL WindowMainProc
CALLBACK FUNCTION WindowMainProc() AS LONG 'Callback for dialog
SELECT CASE CBMSG 'Test for messages
CASE %WM_INITDIALOG
local xpos,ypos as long
dialog get client WindowMain to xPos, yPos
DIALOG SET TIMER windowmain, %timer2, 500
CONTROL ADD TAB, cbhndl, %ID_Main_TAB, "", 0, 0, xpos,ypos call cbtabmain
control untheme cbhndl, %ID_Main_TAB
TAB_PageInsert cbhndl, %ID_Main_TAB, 1, 0, "Player" call cb_Tab_1
TAB_PageInsert cbhndl, %ID_Main_TAB, 2, 0, "Mood" call cb_Tab_2
TAB_PageInsert cbhndl, %ID_Main_TAB, 3, 0, "Database" call cb_Tab_3
TAB_PageInsert cbhndl, %ID_Main_TAB, 4, 0, "Preferences" call cb_Tab_4
TAB_PageInsert cbhndl, %ID_Main_TAB, 5, 0, "Help" call cb_Tab_5
TAB_PageInsert cbhndl, %ID_Main_TAB, 6, 0, "About" call cb_Tab_6
TAB_SetSelected(cbhndl, %ID_Main_TAB,3)
control set resize cbhndl, %ID_Main_TAB, 1, 1, 1, 1
case %WM_SIZE
TAB_OnResize(cbhndl, %ID_Main_TAB)
case %WM_DESTROY
TAB_OnDestroy(cbhndl, %ID_Main_TAB)
case %WM_NOTIFY
select case cbCTL
case %ID_Main_TAB
TAB_OnNotify(cbhndl, %ID_Main_TAB, cblparam)
end select
CASE %WM_COMMAND
select case CBCTL
case %CMD_PLAY
ON_CMD_PLAY(cbhndl, %listview1)
case %ID_Main_TAB
TAB_OnNotify(cbhndl, %ID_Main_TAB, cblparam)
end select
CASE %WM_CLOSE
stop
END SELECT
END FUNCTION
callback function cb_Tab_3()
select case cbMsg
case %WM_INITDIALOG
CONTROL ADD LABEL, cbhndl, %label1, "", 10, ypos-40, 590, 25, %WS_CHILD
Control Add statusbar, cbhndl, %statusbar1, "", , , , , %SBARS_SIZEGRIP | %CCS_BOTTOM | %WS_CHILD
StatusBar_SetParts cbhndl, %statusbar1, 150,350,550,750
case %WM_SIZE
case %WM_DESTROY
end select
end function
Petr Schreiber
12-07-2009, 11:07
Hi Matrin,
and here it works as it should or still not?
uses "UI"
dim WindowMain as dword
dim xx, yy as long
xx= 300
yy= 200
begin const
%ID_Main_TAB = 1000
%timer2
%label1
%statusbar1
end const
DIALOG New 0, "Mart Mix Player v1.0",-1,-1, xx,yy,%WS_CLIPCHILDREN or %WS_OVERLAPPEDWINDOW, 0 To WindowMain
DIALOG SHOW MODAL WindowMain CALL WindowMainProc
CALLBACK FUNCTION WindowMainProc() AS LONG 'Callback for dialog
SELECT CASE CBMSG 'Test for messages
CASE %WM_INITDIALOG
local xpos,ypos as long
dialog get client WindowMain to xPos, yPos
' -- Status
Control Add statusbar, cbhndl, %statusbar1, "", , , , , %SBARS_SIZEGRIP | %CCS_BOTTOM | %WS_CHILD
DIALOG SET TIMER windowmain, %timer2, 500
CONTROL ADD TAB, cbhndl, %ID_Main_TAB, "", 0, 0, xpos, ypos -15 'call cbtabmain
control untheme cbhndl, %ID_Main_TAB
TAB_PageInsert cbhndl, %ID_Main_TAB, 1, 0, "Player" 'call cb_Tab_1
TAB_PageInsert cbhndl, %ID_Main_TAB, 2, 0, "Mood" 'call cb_Tab_2
TAB_PageInsert cbhndl, %ID_Main_TAB, 3, 0, "Database" call cb_Tab_3
TAB_PageInsert cbhndl, %ID_Main_TAB, 4, 0, "Preferences" 'call cb_Tab_4
TAB_PageInsert cbhndl, %ID_Main_TAB, 5, 0, "Help" 'call cb_Tab_5
TAB_PageInsert cbhndl, %ID_Main_TAB, 6, 0, "About" 'call cb_Tab_6
TAB_SetSelected(cbhndl, %ID_Main_TAB,3)
control set resize cbhndl, %ID_Main_TAB, 1, 1, 1, 1
case %WM_SIZE
TAB_OnResize(cbhndl, %ID_Main_TAB)
case %WM_DESTROY
TAB_OnDestroy(cbhndl, %ID_Main_TAB)
case %WM_NOTIFY
select case cbCTL
case %ID_Main_TAB
TAB_OnNotify(cbhndl, %ID_Main_TAB, cblparam)
end select
CASE %WM_COMMAND
select case CBCTL
case %CMD_PLAY
ON_CMD_PLAY(cbhndl, %listview1)
case %ID_Main_TAB
TAB_OnNotify(cbhndl, %ID_Main_TAB, cblparam)
end select
CASE %WM_CLOSE
stop
END SELECT
END FUNCTION
callback function cb_Tab_3()
local ypos as long = 0
select case cbMsg
case %WM_INITDIALOG
CONTROL ADD LABEL, cbhndl, %label1, "", 10, ypos-40, 590, 25', %WS_CHILD
StatusBar_SetParts cbhndl, %statusbar1, 150,350,550,750
case %WM_SIZE
case %WM_DESTROY
end select
end function
I moved the statusbar to be local to main dialog, not to tab control.
Petr
YES! It works fine now! Many thanks for your help Petr!! :eusaclap:
Petr Schreiber
12-07-2009, 12:35
I am happy it worked :)
Important is to keep the lower border of nested tab control not overlapping the statusbar.
In the code in previous post I hardcoded value of 15, but that is not precise.
I recommend precise measurements like:
' -- Add statusbar
Control Add statusbar, cbhndl, %statusbar1, "", , , , , %SBARS_SIZEGRIP | %CCS_BOTTOM | %WS_CHILD
' -- Get dialog client and control area
dialog get client WindowMain to dWidth, dHeight
control get size cbhndl, %statusbar1 to sbWidth, sbHeight
' -- Add properly sized TAB control
CONTROL ADD TAB, cbhndl, %ID_Main_TAB, "", 0, 0, dWidth, dHeight - sbHeight