INF: Conditionally Activating a Button in Windows Help

ID Number: Q76534

3.10

WINDOWS

Summary:

An application can add buttons to the Windows 3.1 Help engine button

bar. There may be times when the button should be activated or

deactivated based on an external condition.

For example, if an application adds a tutorial button to the bar and

the user has not chosen to install the tutorial, the button should be

dimmed to indicate that the tutorial is not available.

The following code fragment demonstrates activating and deactivating

buttons using the macro facility of the Windows Help engine, version

3.1:

char szMacro[255];

.

.

.

/* Bring up the Help engine with the HLP file */

/* This code fragment assumes that a button has */

/* been defined with an ID of TUTORIAL_BUTTON */

WinHelp (hWnd, lpHelpFile, HELP_CONTENTS, 0L)

if (fTutorial)

/* If the tutorial is installed, the macro should enable the button */

lstrcpy(szMacro,"EnableButton('TUTORIAL_BUTTON')");

else

/* If the tutorial is not installed, the macro should disable the

button */

lstrcpy(szMacro,"DisableButton('TUTORIAL_BUTTON')");

/* Run the appropriate macro */

WinHelp (hWnd, lpHelpFile, HELP_COMMAND, (LONG)szMacro);

Additional reference words: 3.10 3.1 grayed out disabled unavailable