Professional Web Applications Themes

What's a "RefCon"? - Mac Programming

I'm trying to learn about callback functions, although I haven't found anything yet that doesn't assume a high level of familiarity with them. But just for starters, can someone tell me what a refCon is and what it does? All these doents seem to take it for granted that you know what it is and what it does, but I don't. Thanks! CT...

  1. #1

    Default What's a "RefCon"?

    I'm trying to learn about callback functions, although I haven't found
    anything yet that doesn't assume a high level of familiarity with them.

    But just for starters, can someone tell me what a refCon is and what it
    does? All these doents seem to take it for granted that you know
    what it is and what it does, but I don't.

    Thanks!

    CT
    Charles Guest

  2. #2

    Default Re: What's a "RefCon"?

    In article <doit.wisc.edu>,
    Charles Thomas <facstaff.wisc.edu> wrote:
     

    It's a field in a structure (eg in a WindowRecord) that's usually for
    the programmer to use (for instance, to store a pointer to some data
    related to the window). IIRC, in some cases this was also used to
    communicate with the operating system.

    It's probably described in Macintosh Toolbox Essentials :
    http://developer.apple.com/doentation/mac/Toolbox/Toolbox-2.html

    Patrick
    --
    Patrick Stadelmann <ch>
    Patrick Guest

  3. #3

    Default Re: What's a "RefCon"?

    In article <doit.wisc.edu>,
    Charles Thomas <facstaff.wisc.edu> wrote:
     

    That's because, by design, *ONLY YOU* can actually know what a specific
    instance of a refcon is/does. "RefCon" = "Reference Constant". It just
    so happens that it's a snippet of storage that's exactly large enough
    (in bytes) to be a perfect place to park a pointer to much more involved
    data. It can also be used as a sort of "status flag", or an input or
    output value for functions that operate on whatever struct contains the
    refcon, or even a pointer to a function (or list of functions) that do
    something for/with the structure the refcon is associated with. Quite
    frankly, the only limit to what can be done with a refcon is your
    imagination.

    A common use is for the refcon of a window record to hold a pointer to a
    buffer containing the data the window will be displaying, and/or related
    data such as where the cursor should be displayed when that window is
    active, what font/size the text in the window should be displayed in/at,
    or any number of other things. Other uses include passing context
    information between routines that work with structures that contain a
    refcon field.

    In the final ysis, a refcon is *YOUR BABY*. What it is, what it
    does, and how it gets used are completely up to you. The system itself
    does nothing with them, other than provide the storage space.

    --
    Don Bruder - net <--- Preferred Email - SpamAssassinated.
    Hate SPAM? See <http://www.spamassassin.org> for some seriously great info.
    I will choose a path that's clear: I will choose Free Will! - N. Peart
    Fly trap info pages: <http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>
    Don Guest

  4. #4

    Default Re: What's a "RefCon"?

    In article <vhFKb.6982$sonic.net>,
    Don Bruder <net> wrote:
     
    >
    > That's because, by design, *ONLY YOU* can actually know what a specific
    > instance of a refcon is/does. "RefCon" = "Reference Constant". It just
    > so happens that it's a snippet of storage that's exactly large enough
    > (in bytes) to be a perfect place to park a pointer to much more involved
    > data. It can also be used as a sort of "status flag", or an input or
    > output value for functions that operate on whatever struct contains the
    > refcon, or even a pointer to a function (or list of functions) that do
    > something for/with the structure the refcon is associated with. Quite
    > frankly, the only limit to what can be done with a refcon is your
    > imagination.
    >
    > A common use is for the refcon of a window record to hold a pointer to a
    > buffer containing the data the window will be displaying, and/or related
    > data such as where the cursor should be displayed when that window is
    > active, what font/size the text in the window should be displayed in/at,
    > or any number of other things. Other uses include passing context
    > information between routines that work with structures that contain a
    > refcon field.
    >
    > In the final ysis, a refcon is *YOUR BABY*. What it is, what it
    > does, and how it gets used are completely up to you. The system itself
    > does nothing with them, other than provide the storage space.[/ref]

    Thanks to both of you. This was very helpful. As it happens, I used
    RefCons back in the old days of Mac OS programming (six years ago or
    so), but didn't think this could possibly be the same thing.

    Actually, it's exactly the same thing.

    Thanks again!

    CT
    Charles Guest

Similar Threads

  1. Replies: 1
    Last Post: April 24th, 01:27 PM
  2. CFINPUT type="radio" w/ "value" requires "label"
    By Iceborer in forum Macromedia ColdFusion
    Replies: 2
    Last Post: February 21st, 06:16 PM
  3. dr("field").toString returns "400.0000" instead of "400"
    By Dan C Douglas in forum ASP.NET General
    Replies: 5
    Last Post: July 22nd, 05:48 PM
  4. "Start" "Program" "Menu" list is empty
    By Pete in forum Windows XP/2000/ME
    Replies: 2
    Last Post: July 10th, 10:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139