Checkbox Tri-State

Checkbox Tri-State

Postby sambomb » Wed May 06, 2015 11:18 pm

How to implement the Tri State checkbox?
Image
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Checkbox Tri-State

Postby Enrico Maria Giordano » Thu May 07, 2015 11:50 am

Use BS_AUTO3STATE style.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Checkbox Tri-State

Postby sambomb » 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
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Checkbox Tri-State

Postby Enrico Maria Giordano » Thu May 07, 2015 1:29 pm

This is a sample of how I define it:

Code: Select all  Expand view  RUN
CONTROL "Interni:", 136, "BUTTON", BS_AUTO3STATE | BS_LEFTTEXT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 385, 110, 30, 12


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Checkbox Tri-State

Postby sambomb » Thu May 07, 2015 1: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
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Checkbox Tri-State

Postby Enrico Maria Giordano » Thu May 07, 2015 1:38 pm

Here it is:

Code: Select all  Expand view  RUN
   nCsn = 2

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


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Checkbox Tri-State

Postby sambomb » Thu May 07, 2015 5: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
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Checkbox Tri-State

Postby Enrico Maria Giordano » Thu May 07, 2015 5:13 pm

Please check nCsn variable in my sample above.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Checkbox Tri-State

Postby sambomb » Thu May 07, 2015 5:52 pm

Error description: Error BASE/1003 Variable does not exist: BM_GETCHECK
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Checkbox Tri-State

Postby Enrico Maria Giordano » Thu May 07, 2015 5:57 pm

Code: Select all  Expand view  RUN
// Button messages

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


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Checkbox Tri-State

Postby sambomb » Thu May 07, 2015 6:02 pm

Now It's working fine!
Thanks a lot

Code: Select all  Expand view  RUN


#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
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 71 guests