FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Checkbox Tri-State
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Checkbox Tri-State
Posted: Wed May 06, 2015 11:18 PM
How to implement the Tri State checkbox?
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Checkbox Tri-State
Posted: Thu May 07, 2015 11:50 AM

Use BS_AUTO3STATE style.

EMG

Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: Checkbox Tri-State
Posted: Thu May 07, 2015 12:23 PM

Use Where?
In the Pelles C I found, but I dont know what class to (re)define

Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Checkbox Tri-State
Posted: Thu May 07, 2015 01:29 PM
This is a sample of how I define it:

Code (fw): Select all Collapse
CONTROL "Interni:", 136, "BUTTON", BS_AUTO3STATE | BS_LEFTTEXT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 385, 110, 30, 12


EMG
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: Checkbox Tri-State
Posted: Thu May 07, 2015 01:33 PM

Enrico, I use redefine, I think that I can change the TCheckbox class to work with 3 states or maybe create a new class with inheritance from TCheckbox.
But I hope that there is a easier way

Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Checkbox Tri-State
Posted: Thu May 07, 2015 01:38 PM
Here it is:

Code (fw): Select all Collapse
    nCsn = 2

    REDEFINE CHECKBOX oCsn VAR csn;
             ID 111 OF oDlgAna;
             ON CLICK ( ::SendMsg( BM_SETCHECK, ( nCsn + 1 ) % 3 ),;
                        nCsn := ::SendMsg( BM_GETCHECK ) )


EMG
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: Checkbox Tri-State
Posted: Thu May 07, 2015 05:06 PM

Enrico, this code didn't work right...
I want to change the var to work as a integer instead of logical
0 = Unchecked
1 = Checked
2 = Full Checked

Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Checkbox Tri-State
Posted: Thu May 07, 2015 05:13 PM

Please check nCsn variable in my sample above.

EMG

Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: Checkbox Tri-State
Posted: Thu May 07, 2015 05:52 PM

Error description: Error BASE/1003 Variable does not exist: BM_GETCHECK

Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Checkbox Tri-State
Posted: Thu May 07, 2015 05:57 PM
Code (fw): Select all Collapse
// Button messages

#define BM_GETCHECK 240
#define BM_SETCHECK 241
#define BM_GETSTATE 242
#define BM_SETSTATE 243
#define BM_SETSTYLE 244


EMG
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: Checkbox Tri-State
Posted: Thu May 07, 2015 06:02 PM
Now It's working fine!
Thanks a lot

Code (fw): Select all Collapse
#include "fivewin.ch"

#define BM_GETCHECK 240
#define BM_SETCHECK 241
#define BM_GETSTATE 242
#define BM_SETSTATE 243
#define BM_SETSTYLE 244

Procedure TestTriCheck()

Private oDlg, oChk, lChk, nChk := 0, oBtnTest, oBtnExit

   Define   Dialog      oDlg;
            Resource    "DIALOG_TEST";
            Of          oWnd

   Redefine CheckBox    oChk;
            var         lChk;
            Update;
            ID          101;
            Of          oDlg;
            ON CLICK  ( oChk:SendMsg( BM_SETCHECK, ( nChk+ 1 ) % 3 ),;
                        nChk := oChk:SendMsg( BM_GETCHECK ) )

   Redefine ButtonBmp   oBtnTest;
            ID          102;
            of          oDlg;
            Prompt      "Test ";
            action      MsgInfo(Str(nChk));
            Update;
            TextRight

   Redefine ButtonBmp   oBtnExit;
            ID          103;
            of          oDlg;
            Prompt      "End ";
            action      oDlg:End();
            Update;
            TextRight
                        
   Activate Dialog      oDlg;
            CENTER
            
Return
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2

Continue the discussion