scribbleData.drawPane->SetBackgroundColor(NS_RGB(255, 255, 255));
nsresult CreateApplication(){    scribbleData.isDrawing = PR_FALSE;    // register graphics classes    static NS_DEFINE_IID(kCRenderingContextIID, NS_RENDERING_CONTEXT_CID);    static NS_DEFINE_IID(kCDeviceContextIID, NS_DEVICE_CONTEXT_CID);    static NS_DEFINE_IID(kCFontMetricsIID, NS_FONT_METRICS_CID);    static NS_DEFINE_IID(kCImageIID, NS_IMAGE_CID);    NSRepository::RegisterFactory(kCRenderingContextIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);    NSRepository::RegisterFactory(kCDeviceContextIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);    NSRepository::RegisterFactory(kCFontMetricsIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);    NSRepository::RegisterFactory(kCImageIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);    // register widget classes    static NS_DEFINE_IID(kCWindowCID, NS_WINDOW_CID);    static NS_DEFINE_IID(kCChildCID, NS_CHILD_CID);    static NS_DEFINE_IID(kCButtonCID, NS_BUTTON_CID);    static NS_DEFINE_IID(kCCheckButtonCID, NS_CHECKBUTTON_CID);    static NS_DEFINE_IID(kCComboBoxCID, NS_COMBOBOX_CID);    static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);    static NS_DEFINE_IID(kCListBoxCID, NS_LISTBOX_CID);    static NS_DEFINE_IID(kCRadioButtonCID, NS_RADIOBUTTON_CID);    static NS_DEFINE_IID(kCHorzScrollbarCID, NS_HORZSCROLLBAR_CID);    static NS_DEFINE_IID(kCVertScrollbarCID, NS_VERTSCROLLBAR_CID);    static NS_DEFINE_IID(kCTextAreaCID, NS_TEXTAREA_CID);    static NS_DEFINE_IID(kCTextFieldCID, NS_TEXTFIELD_CID);    NSRepository::RegisterFactory(kCAppShellCID, "raptorwidget.dll", PR_FALSE, PR_FALSE);    NSRepository::RegisterFactory(kCWindowCID, WIDGET_DLL, PR_FALSE, PR_FALSE);    NSRepository::RegisterFactory(kCChildCID, WIDGET_DLL, PR_FALSE, PR_FALSE);    NSRepository::RegisterFactory(kCButtonCID, WIDGET_DLL, PR_FALSE, PR_FALSE);    NSRepository::RegisterFactory(kCCheckButtonCID, WIDGET_DLL, PR_FALSE, PR_FALSE);    NSRepository::RegisterFactory(kCComboBoxCID, WIDGET_DLL, PR_FALSE, PR_FALSE);    NSRepository::RegisterFactory(kCFileWidgetCID, WIDGET_DLL, PR_FALSE, PR_FALSE);    NSRepository::RegisterFactory(kCListBoxCID, WIDGET_DLL, PR_FALSE, PR_FALSE);    NSRepository::RegisterFactory(kCRadioButtonCID, WIDGET_DLL, PR_FALSE, PR_FALSE);    NSRepository::RegisterFactory(kCHorzScrollbarCID, WIDGET_DLL, PR_FALSE, PR_FALSE);    NSRepository::RegisterFactory(kCVertScrollbarCID, WIDGET_DLL, PR_FALSE, PR_FALSE);    NSRepository::RegisterFactory(kCTextAreaCID, WIDGET_DLL, PR_FALSE, PR_FALSE);    NSRepository::RegisterFactory(kCTextFieldCID, WIDGET_DLL, PR_FALSE, PR_FALSE);    //NS_InitToolkit(PR_GetCurrentThread());    nsresult  res;    static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);    static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);    res = NSRepository::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&scribbleData.mContext);    if (NS_OK == res)      scribbleData.mContext->Init(nsnull);     // Create an application shell    nsIAppShell *appShell;    NSRepository::CreateInstance(kCAppShellCID, nsnull, kIAppShellIID, (void**)&appShell);    int     argc;    char ** argv = nsnull;    appShell->Create(&argc, argv);       //    // create the main window    //    NSRepository::CreateInstance(kCWindowCID, nsnull, kIWidgetIID, (void **)&(scribbleData.mainWindow));    nsRect rect(100, 100, 600, 600);    scribbleData.mainWindow->Create((nsIWidget*)NULL, rect, HandleEventMain, NULL);    //    // create the control pane    //    nsIWidget *controlPane;    rect.SetRect(0, 0, 200, 580);      NSRepository::CreateInstance(kCChildCID, nsnull, kIWidgetIID, (void **)&controlPane);    controlPane->Create(scribbleData.mainWindow, rect, HandleEventControlPane, NULL);    //    // Add the scribble/lines section    //    // create the "Scribble" check button    rect.SetRect(50, 50, 100, 25);      NSRepository::CreateInstance(kCRadioButtonCID, nsnull, kIRadioButtonIID, (void **)&(scribbleData.scribble));    scribbleData.scribble->Create(controlPane, rect, HandleEventRadioButton, NULL);    nsString cbLabel("Scribble");    scribbleData.scribble->SetLabel(cbLabel);    scribbleData.scribble->SetState(PR_FALSE);    //scribbleData.scribble->SetBackgroundColor(NS_RGB(255, 255, 255));    scribbleData.scribble->Show(PR_TRUE);    // create the "Lines" check button    rect.SetRect(50, 75, 100, 25);      NSRepository::CreateInstance(kCRadioButtonCID, nsnull, kIRadioButtonIID, (void **)&(scribbleData.lines));    scribbleData.lines->Create(controlPane, rect, HandleEventRadioButton, NULL);    nsString cbLabel1("Lines");    scribbleData.lines->SetLabel(cbLabel1);    scribbleData.lines->SetState(PR_TRUE);    //scribbleData.lines->SetBackgroundColor(NS_RGB(255, 255, 255));    scribbleData.lines->Show(PR_TRUE);    //    // Add the circle/rectangle section    //    // create the "Circles" check button    nsICheckButton * checkButton;    rect.SetRect(50, 200, 100, 25);      NSRepository::CreateInstance(kCCheckButtonCID, nsnull, kICheckButtonIID, (void **)&checkButton);    checkButton->Create(controlPane, rect, HandleEventCheck, NULL);    nsString cbLabel2("Circles");    checkButton->SetLabel(cbLabel2);    checkButton->SetBackgroundColor(NS_RGB(255, 255, 255));    checkButton->Show(PR_TRUE);    NS_RELEASE(checkButton);    // create the "Rectangles" check button    rect.SetRect(50, 225, 100, 25);      NSRepository::CreateInstance(kCCheckButtonCID, nsnull, kICheckButtonIID, (void **)&checkButton);    checkButton->Create(controlPane, rect, HandleEventCheck, NULL);    nsString cbLabel3("Rectangles");    checkButton->SetLabel(cbLabel3);    checkButton->SetBackgroundColor(NS_RGB(255, 255, 255));    checkButton->Show(PR_TRUE);    NS_RELEASE(checkButton);    //    // Add the color section    //    // create the "red" text widget    rect.SetRect(100, 350, 50, 22);      NSRepository::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void **)&(scribbleData.red));    scribbleData.red->Create(controlPane, rect, HandleEventText, NULL);    nsString initText("0");    scribbleData.red->SetText(initText);    scribbleData.red->SetBackgroundColor(NS_RGB(0, 0, 255));    scribbleData.red->Show(PR_TRUE);    // create the "green" text widget    rect.SetRect(100, 371, 50, 22);      NSRepository::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void **)&(scribbleData.green));    scribbleData.green->Create(controlPane, rect, HandleEventText, NULL);    scribbleData.green->SetText(initText);    scribbleData.green->SetBackgroundColor(NS_RGB(255, 0, 0));    scribbleData.green->Show(PR_TRUE);    // create the "blue" text widget    rect.SetRect(100, 392, 50, 22);      NSRepository::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void **)&(scribbleData.blue));    scribbleData.blue->Create(controlPane, rect, HandleEventText, NULL);    scribbleData.blue->SetText(initText);    scribbleData.blue->SetBackgroundColor(NS_RGB(0, 255, 0));    scribbleData.blue->Show(PR_TRUE);    //    // create a button      //    nsIButton *button;    rect.SetRect(50, 500, 100, 25);      NSRepository::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void **)&button);    button->Create(controlPane, rect, HandleEventButton, NULL);    nsString label("Clear");    button->SetLabel(label);    button->Show(PR_TRUE);    NS_RELEASE(button);    NS_RELEASE(controlPane); // the parent keeps a reference on this child    //    // create the draw pane    //    rect.SetRect(200, 0, 400, 580);      NSRepository::CreateInstance(kCChildCID, nsnull, kIWidgetIID, (void **)&scribbleData.drawPane);    scribbleData.drawPane->Create(scribbleData.mainWindow, rect, HandleEventGraphicPane, NULL);    //    // show. We are in business...    //    scribbleData.mainWindow->Show(PR_TRUE);    return(appShell->Run());}