beautypg.com

HP Integrity NonStop J-Series User Manual

Page 263

background image

*/
int
DemoWindow::registerClass(){ //5
WNDCLASS wndclass;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = ::DemoWindow_Callback; //6
wndclass.cbClsExtra = 0;
// Request extra space to store the 'this' pointer
wndclass.cbWndExtra = sizeof(this); //7
wndclass.hInstance = myInstance;
wndclass.hIcon = 0;
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
wndclass.hbrBackground = GetStockObject( WHITE_BRUSH );
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = "DemoWindow";

if( !RegisterClass(&wndclass) ) exit(FALSE);
return TRUE;
}

DemoWindow::~DemoWindow(){
// Delete all items in my list:
myList.clearAndDestroy(); //8
}

void
DemoWindow::insert(RWDrawable* d){
// Add a new item to the window:
myList.insert(d); //9
}

void
DemoWindow::paint(){ //10
RWDrawable* shape;
PAINTSTRUCT ps;
BeginPaint( handle(), &ps); //11

// Draw all items in the list. Start by making an iterator:
RWSlistCollectablesIterator next(myList); //12

// Now iterate through the collection, drawing each item:
while( shape = (RWDrawable*)next() ) //13
shape->drawWith(ps.hdc); //14

EndPaint( handle(), &ps ); //15

This manual is related to the following products: