Each window in an application requires a window structure: even control windows. A window structure for an application's main window might look like this.
LHWINDOW MyTopWindow={MyTopHandler,
0,0,640,190,
&msgAppTopLine,0,
0,0,
NULL,MyFKeys,TopMenu,NO_HELP};
This sets up a window called MyTopWindow that uses MyTopHandler to process the window's messages. The size of the window is full screen except the function key area, has a title pointed to by msgAppTopLine, and function keys and menu called MyFKeys and TopMenu.
A dialog window, its controls, and associated data might look something like this:
/* Prototype for function key handlers */
void far CompleteMyDialog(void);
/* Actual data buffers that are filled in by the user */
char NameBuffer[50];
int IsEccentric;
int Gender;
/* Titles of the dialog, controls, and function keys */
char far *msgMyDialogTitle ="A Silly Dialog Example";
char far *msgNameTitle ="Name";
char far *msgEccentricTitle ="Eccentric?";
char far *msgSex ="Gender";
char far *msgFemale ="Female";
char far *msgMale ="Male";
char far *fkeyOK ="OK";
char far *fkeyCancel ="Cancel";
/* Function keys used by the dialog */
LHFKEY MyFKeys[] = {
{ &fkeyCancel, (PFUNC)CMD_ESC, 9, FKEY_SENDMSG},
{ &fkeyOK, CompleteMyDialog, 10+LAST_FKEY,0}
};
/* Array of dialog controls for MyDialogBox */
LHWINDOW MyDialogArray[]={
{Edit,10,15,24,1, /* 0 = Name */
&msgNameTitle,NameBuffer,
sizeof(NameBuffer),
EDIT_INSERT|STYLE_WHCHAR,NULL,PARENT_FKEYS,NO_MENU,NO_HELP},
{CheckBox,496,39,1,1, /* 1 = Eccentric */
&msgEccentricTitle,(PLHDATA)IsEccentric,
1,STYLE_WHCHAR,NULL,PARENT_FKEYS,NO_MENU,NO_HELP},
{GroupBox,306,61,329,37, /* 2 = Sex */
&msgSex,NULL,
0,0,NULL,PARENT_FKEYS,NO_MENU,NO_HELP},
{RadioButton,426,76,1,1, /* 3 = Female */
&msgFemale,(PLHDATA)Gender,
`F',0,MyDialogArray+2,PARENT_FKEYS,NO_MENU,NO_HELP},
{RadioButton,514,76,1,1, /* 4 = Male */
&msgMale,(PLHDATA)Gender,
`M',0,MyDialogArray+2,PARENT_FKEYS,NO_MENU,NO_HELP},
};
LHWINDOW MyDialogBox={DialogBox,
5,8,480,160,
&msgMyDialogTitle,(PLHDATA)MyDialogArray,
countof(MyDialogArray),0,
NULL,MyFKeys,NO_MENU,NO_HELP};
A couple of things to note about this example.