[comp.sys.mac.programmer] Radio Buttons

cws@mbunix.mitre.org (Christopher C. Wilder-Smith) (03/20/90)

Hi,

This is probably a real simple question...

I have written code in the past for the Mac that uses radio buttons on
dialogs, no problem.  Now I have a program where I want radio buttons on
the main window, and although they function correctly, the little dot in
the middle isn't automatically put in as in a dialog.  Do I have to
generate the code for drawing the dot or have I overlooked something
obvious?

Thanks in advance,

Chris



================================================================================
--                                 --------------                             --
---   Christopher C. Wilder-Smith   ------------   Everything serious is     ---
----   The MITRE Corporation         ----------   difficult and almost      ----
-----   Burlington Road               --------   everything is serious     -----
------   Bedford, Massachusetts 01730  ------                             ------
-------   cws@mbunix.mitre.org          ----                             -------
--------                                 --                             --------
================================================================================
--

================================================================================
--                                 --------------                             --
---   Christopher C. Wilder-Smith   ------------   Everything serious is     ---
----   The MITRE Corporation         ----------   difficult and almost      ----
-----   Burlington Road               --------   everything is serious     -----
------   Bedford, Massachusetts 01730  ------                             ------
-------   cws@mbunix.mitre.org          ----                             -------
--------                                 --                             --------
================================================================================

sdh@flash.bellcore.com (Stephen D Hawley) (03/21/90)

In article <103386@linus.UUCP> cws@mbunix.mitre.org (Christopher C. Wilder-Smith) writes:
>Hi,
>
>This is probably a real simple question...
>
>I have written code in the past for the Mac that uses radio buttons on
>dialogs, no problem.  Now I have a program where I want radio buttons on
>the main window, and although they function correctly, the little dot in
>the middle isn't automatically put in as in a dialog.  Do I have to
>generate the code for drawing the dot or have I overlooked something
>obvious?
>
>Thanks in advance,
>
>Chris

Yup, this is not too hard.  What you want to do is something like this:

myRadio = NewControl(ownerWindow, &boundsRect, "\PYour Title here.",
	TRUE /* visible */,
	1 /* value 1 is set, 0 is clear */,
	0 /* minimum */,
	1 /* maximum */,
	radioButProc /* what type of control */,
	myReference /* refCon */);

If the value is 1, it is set.  If it is zero, it is clear.  If you pull the
control up from a resource file, use SetCtlValue() to change the default.

eg, SetCtlValue(myRadio, 1); /* turn it on */
    SetCtlValue(myRadio, 0); /* turn it off */

Steve Hawley
sdh@flash.bellcore.com
"I'm sick and tired of being told that ordinary decent people are fed up with
being sick and tired.  I know I'm certainly not, and I'm sick and tired of
being told that I am."