| RTL referenceGlossary|Tips/Tricks|FREE App/VCL|Best'O'Net|Books|Link To |
| GDI Graphics In Delphi | |||||||||||||||||||||||||
| Page 5: Handles and Stuff | |||||||||||||||||||||||||
Using Handles and Stuff Just about everything in Windows uses a "Handle". The handle is just a way of identifying your object. Windows have handles, buttons have handles, etc. Therefore, you should not be surprised to learn that all your objects have these handles as a property - for example, "MyForm.Canvas.Handle". Here's a quote from Win32.hlp, explaining handles:
"An application must obtain an object handle and use this handle to examine or modify the system resource (or both). In the Microsoft® Win32® application programming interface (API), handles are usually implemented as indirect pointers, but this is not always the case."
The HDC type is a Handle to a Device Context. If you remember from the first part of this tutorial, I said that TCanvas encapsulates most of the DC functions. Well, you just use your object's Canvas Handle whenever Windows wants a HDC. Nice and easy.
Having said all that, I might have confused you. If so, here are some examples of using Windows API functions versus VCL ones. You'll see they are almost the same.
Generally, you just use the same functions as before, but pass in the appropriate handle first. Remember that you can supply different handles to draw to different places. For example, you could use "SomeBmp.Canvas.Handle" to draw to a bitmap, or "Form1.Canvas.Handle" to draw to a form.
One point to be aware of is that Windows wants strings to be passed in as null-terminated. All this means is that instead of passing in your strings directly, you typecast the string as a PChar (see TextOut(), for example). That's all! You might also be required to give the length of the string - if so, just use the Length function.
Okay, now we can draw lines and shapes (and other stuff, like text). However, it would be nice to have some bitmap drawing too...
Question, Suggestions... Next page > Drawing Bitmaps > Page 1, 2, 3, 4, 5, 6, 7, 8, 9
|
|||||||||||||||||||||||||
All graphics (if any) in this feature created by Zarko Gajic.
| More Delphi |
|
· Learn another routine every day - RTL Quick Reference. · Download free source code applications and components. · Talk about Delphi Programming, real time. · Link to the Delphi Programming site from your Web pages. · Tutorials, articles, tech. tips by date: 2001|2000|1999|1998 or by TOPIC. |
|
· NEXT ARTICLE:
Articles. More Delphi articles |
| Stay informed with all new and interesting things about Delphi (for free). |
|
|
| Got some code to share? Got a question? Need some help? |

