Robert Meek wrote:
I'm going to have to spend a couple of days and really study up on
pointers.  I've never had a reason to use them until now!  I know that's
hard to believe, but true!  Also, exactly what is the purpose of the
GlobalLock?

MSDN says this: "The GlobalLock function locks a global memory object and returns a pointer to the first byte of the object's memory block."


Thus, before we call GlobalLock, we don't have a pointer to the memory, so we clearly can't access the contents of the memory block.

The global memory functions deal with handles, not the memory itself. This is because global memory can be "moveable" -- the OS can put the allocated memory somewhere else when it decides it needs to current space for something else. In a way, the OS can "defragment" the memory while it's still allocated. But to do this, it needs to have another level of indirection so that programs can refer to their allocated memory without having to have stationary addresses to that memory. GlobalLock tells the OS that we're using the memory and that it must not move it anywhere for the time being.

Since the clipboard handles everything using handles to global memory, we need to call GlobalLock and GlobalUnlock while accessing the memory.

I was referring to specially registered formats, but I found in
the SDK some functions that should be able to give me that information.
Just for simplicity's sake I would probably like to store the formats in a
separate field.  I've used Widestrings ONLY as required by a few API calls
without truly understanding why.  What type could I use to store them...as
TStrings?

Store WideStrings in variables of type WideString. TStrings holds lists of AnsiStrings. A WideString is neither an AnsiString nor a list.


If you have a list of WideStrings, then you can use a TWideStrings object. (It's declared in the WideStrings unit.)

Is there anyway to make use of them without converting them from
their integer values first?  I couldn't find any but that doesn't mean it
isn't possible!

No. The numeric values have no meaning.

Windows NT tends to assign clipboard formats in sequential order. That is, the first registered clipboard format will be assigned the first number, $c000, and the next format will be assigned $c001, etc. Windows 95, on the other hand, uses some kind of hashing mechanism (it may or may not be a true hash table), so format names will usually get the same number, no matter what order they were registered in.

And that's why you can't rely on the numbers. They may refer to different formats the next time you see them. A registered format is valid until you reboot (or perhaps only until you log off, but not likely). Note that there is no UnregisterClipboardFormat function.

--
Rob

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to