Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview

Buy Now

Issue 3.1


Custom Controls

A lesson and practice session

Issue: 3.1 (September/October 2004)
Author: Owen Yamauchi
Author Bio: Owen Yamauchi is a freelance programmer who has been programming REALbasic since version F4. He is the lead programmer for Domain Softworx, a company that produces developer tools for REALbasic.
Article Description: No description available.
Article Length (in bytes): 9,786
Starting Page Number: 36
Article Number: 3117
Resource File(s):

Download Icon 3117.zip Updated: 2013-03-11 19:07:58

Related Link(s): None

Excerpt of article text...

News: the recently released REALbasic (RB) 5.5 has a new feature that should be appreciated by Visual Basic (VB) users. Long lines of code can be split using the underscore character, like in VB. That's one less syntax difference to worry about.

If you've ever tried to make a custom control in VB, you've probably been driven insane by how difficult it is. However, there are often times when you want to make custom controls in the course of your development work. Perhaps there's a specific type of WinSock that you want to use in more than one project, or a Text control that behaves differently. As we've covered in a previous column, RB makes these tasks easy to perform with its class and class interface structures.

However, what about another type of custom control: one that does not resemble an existing control at all? VB provides a facility to do this, but it is also maddening. You have to draw the control on a little area like the Form Editor, giving you limited options for what the control can look like. You can make a custom control easily with RB's classes. Since you've never heard of classes unless you've taken an object-oriented programming course, this might seem intimidating at first. In this column, I'll walk you through the process of creating a custom control that allows the user to resize controls by dragging a handle.

First of all, let's see what is going to contrast with the VB process of making custom controls. The menu command we'll use is "New Class", not "New Control". We'll be drawing the handle with code, not with Line objects. We'll also be able to make the control do absolutely whatever we want, not be constrained to putting other existing controls together.

To start with, choose "New Class" from the File menu. Select "Class1", which has just appeared in the Project window, and rename it "Resizer". Change its superclass to "Canvas". The Canvas control is one of the things that makes RB development so easy. A Canvas is simply an area of the screen on which you can draw stuff. It also responds to mouse and keyboard events, so it's very versatile. Almost any custom control is built on a Canvas. Remember that for future reference.

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