How To Use Radio Button

This article will demonstrate how to use radio button using SwinGame’s User Interface.

Level

Advanced

Read these first

How To Move A Panel

Details

In programs that required the used of radio button, to do this it is required SwinGame’s User Interface functionality.

Before you can draw radio button on the screen, it is required two images to be draw represent the active and inactive stage of the radio button and will be stored in the Resources\Images folder.

 

Having drawn the two images and stored them in the Resources\images folder, next step is to add a few lines of text into the configured text file. Snip set of it will be display below.

//active bmp 
a: CheckBoxActiveWithOutText.png 
// Background Image 
b: CheckBoxWithOutText.png 
//inactive bmp 
i: CheckBoxWithOutText.png 
//Draggable 
d: true 
v: false 
 
//Radiobutton r: x, y, w, h, 2, GroupID 
r: 14, 30, 48, 44,RadioGroup, radButton1,RadioGroup1 
r: 143, 30, 48, 44,RadioGroup, radButton2,RadioGroup1 
r: 256, 30, 48, 44,RadioGroup, radButton3,RadioGroup1 

To be able to draw radio button on screen you just have to LoadPanel into your code, then call ShowPanel and call DrawPanels to display it to the screen.

To demonstrate the use of RadioButton a video will be display on the right and below is the code of the program.

Source Code Widget

  • program HowToUseRadioButton;
    uses SwinGame,sgTypes,sgUserInterface;
    
    procedure Main();
    var
        cp : Panel;
    begin
        OpenGraphicsWindow('How To Radio Button ' ,400 ,150 );
        LoadDefaultColors();
        cp := LoadPanel('radioPanel.txt' );
        ShowPanel(cp );
        PanelSetDraggable(cp ,false );
        repeat
            ProcessEvents();
            ClearScreen(ColorWhite );
            DrawInterface();
            UpdateInterface();
            RefreshScreen();
        
        until WindowCloseRequested();
        ReleaseAllResources();
    end;
    begin
        Main();
    end.
    Download Now"
  • #include 
    #include "SwinGame.h"
    int main() 
    {
        panel  cp;
        open_graphics_window("How To Radio Button " ,400 ,150 );
        load_default_colors();
        cp = load_panel("radioPanel.txt" ) ;
        show_panel(cp );
        panel_set_draggable(cp ,false );
        do 
        {
            process_events();
            clear_screen(color_white );
            draw_interface();
            update_interface();
            refresh_screen();
        }
        while ( ! (window_close_requested() ) );
        release_all_resources();
        return 0;
    }
    
    Download Now"
  • Source Code Coming Soon

  • Source Code Coming Soon

  • Source Code Coming Soon

If there is a useful hint you will find it in a box like this

Possibilities

Suggested projects will appear here.