FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

CONTROLS

Use CALL SETCTLVALUE


I was wondering if someone out there could help me understand why I can't get SETCTLVALUE to work. I've watched the following in MacsBug, but the ContrlVal% field never gets set (even though the GETCTLVALUE function returns its value just fine):

CLEAR LOCAL
LOCAL FN CheckToggle (CntlH&,MousePt&)
'---> Allocate Variables
  DIM BtnState%, CntlPart%
'---> Convert To Local
  CALL GLOBALTOLOCAL (MousePt&)
'---> Toggle Check Box
  LONG IF (CntlH& <>0)
    CntlPart% = FN TRACKCONTROL (CntlH&,MousePt&,0)
'---> Set Control
    LONG IF (CntlPart% <>0)
      BtnState% = FN GETCTLVALUE (CntlH&)
      BtnState% = 1 - BtnState%
      CALL SETCTLVALUE (CntlH&,BtnState%)
    END IF
  END IF
END FN = BtnState%

On the other hand, when I set it manually it works like a charm:

CLEAR LOCAL
LOCAL FN CheckToggle (CntlH&,MousePt&)
'---> Allocate Variables
  DIM BtnState%, CntlPart%
'---> Convert To Local
  CALL GLOBALTOLOCAL (MousePt&)
'---> Toggle Check Box
  LONG IF (CntlH& <>0)
    CntlPart% = FN TRACKCONTROL (CntlH&,MousePt&,0)
'---> Set Control
    LONG IF (CntlPart% <>0)
      BtnState% = FN GETCTLVALUE (CntlH&)
      BtnState% = 1 - BtnState%
      CntlH&..contrlValue% = BtnState%
      CALL DRAW1CONTROL (CntlH&)
    END IF
  END IF
END FN = BtnState%

I tried replacing the CALLSETCTLVALUE with the assembly version from the original header files, to make sure it wasn't an FB problem, but no luck. I understand why the second version works, but I don't understand why the first one won't. Any hints?

Joe K.


How does the control value you are setting compare to the control's min and max values? If it is out of range, SETCTLVALUE is probably ignoring it - whereas your direct field access bypasses any checks and sets it directly.

Something to look for...

Mars