Author Topic: 3. IWBasic Windows  (Read 1060 times)

0 Members and 1 Guest are viewing this topic.

Offline LarryMc

  • Administrator
  • Hero Member
  • *****
  • Posts: 5934
  • 'All I like is finishing'
3. IWBasic Windows
« on: July 25, 2011, 06:27:33 PM »
In order to really understand where we are going with custom controls it is important to understand why we do some of the things we do with windows. The following discussion uses portions of the IWBasic User's Guide.

Opening a window in IWBasic is extremely easy.  We use the following command line:

Code: [Select]
OPENWINDOW variable, left, top, width, height, flags, parent, title, handler

First and foremost, we must understand that this is simply a call to a function (a subroutine that returns a value) that is sent nine parameters (pieces of information) to use to do whatever the subroutine has to do to open our window.  Let's look at those parameters.


This identifies this specific window.  Any given program may have many windows.  That being the case the uniqueness of this variable name is how we tell them apart.  This is a special type of variable called a User Defined Type (UDT). In this case it is a little of a misnomer since the User doesn't define this one; it is predefined by IWBasic.  The fundamental characteristic of UDTs is that they are single variables made up of multiple pieces of data. This particular UDT is of type WINDOW. This designation is purely an arbitrary name that was assigned to it when the language was created.  Outside of IWBasic, the Windows OS has no idea what it is or what it is used for.

The structure of this WINDOW UDT is defined as:

Code: [Select]
DEF hWnd as UINT
DEF hBitmap as UINT
DEF hFont as UINT
DEF hPen as UINT
DEF hClient as UINT
DEF m_pos as POINT
DEF m_iBkMode as INT
DEF m_iROP2 as INT
DEF m_nPenStyle as INT
DEF m_nPenWidth as INT
DEF m_cBack as UINT
DEF m_cWindow as UINT
DEF m_bAutoDraw as INT
DEF m_bTabEnable as UINT
DEF m_hCursor as UINT
DEF m_hBackDC as UINT
DEF m_hCacheDC as UINT
DEF m_nCacheCount as INT
DEF m_bDialog as INT
DEF m_pDlgTemplate as POINTER
DEF m_pIB2DScreen as POINTER
DEF m_pIB2DSurface as POINTER
DEF hProcedure as UINT
DEF m_pBrowser as POINTER
DEF m_hPrintDC as UINT

It is beyond the scope of this tutorial to describe the purpose of each element of the UDT structure.  However, there are several things that should be noted from looking at the above.

 - It requires that a lot of information be generated to create an IWBasic window.
 - We, as the users, are not required to provide any of that information other than a name for the UDT variable.
 -The OPENWINDOW subroutine must be dealing with all that for us.

Later we will be referring back to this UDT.

left, top, width, height

Pretty straight-forward.  All four values are in pixels. Left/Top are relative to the upper left corner of the User's screen.
The point here being that we're defining how big the window is and where it is located.


Normally referred to as Style flags.  This is a single UINT whose individual bits each have some specific impact on the appearance or functionality of the window. Usually, to make things easier to read, each bit is given a CONST definition representing one bit and various bits are or'd together with the' |' operator.
 An example would be:
Code: [Select]

The WINDOWS variable that identifies the parent of the window being created, if there is one.  If there is no parent then a NULL or 0 is entered.


The text that will appear in the caption bar at the top of the window.  If the window has no caption bar (style flag option) or no text is desired "" is entered.  Titles are not mandatory.


This entry is a pointer to a message handler subroutine created by the User. Each window has to have a handler routine to do what - handle its messages.  Message Handlers is a whole separate subject covered in the next section.

« Last Edit: July 26, 2011, 05:48:13 AM by LarryMc »
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library