Special

Clearance Sale!

We've been publishing for over five years now and it's time to clear out our inventory of back issues, so we're slashing prices!

RBD Magazines

Check out this amazing clearance sale of all our past issues. Missing some issues? This is a great time to complete your RBD collection. Save up to 40% off the regular price of our printed back issue packages. These prices are only good until the end of the year May 2008 and supplies are limited, so place your order today.

Article Preview


Buy Now

Print:
PDF:

Intel corner

Printing Rotated Text

Using declares to draw a rotated string on Windows.

Issue: 3.6 (July/August 2005)
Author: Christian Schmitz
Author Bio: Christian Schmitz is the creator of the Monkeybread Software REALbasic Plugins.
Article Description: No description available.
Article Length (in bytes): 7,916
Starting Page Number: 42
RBD Number: 3620
Resource File(s):

Download Icon 3620.sit Updated: Monday, July 25, 2005 at 11:27 AM

Related Link(s): None
Known Limitations: None

Excerpt of article text...

Recently a REALbasic user asked in the REALbasic newsgroup (comp.lang.basic.realbasic) about how to get the Windows device handle of a graphics object. He needed to talk directly to the Windows API to do some special things like printing rotated text. This article will show how to do this.

How to get the handle

The first difficulty is getting the actual handle. In C, an HDC is a handle for the device context. In REALbasic we can use a simple integer for this. To get it, you currently need a plugin. The MBS Plugins include a "graphics.HandleMBS as integer" function which can be used without registering the plugin collection. Depending on reader feedback we may also offer a special REALbasic Developer plugin for this function in the future.

The HandleMBS function can be used like this in REALbasic:

dim g As Graphics

g = OpenPrinterDialog

if g <> nil then

msgbox hex(g.handleMBS) // Show handle as hex number

end if

What we need for the declares

We declare some functions from the Windows GDI API. First is CreateFontIndirectA, which loads a font object to memory. This is the ANSI function, which is not Unicode-savvy, but always present. The newer Unicode version, CreateFontIndirectW, is not installed with Windows 98. You can of course change the example to support Unicode. This function needs a pointer to a LOGFONTA data structure which is displayed in a comment inside the code below. This structure contains various parameters for the font needed and we will use them later. The returned value is a handle for the new font object.

...End of Excerpt. Please purchase the magazine to read the full article.

Article copyrighted by REALbasic Developer magazine. All rights reserved.


 


|

 


Weblog Commenting and Trackback by HaloScan.com