Author Topic: 10. Control Required Components  (Read 852 times)

0 Members and 1 Guest are viewing this topic.

Offline LarryMc

  • Administrator
  • Hero Member
  • *****
  • Posts: 5991
  • 'All I like is finishing'
10. Control Required Components
« on: August 16, 2011, 08:34:12 PM »
Here we are on the verge of actually writing some code for our custom control.  Now is a good time for us to discuss what the required components for a custom control are.  Notice that I said "a" custom control and not "our" custom control.  That is because this tutorial covers almost all the required components of any custom control.  The reason I say "almost" is because of the particular custom control we will create in this tutorial. It doesn't need a couple of the required components.

It should be obvious, after the amount of time spent talking about message handlers, that we will need our own custom message handler. Message handlers respond to messages.  We know, from the previous discussions, that the OS sends a lot of messages and we can pick and choose what messages we will write code for. We will need to handle the @IDPAINT / WM_PAINT message since that is where we will actually draw the control. As we proceed we will also address a couple of other OS messages we will need to use.

We will also need some user defined messages so that the user's application can communicate with our control to configure it and to update the pointers.

We could just use the SENDMESSAGE command to send the messages (with  our information) to our control, but instead, we will create commands the user can use.

Since our custom control message handler will have to handle an unlimited number of our controls in any given user application we have to have a way to store the configuration/runtime information that is unique for each instance of our control.  The OS gives us several methods of doing this.  We will use the method of my choosing and briefly mention the others that I discovered.

The OS won't send any messages to our handler until we register it as a class with the OS.  So we will have to address that.

Can't forget that we have to have a way for the user to create an instance of our control.  We could structure things so the CONTROLEX command could be used. However, I chose to create a custom command like was done in IWBasic's ControlPak.

When we create the lib that we will share, we will also need to create an include file (*.inc) for the user that contains all the required declarations to support our control.

And finally, we need to create some sort of help discussion to given the user the necessary information in order to properly implement our control.

With that said, we have finally arrived at the point of writing some code.

________________________

Coming Next - Creating a Skeleton Project
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library