ebmDevMag.com home
ebm Developer's Magazine
links

developer's mag
main page

article
part 1
part 2
part 3
part 4
part 5


3 - Separate Sources, Common Class

By '#include'ing the form header file eg_2.h in the source file extra.cpp, we can add the bodies of these other functions. In this way, the code can be maintained separately, you can re-export the form code at any time, and the program will continue to compile.

This extra.cpp source file also contains the GUI_Main() startup function, giving us a place to add the extra initialization code:

static CWindow1 *f_mainWindow;
//--------------------------------------------------------
S32 GUI_main( MSG_TYPE type, CViewable *object, S32 data )
{ switch (type)
{
case MSG_APP_START:
if (OS_is_present && hostIO_am_I_the_current_task())
HOSTIO_INLINE_BREAKPOINT();
f_mainWindow = new CWindow1();
f_mainWindow->Initialize(); // additional setup!
return 1;
case MSG_APP_STOP: // prog exit & cleanup
delete f_mainWindow;
return 1;
default:
break;
}
return 0;
};
Right after the form is created (and the objects are set up in their default state), the Initialize() function is called, allowing additional set up. In particular, this is where we tweak the checkbox, text edit, and rectangle objects:

void CWindow1::Initialize(void)
{
// do additional setup functions
m_count=0;
Rect1->SetForegroundColor(COLOR_GRAY27); // color rectangle
Checkbox1->SetDownStatus(true); // check box is now checked
TextEdit1->SetText("An example of text set " "at the beginning of the program!");
}


Previous Section
Next Section

Copyright © 2001-2006 ebmDevMag.com - Legal Notice