Jump to content

check box problem


nimaltd

Recommended Posts

this code works ::

    case GEVENT_GWIN_CHECKBOX:
                if(((GEventGWinCheckbox*)pe)->gwin == ghCheckbox_RunMode)
                {
                    
                    if( gwinCheckboxIsChecked(ghCheckbox_RunMode) == FALSE )
                    {
                        RunMode = false;
                        Stop();
                        gwinSetText(ghLabelPlayingItem," Stop!",true);
                    }
                    else
                    {
                        RunMode = true;
                        gwinSetText(ghLabelPlayingItem,"" ,true);
                    }
                    
                }

            break;

 

but this code do not work :: 

    case GEVENT_GWIN_CHECKBOX:
                if(((GEventGWinCheckbox*)pe)->gwin == ghCheckbox_RunMode)
                {
                    
                    if( gwinCheckboxIsChecked(ghCheckbox_RunMode) == FALSE )
                    {
                        RunMode = false;
                        Stop();
                        gwinSetText(ghLabelPlayingItem," Stop!",true);
                    }
                     if( gwinCheckboxIsChecked(ghCheckbox_RunMode) == TRUE )
                    {
                        RunMode = true;
                        gwinSetText(ghLabelPlayingItem,"" ,true);
                    }
                    
                }

            break;

 

Link to comment
Share on other sites

Please tell us exactly what doesn't work. We can't just guess.
This applies to all your posts. Please inform us about the exact issue that you are facing. "Doesn't work" it not helpful at all.

We are not going to look at that code and just guess what could be wrong ;)
I mean... we don't even know if it's a compile error, whether it just doesn't do anything or whether it crashes.

We are of course very happy to help wherever we can. But we need the corresponding information.

Link to comment
Share on other sites

You have to be careful comparing with the define TRUE. C defines any non-zero value as logical true. The define TRUE represents only a single true value from the set of true values. The define FALSE however is the one and only false value.

Note that even in ugfx TRUE will be defined as either 1 or -1 depending on the compiler, the hardware platform and the embedded operating system. Similarly the bool_t type may be a bit, a byte, or even an int. Additionally there is no guarantee that !FALSE == TRUE as that depends on the compiler and the value defined for TRUE. On some compilers the compiler may even give different values for !FALSE in different circumstances. 

In reality this is a consequence of their being no real boolean type in C. Some compilers add a boolean type as a language extension but it is still non-portable and the same problems may still exist depending on the internal machine representation of that type.

Thus to say "if (xxx == TRUE )" is very bad code. You should either say "if (xxx)" or "if (! (xxx == FALSE))".

The define TRUE is thus useful for assignment to a bool_t type but it is worthless as a comparitive value.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...