Forum Navigation
You need to log in to create posts and topics.

Re: File Style

Posted by: rbrown <rbrown@...>

Brian wrote:
> I'd like to know what the "best" way is to attach data to a window,
> avoiding global variables if at all possible. I'm thinking along the lines
> of giving a window a pointer to a data structure when I open it. The data
> structure would contain a handle to the file, file prefs, etc. The demos
> I've seen have all either stored such information in a global or in an edit
> field in the window. If a global variable is necessary, how can I attain
> this as simply and as efficiently as possible?

Something I've done in the past is this: create an array of global
long-integers, like this:

DIM gWindowDataH&(255)

Then, when you create window "n", allocate a relocatable block of
whatever size is appropriate, and store its handle in gWindowDataH&(n).
For example:

gWindowDataH&(windowID) = FN NEWHANDLE(_dataSize)

Now you have an easily-identifiable block of data for every window.

- Rick