nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSiteNextBtn);
CallCreateInstance(kButtonCID, &mSiteNextBtn);
PRBool CreateSiteDialog(nsIWidget * aParent){  // Dynamically find the index of the last pointer  gTop100LastPointer = 0;  const char * p;  do {    p = gTop100List[gTop100LastPointer++];  } while (p);  gTop100LastPointer--;  PRBool result = PR_TRUE;  if (mSiteDialog == nsnull) {    nsILabel * label;    nsIDeviceContext* dc = aParent->GetDeviceContext();    float t2d;    t2d = dc->TwipsToDevUnits();    nsFont font(DIALOG_FONT, NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,                NS_FONT_WEIGHT_NORMAL, 0,                nscoord(t2d * NSIntPointsToTwips(DIALOG_FONT_SIZE)));    NS_RELEASE(dc);    nscoord dialogWidth = 375;    // create a Dialog    //    nsRect rect;    rect.SetRect(0, 0, dialogWidth, 125+24+10);      nsIWidget* widget = nsnull;    nsComponentManager::CreateInstance(kWindowCID, nsnull,                                        kIWidgetIID, (void**)&mSiteDialog);    if (nsnull == mSiteDialog)      return PR_FALSE;        if (NS_OK == mSiteDialog->QueryInterface(kIWidgetIID,(void**)&widget))    {      widget->Create((nsIWidget *) nsnull, rect, HandleSiteEvent, NULL);      //mSiteDialog->SetLabel("Top 100 Site Walker");    }    //mSiteDialog->SetClientData(this);    nsAutoString titleStr(NS_LITERAL_STRING("Top "));    titleStr.AppendInt(gTop100LastPointer);    titleStr.AppendLiteral(" Sites");    mSiteDialog->SetTitle(titleStr);    nscoord w  = 65;    nscoord x  = 5;    nscoord y  = 10;    // Create Label    w = 50;    rect.SetRect(x, y+3, w, 24);  #ifdef USE_LOCAL_WIDGETS    NS_NewLabel(&label);#else    nsComponentManager::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label);#endif    NS_CreateLabel(mSiteDialog,label,rect,HandleSiteEvent,&font);    label->SetAlignment(eAlign_Right);    label->SetLabel(NS_ConvertASCIItoUCS2("Site:"));    x += w + 1;    w = 250;    rect.SetRect(x, y+3, w, 24);  #ifdef USE_LOCAL_WIDGETS    NS_NewLabel(&mSiteLabel);#else   nsComponentManager::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&mSiteLabel);#endif    NS_CreateLabel(mSiteDialog,mSiteLabel,rect,HandleSiteEvent,&font);    mSiteLabel->SetAlignment(eAlign_Left);    mSiteLabel->SetLabel(EmptyString());    y += 34;    w = 75;    nscoord spacing = (dialogWidth - (3*w)) / 4;    x = spacing;    // Create Previous Button    rect.SetRect(x, y, w, 24);  #ifdef USE_LOCAL_WIDGETS    NS_NewButton(&mSitePrevBtn);#else    nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSitePrevBtn);#endif    NS_CreateButton(mSiteDialog,mSitePrevBtn,rect,HandleSiteEvent,&font);    mSitePrevBtn->SetLabel(NS_ConvertASCIItoUCS2("<< Previous"));    x += spacing + w;    // Create Next Button    rect.SetRect(x, y, w, 24);  #ifdef USE_LOCAL_WIDGETS    NS_NewButton(&mSiteNextBtn);#else    nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSiteNextBtn);#endif    NS_CreateButton(mSiteDialog,mSiteNextBtn,rect,HandleSiteEvent,&font);    mSiteNextBtn->SetLabel(NS_ConvertASCIItoUCS2("Next >>"));    x += spacing + w;      // Create Cancel Button    rect.SetRect(x, y, w, 24);  #ifdef USE_LOCAL_WIDGETS    NS_NewButton(&mSiteCancelBtn);#else    nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSiteCancelBtn);#endif    NS_CreateButton(mSiteDialog,mSiteCancelBtn,rect,HandleSiteEvent,&font);    mSiteCancelBtn->SetLabel(NS_ConvertASCIItoUCS2("Cancel"));    /////////////////////////    w  = 65;    x  = spacing;    y  += 24 + 10;    nscoord txtHeight   = 24;    nscolor textBGColor = NS_RGB(255,255,255);    nscolor textFGColor = NS_RGB(255,255,255);    {      nsCOMPtr<nsILookAndFeel> lookAndFeel = do_GetService(kLookAndFeelCID);      if (lookAndFeel) {        lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldHeight, txtHeight);        lookAndFeel->GetColor(nsILookAndFeel::eColor_TextBackground, textBGColor);        lookAndFeel->GetColor(nsILookAndFeel::eColor_TextForeground, textFGColor);      }    }    // Create TextField    rect.SetRect(x, y, w, txtHeight);  #ifdef USE_LOCAL_WIDGETS    NS_NewTextWidget(&mSiteIndexTxt);#else    nsComponentManager::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, (void**)&mSiteIndexTxt);#endif    NS_CreateTextWidget(mSiteDialog,mSiteIndexTxt,rect,HandleSiteEvent,&font);    if (mVerDirTxt && NS_OK == mSiteIndexTxt->QueryInterface(kIWidgetIID,(void**)&widget)) {      widget->SetBackgroundColor(textBGColor);      widget->SetForegroundColor(textFGColor);    }    nsString str;    str.AppendInt(0);    PRUint32 size;    mSiteIndexTxt->SetText(str,size);    x += spacing + w;    w = 100;    // Create Jump Button    rect.SetRect(x, y, w, 24);  #ifdef USE_LOCAL_WIDGETS    NS_NewButton(&mSiteJumpBtn);#else    nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSiteJumpBtn);#endif    NS_CreateButton(mSiteDialog,mSiteJumpBtn,rect,HandleSiteEvent,&font);    mSiteJumpBtn->SetLabel(NS_ConvertASCIItoUCS2("Jump to Index"));  }  NS_ShowWidget(mSiteDialog,PR_TRUE);  NS_SetFocusToWidget(mSiteNextBtn);  // Init  NS_EnableWidget(mSitePrevBtn,PR_FALSE);   if (gWinData) {    nsString urlStr; urlStr.AssignWithConversion(gTop100List[gTop100Pointer]);    gWinData->GoTo(urlStr.get());    mSiteLabel->SetLabel(urlStr);  }  return result;}