Broad Network


A Window Button Function and Macro

Windows Predefined Controls – Part 12

Volume - Windows User Interface

Forward: In this part of the series, we look at a Window Button Function and a Macro.

By: Chrysanthus Date Published: 29 Aug 2012

Introduction

This is part 12 of my series, Windows Predefined Controls. In order to understand this tutorial, you most have read all the previous tutorials of the series. In this part of the series, we look at a Window Button Function and a Macro.

Note: If you cannot see the code or if you think anything is missing (broken link, image absent), just contact me at forchatrans@yahoo.com. That is, contact me for the slightest problem you have about what you are reading.

Reason for this tutorial
The previous tutorial dealt with messages that an application can send to a Button. There are two important things that the messages do not address. However, one of them is addressed by a Button function and the other is addressed by a button macro.

The application needs to be able to go to a group of radio buttons and check (On) one of the buttons in the group; that is done by a button function.

An application should be able disable or enable a button; this is done by the macro.

Checking a Radio Button of a Group
The function to check (put in a dot) a radio button of a group is:

BOOL CheckRadioButton(
    HWND hDlg,
    int nIDFirstButton,
    int nIDLastButton,
    int nIDCheckButton
);

hDlg is a handle to the dialog box that contains the radio button.
nIDFirstButton: is the identifier of the first radio button in the group.
nIDLastButton: is the identifier of the last radio button in the group.
nIDCheckButton: is the identifier of the radio button to select.

The return value is a BOOL. If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.

The Button_Enable Macro
When a button is enabled, the user can use it; when it is disabled, the user cannot use it. A macro is a kind of function. The Button_Enable macro is used to enable or disable a button. The syntax is:

BOOL Button_Enable(
    HWND hwndCtl,
    BOOL fEnable
);

hwndCtl is the handle to the button control.
fEnable is a BOOL. If it is TRUE, the button is enabled. If it is FALSE the button is disabled.

The return value is a BOOL. It is zero if the window was previously disabled; otherwise nonzero.

That is it for this part of the series. We stop here and continue in the next part.

Chrys

Related Courses

C++ Course
Relational Database and Sybase
Windows User Interface
Computer Programmer – A Jack of all Trade – Poem
NEXT

Comments

Become the Writer's Fan
Send the Writer a Message