I figured out. Please ignore.
Adele
none wrote:
Hello, everyone,
I created an XPCOM component for validating profiles before they can be used.
It captures the even "profile_approve_change" when the user selects a profile from the "Profile Selection" dialog.
Is there anyway to get the name of the selected profile?
(I can get it after the profile is switched, but it's too late then.)
I tried the following but the seletion length is 0.
// create an nsWindowCreator and give it to the WindowWatcher service
nsIWindowCreator *creatorCallback = new nsWindowCreator();
if (!creatorCallback)
return PR_FALSE;
nsCOMPtr<nsIWindowCreator> windowCreator(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback));
if (windowCreator)
{
nsCOMPtr<nsIWindowWatcher> watcher(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
if(NS_FAILED(rv)) return PR_FALSE;
watcher->SetWindowCreator(windowCreator);
nsCOMPtr<nsIDOMWindow> activeWindow;
watcher->GetActiveWindow(getter_AddRefs(activeWindow));
NS_ENSURE_TRUE(activeWindow, NS_OK);
nsCOMPtr<nsISelection> selection;
rv = activeWindow->GetSelection(getter_AddRefs(selection));
NS_ENSURE_TRUE(selection && NS_SUCCEEDED(rv), rv);
nsXPIDLString str;
rv = selection->ToString(getter_Copies(str));
if(NS_FAILED(rv)) return rv;
printf("\n========Selected profile: %s==========\n", ToNewCString(str));
}
else
return NS_ERROR_FAILURE;
I will really appreciate your help.
Thanks. Adele
_______________________________________________ Mozilla-xpcom mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-xpcom
