catventure
17-11-2005, 17:38
Hello,
I've been trying to figure this out:
How do I GET and SET the state of a checkbox, check3box or radiobutton control?
Also, is it yet possible to assign hotkey shortcuts to dialog window button controls? I know you can use ampersand in the button text eg:
"&Button1" puts underline under letter "B". How now to continue?
Any help much appreciated.
catventure.
Petr Schreiber
17-11-2005, 20:12
Hi Catventure,
Control Get Check
It seems that Control Get Check is not yet implemented.
You can emulate it for a while by doing this
* Declare variable, which will keep the check status
DIM CheckFlag AS LONG
* In the main dialog loop, add case for the checkbox control
...
CASE %MYCHECKBOX
CheckFlag = CheckFlag XOR 1
MsgBox 0, "CheckFlag is "+FORMAT$(CheckFlag)
-> when user clicks the checkbox, it will make CheckFlag 1 or 0.
Control Set Check
Solution for Control Set Check could be something like this
%BM_CLICK = &HF5 ' declare this equate at the beginning of source code
Function myControlSetCheck ( dlgHandle AS DWORD, dlgControl AS LONG ) As Long
IF CheckFlag = 0 THEN control send dlgHandle, dlgControl, %BM_CLICK,0,0
End Function
... then by calling myControlSetCheck ( hDlg, %MYCHECKBOX ) this should programaticaly click the checkbox IF is unchecked
Please keep in mind that's a bit dirty way, but it doesn't occur to me other solution now :(
See ya,
Psch
catventure
17-11-2005, 23:44
That code looks interesting, Psch.
The developers may well come up with a more elegant solution for testing and getting the on/off state of a checkbox and check3state controls but your code may suffice as a temporary stopgap measure until then.
I will try it out and see how it goes
catventure
ErosOlmi
18-11-2005, 03:10
Sorry for the delay but today (and I think tomorrow) I had (will have) very little time.
Please find here attached new thinBasic_UI.dll updated module.
I've added:
CONTROL GET CHECK hDlg, id TO lResult
CONTROL SET CHECK hDlg, id, checkstate
CONTROL SET OPTION hDlg, id, minid, maxid
They are exactly like PowerBasic ones.
I will document and released officially during this weekend.
Hopes they work fine.
Here a fast example taken from PB help doc:
uses "UI"
%OPT1 = 101
%OPT2 = 102
%OPT3 = 103
%OPT4 = 104
%OPT5 = 105
MAIN
FUNCTION MAIN() as long
DIM Msg AS LONG
DIM wParam AS LONG
DIM lParam AS LONG
DIM hDlg AS DWORD
dim lResult as long
dim sResult as string
dim Count as long
DIALOG NEW 0, "OPTION control test", -1, -1, _
100, 100, %WS_SYSMENU OR %WS_CAPTION TO hDlg
CONTROL ADD OPTION, hDlg, %OPT1, "Option 1", _
10, 6, 50, 14, %WS_GROUP OR %WS_TABSTOP
CONTROL ADD OPTION, hDlg, %OPT2, "Option 2", _
10, 20, 50, 14
CONTROL ADD OPTION, hDlg, %OPT3, "Option 3", _
10, 34, 50, 14
CONTROL ADD OPTION, hDlg, %OPT4, "Option 4", _
10, 48, 50, 14
CONTROL ADD OPTION, hDlg, %OPT5, "Option 5", _
10, 62, 50, 14
CONTROL ADD BUTTON, hDlg, %IDOK, "OK", _
25, 80, 50, 14, %WS_GROUP OR %WS_TABSTOP
'---Set the initial state to OPTION button 3
CONTROL SET OPTION hDlg, %OPT3, %OPT1, %OPT5
DIALOG SHOW MODELESS hDlg
'---Start the main message loop
WHILE IsWindow(hDlg)
'---Get the message and fill wParam and lParam
Msg = GetMessage(hDlg, wParam, lParam)
SELECT CASE Msg
CASE %WM_COMMAND
'---Test which control has been clicked
SELECT CASE wParam
'---A number was activated
CASE %IDOK
sResult = ""
for Count = %OPT1 to %OPT5
CONTROL GET CHECK hDlg, Count TO lResult
sResult += "Control " & Count & " is " & lResult & $crlf
next
msgbox 0, sResult
END SELECT
CASE %WM_SYSCOMMAND
SELECT CASE wParam
CASE %SC_CLOSE
EXIT WHILE
END SELECT
CASE ELSE
END SELECT
WEND
DIALOG END hDlg
END FUNCTION
Psch, thanks a lot for your support !!!! :D
Eros
catventure
18-11-2005, 10:42
OOH! This a very nice surprise when I woke up this morning!
Thanks ever so much for putting this into the UI module Eros and also thanks to Psch for the workaround code.
I will try it today.
Best wishes,
catventure
catventure
18-11-2005, 17:24
Hi,
Just to let you know I tried the new checkbox commands in my project and they worked without problem.
Regards,
catventure
ErosOlmi
18-11-2005, 18:32
OK, thanks.
I will document and publish during this week-end. I think I will be able to add some more functionalities :P
Ciao
Eros