3.3. tsContextBind

Syntax

Pascal

procedure tsContextBind(ContextID: tsContextID);

C/C++

void tsContextBind(tsContextID ContextID);

Description

This function will bind an context to the current thread. It's not possible to bind more than one contexts to an single thread. An thread can have only one context. You only can access an context from the thread where it was bound. An context only can be bound to one thread at the same time. If you bind an context in an thread in which an other context are still bound the binding will be released and the new will be bound. If you try to bind an context to more than one thread at the same time the calls do nothing instead of setting the TS_INVALID_OPERATION error code.

[Important] Important

If you frees an thread in which an context is still bound you can't access this context anymore. The context is locked to the other thread and you only can unbind or free them in the other thread. The only way to destroy the context is to quit the whole library with tsQuit.

[Tip] Tip

All contexts has it's own space for all settings and parameter. So if you rebind an previous used context all stay unchanged since you have unbind him. Also the last bound font is still bound.

Params

ContextID

The ID of the context that will be bound. If you pass 0 to this function the current bound context will be released and no context is bound to the thread.

Error Codes

TS_NOT_INITIALIZED

You are not able to bind an context if the library is not intialized. See also tsInit.

TS_INVALID_OPERATION

If you try to bind an context that is currently bount to an other thread.

TS_INVALID_VALUE

If you pass an ID of context that dosn't exists.