PSZ Settings :: QueryNumSaveDir( VOID )
{
    // Using a static buffer here is not really good, but good enough
    // currently as we know there will be no concurrent access.
    static CHAR ach[_MAX_PATH];

    if( strspn( QueryString( SEI_NUMSAVEDIR ), " \t\n\r" ) ==
        strlen( QueryString( SEI_NUMSAVEDIR ) ) )
        return getcwd( ach, _MAX_PATH );
    return QueryString( SEI_NUMSAVEDIR );
}
Exemple #2
0
BOOL CDownLoader::SaveProxy(__in HINTERNET hRequest)
{
    ::InternetErrorDlg(::GetDesktopWindow(),
                       hRequest, ERROR_INTERNET_INCORRECT_PASSWORD,
                       FLAGS_ERROR_UI_FILTER_FOR_ERRORS
                       | FLAGS_ERROR_UI_FLAGS_GENERATE_DATA
                       | FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS, NULL);

    // 保存代理信息
    m_proxyUserName = QueryString(hRequest, INTERNET_OPTION_PROXY_USERNAME);
    m_proxyPassWord = QueryString(hRequest, INTERNET_OPTION_PROXY_PASSWORD);
    m_proxyType = UseProxy;
    return TRUE;
}
void DlgffDPjrProperties::SelectLocation() {
    QMenu       *ContextMenu=new QMenu(this);
    bool        AddSep=false;

    QAction     *Add=CreateMenuAction(QIcon(":/img/gmap_add.png"),
                                      ffdProject->ProjectInfo->Location?QApplication::translate("MainWindow","Edit this location"):QApplication::translate("MainWindow","Define a location"),
                                      FAVACTIONTYPE_EDIT,false,false,this);
    ContextMenu->addAction(Add);

    QSqlQuery   Query(ApplicationConfig->Database->db);
    QString     QueryString("SELECT Key,Name,FAddress,Thumbnail FROM Location ORDER BY LOWER(Name)");
    Query.prepare(QueryString);
    if (!Query.exec()) DisplayLastSQLError(&Query); else while (Query.next()) {
        bool      Ret;
        qlonglong Key=Query.value(0).toLongLong(&Ret);
        if (Ret) {
            if (!AddSep) {
                ContextMenu->addSeparator();
                AddSep=true;
            }
            QString     Name   =Query.value(1).toString();
            QString     Address=Query.value(2).toString();
            QByteArray  Data   =Query.value(3).toByteArray();
            QImage      Thumb; Thumb.loadFromData(Data);
            bool        IsCurrent=(Key==(ffdProject->ProjectInfo->Location?((cLocation *)ffdProject->ProjectInfo->Location)->FavKey:-1));
            QAction *Act=CreateMenuAction(QIcon(QPixmap().fromImage(Thumb)),QString("%1 (%2)").arg(Name).arg(Address),FAVACTIONTYPE_SELECT+Key,true,IsCurrent,this);
            ContextMenu->addAction(Act);
        }
    }

    QAction *Action=ContextMenu->exec(QCursor::pos());
    if (Action) {
        int ActionType=Action->data().toInt() & FAVACTIONTYPE_ACTIONTYPE;
        if (ActionType==FAVACTIONTYPE_EDIT) {
            cLocation *PrevLocation=(cLocation *)ffdProject->ProjectInfo->Location;
            if (!((cLocation *)ffdProject->ProjectInfo->Location)) ffdProject->ProjectInfo->Location=new cLocation(ApplicationConfig);
            DlgGMapsLocation Dlg((cLocation *)ffdProject->ProjectInfo->Location,ApplicationConfig,this);
            Dlg.InitDialog();
            if ((Dlg.exec()!=0)&&(!PrevLocation)) {
                delete (cLocation *)ffdProject->ProjectInfo->Location;
                ffdProject->ProjectInfo->Location=NULL;
            }
        } else if (Action->text()!="") {
            qlonglong Key=Action->data().toInt() & ~FAVACTIONTYPE_ACTIONTYPE;
            if (!ffdProject->ProjectInfo->Location) ffdProject->ProjectInfo->Location=new cLocation(ApplicationConfig);
            ((cLocation *)ffdProject->ProjectInfo->Location)->LoadFromFavorite(Key);
        }
    }
    ui->LocationBT->setDown(false);
    if (ffdProject->ProjectInfo->Location) {
        ui->Location->setText(QString("%1 (%2)").arg(((cLocation *)ffdProject->ProjectInfo->Location)->Name).arg(((cLocation *)ffdProject->ProjectInfo->Location)->FriendlyAddress));
        ui->LocationIcon->setPixmap(QPixmap().fromImage(((cLocation *)ffdProject->ProjectInfo->Location)->GetThumb(16)));
    } else {
        ui->Location->setText("");
        ui->LocationIcon->setPixmap(QPixmap());
    }
    IsLocationChanged=true;
}
Exemple #4
0
void LoadSettings(void)
{
	HKEY hKey = NULL;
	HFONT hFont;
	DWORD dwPointSize = 0;
	INT base_length, dx, dy;

	base_length = (GetSystemMetrics(SM_CXSCREEN) > GetSystemMetrics(SM_CYSCREEN))?
		GetSystemMetrics(SM_CYSCREEN) : GetSystemMetrics(SM_CXSCREEN);

	dx = (INT)(base_length * .95);
	dy = dx * 3 / 4;
	SetRect( &Globals.main_rect, 0, 0, dx, dy );

	if (RegOpenKey(HKEY_CURRENT_USER, s_szRegistryKey, &hKey) == ERROR_SUCCESS)
	{
		QueryByte(hKey,     _T("lfCharSet"),        &Globals.lfFont.lfCharSet);
		QueryByte(hKey,     _T("lfClipPrecision"),  &Globals.lfFont.lfClipPrecision);
		QueryDword(hKey,    _T("lfEscapement"),     (DWORD*)&Globals.lfFont.lfEscapement);
		QueryString(hKey,   _T("lfFaceName"),       Globals.lfFont.lfFaceName, sizeof(Globals.lfFont.lfFaceName) / sizeof(Globals.lfFont.lfFaceName[0]));
		QueryByte(hKey,     _T("lfItalic"),         &Globals.lfFont.lfItalic);
		QueryDword(hKey,    _T("lfOrientation"),    (DWORD*)&Globals.lfFont.lfOrientation);
		QueryByte(hKey,     _T("lfOutPrecision"),   &Globals.lfFont.lfOutPrecision);
		QueryByte(hKey,     _T("lfPitchAndFamily"), &Globals.lfFont.lfPitchAndFamily);
		QueryByte(hKey,     _T("lfQuality"),        &Globals.lfFont.lfQuality);
		QueryByte(hKey,     _T("lfStrikeOut"),      &Globals.lfFont.lfStrikeOut);
		QueryByte(hKey,     _T("lfUnderline"),      &Globals.lfFont.lfUnderline);
		QueryDword(hKey,    _T("lfWeight"),         (DWORD*)&Globals.lfFont.lfWeight);
		QueryDword(hKey,    _T("iPointSize"),       &dwPointSize);
		QueryBool(hKey,     _T("fWrap"),            &Globals.bWrapLongLines);
		QueryBool(hKey,     _T("fStatusBar"),       &Globals.bShowStatusBar);

		QueryDword(hKey,    _T("iWindowPosX"),      (DWORD*)&Globals.main_rect.left);
		QueryDword(hKey,    _T("iWindowPosY"),      (DWORD*)&Globals.main_rect.top);
		QueryDword(hKey,    _T("iWindowPosDX"),     (DWORD*)&dx);
		QueryDword(hKey,    _T("iWindowPosDY"),     (DWORD*)&dy);

        Globals.main_rect.right = Globals.main_rect.left + dx;
        Globals.main_rect.bottom = Globals.main_rect.top + dy;

		Globals.bShowStatusBar = !Globals.bShowStatusBar; /* invert value becuase DIALOG_ViewStatusBar will be called to show it*/

		if (dwPointSize != 0)
			Globals.lfFont.lfHeight = HeightFromPointSize(dwPointSize);

		RegCloseKey(hKey);
	}

	hFont = CreateFontIndirect(&Globals.lfFont);
	if (hFont)
	{
		if (Globals.hFont)
			DeleteObject(Globals.hFont);
		Globals.hFont = hFont;
	}
}
Exemple #5
0
/***********************************************************************
 *
 *           NOTEPAD_LoadSettingsFromRegistry
 *
 *  Load settings from registry HKCU\Software\Microsoft\Notepad.
 */
void NOTEPAD_LoadSettingsFromRegistry(void)
{
    HKEY hKey = NULL;
    HFONT hFont;
    DWORD dwPointSize = 0;
    INT base_length, dx, dy;

    base_length = (GetSystemMetrics(SM_CXSCREEN) > GetSystemMetrics(SM_CYSCREEN)) ?
                  GetSystemMetrics(SM_CYSCREEN) : GetSystemMetrics(SM_CXSCREEN);

    dx = (INT)(base_length * .95);
    dy = dx * 3 / 4;
    SetRect(&Globals.main_rect, 0, 0, dx, dy);

    if (RegOpenKey(HKEY_CURRENT_USER, s_szRegistryKey, &hKey) == ERROR_SUCCESS)
    {
        QueryByte(hKey, _T("lfCharSet"), &Globals.lfFont.lfCharSet);
        QueryByte(hKey, _T("lfClipPrecision"), &Globals.lfFont.lfClipPrecision);
        QueryDword(hKey, _T("lfEscapement"), (DWORD*)&Globals.lfFont.lfEscapement);
        QueryString(hKey, _T("lfFaceName"), Globals.lfFont.lfFaceName, ARRAY_SIZE(Globals.lfFont.lfFaceName));
        QueryByte(hKey, _T("lfItalic"), &Globals.lfFont.lfItalic);
        QueryDword(hKey, _T("lfOrientation"), (DWORD*)&Globals.lfFont.lfOrientation);
        QueryByte(hKey, _T("lfOutPrecision"), &Globals.lfFont.lfOutPrecision);
        QueryByte(hKey, _T("lfPitchAndFamily"), &Globals.lfFont.lfPitchAndFamily);
        QueryByte(hKey, _T("lfQuality"), &Globals.lfFont.lfQuality);
        QueryByte(hKey, _T("lfStrikeOut"), &Globals.lfFont.lfStrikeOut);
        QueryByte(hKey, _T("lfUnderline"), &Globals.lfFont.lfUnderline);
        QueryDword(hKey, _T("lfWeight"), (DWORD*)&Globals.lfFont.lfWeight);
        QueryDword(hKey, _T("iPointSize"), &dwPointSize);
        QueryBool(hKey, _T("fWrap"), &Globals.bWrapLongLines);
        QueryBool(hKey, _T("fStatusBar"), &Globals.bShowStatusBar);
        QueryString(hKey, _T("szHeader"), Globals.szHeader, ARRAY_SIZE(Globals.szHeader));
        QueryString(hKey, _T("szTrailer"), Globals.szFooter, ARRAY_SIZE(Globals.szFooter));
        QueryDword(hKey, _T("iMarginLeft"), (DWORD*)&Globals.lMarginLeft);
        QueryDword(hKey, _T("iMarginTop"), (DWORD*)&Globals.lMarginTop);
        QueryDword(hKey, _T("iMarginRight"), (DWORD*)&Globals.lMarginRight);
        QueryDword(hKey, _T("iMarginBottom"), (DWORD*)&Globals.lMarginBottom);

        QueryDword(hKey, _T("iWindowPosX"), (DWORD*)&Globals.main_rect.left);
        QueryDword(hKey, _T("iWindowPosY"), (DWORD*)&Globals.main_rect.top);
        QueryDword(hKey, _T("iWindowPosDX"), (DWORD*)&dx);
        QueryDword(hKey, _T("iWindowPosDY"), (DWORD*)&dy);

        Globals.main_rect.right = Globals.main_rect.left + dx;
        Globals.main_rect.bottom = Globals.main_rect.top + dy;

        /* invert value because DIALOG_ViewStatusBar will be called to show it */
        Globals.bShowStatusBar = !Globals.bShowStatusBar;

        if (dwPointSize != 0)
            Globals.lfFont.lfHeight = HeightFromPointSize(dwPointSize);
        else
            Globals.lfFont.lfHeight = HeightFromPointSize(100);

        RegCloseKey(hKey);
    }
    else
    {
        /* If no settings are found in the registry, then use default values */
        Globals.lfFont.lfCharSet = 163;
        Globals.lfFont.lfClipPrecision = 2;
        Globals.lfFont.lfEscapement = 0;
        _tcscpy(Globals.lfFont.lfFaceName, _T("Arial"));
        Globals.lfFont.lfItalic = 0;
        Globals.lfFont.lfOrientation = 0;
        Globals.lfFont.lfOutPrecision = 3;
        Globals.lfFont.lfPitchAndFamily = 34;
        Globals.lfFont.lfQuality = 1;
        Globals.lfFont.lfStrikeOut = 0;
        Globals.lfFont.lfUnderline = 0;
        Globals.lfFont.lfWeight = 400;
        Globals.lfFont.lfHeight = HeightFromPointSize(100);
    }

    hFont = CreateFontIndirect(&Globals.lfFont);
    SendMessage(Globals.hEdit, WM_SETFONT, (WPARAM)hFont, (LPARAM)TRUE);
    if (hFont)
    {
        if (Globals.hFont)
            DeleteObject(Globals.hFont);
        Globals.hFont = hFont;
    }
}
Exemple #6
0
BOOL CSettingsPage::OnInitDialog()
{
	int t;
	BYTE buf[_MAX_PATH*sizeof(TCHAR)];
	DWORD bufLen;
	DWORD dwType;
	CWaitCursor wait;

	CTooltipPropertyPage::OnInitDialog();

	SetDlgItemInt(IDC_PSERVERPORT,(t=QueryDword(_T("PServerPort")))>=0?t:2401,FALSE);
	bufLen=sizeof(buf);
	if(RegQueryValueEx(g_hServerKey,_T("LockServer"),NULL,&dwType,buf,&bufLen))
	{
		SetDlgItemText(IDC_LOCKSERVER,_T("localhost"));
		SetDlgItemInt(IDC_LOCKSERVERPORT,(t=QueryDword(_T("LockServerPort")))>=0?t:2402,FALSE);
	}
	else
	{
		RegDeleteValue(g_hServerKey,_T("LockServerPort"));
		TCHAR *p=_tcschr((TCHAR*)buf,':');
		if(p)
			*p='\0';
		m_edLockServer.SetWindowText((LPCTSTR)buf);
		SetDlgItemInt(IDC_LOCKSERVERPORT,p?_tstoi(p+1):2402,FALSE);
	}

	if(!RegQueryValueEx(g_hServerKey,_T("AnonymousUsername"),NULL,&dwType,buf,&bufLen))
		m_edAnonUser.SetWindowText((TCHAR*)buf);

	SendDlgItemMessage(IDC_PSERVERPORT,EM_LIMITTEXT,4);
	SendDlgItemMessage(IDC_LOCKSERVERPORT,EM_LIMITTEXT,4);

	m_sbServerPort.SetRange32(1,65535);
	m_sbLockPort.SetRange32(1,65535);

	bufLen=sizeof(buf);
	if(RegQueryValueEx(g_hServerKey,_T("TempDir"),NULL,&dwType,buf,&bufLen) &&
	   SHRegGetUSValue(_T("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"),_T("TEMP"),NULL,(LPVOID)buf,&bufLen,TRUE,NULL,0) &&
	   !GetEnvironmentVariable(_T("TEMP"),(LPTSTR)buf,sizeof(buf)) &&
	   !GetEnvironmentVariable(_T("TMP"),(LPTSTR)buf,sizeof(buf)))
		{
			// Not set
			*buf='\0';
		}

	m_edTempDir.SetWindowText((LPCTSTR)buf);

	m_cbEncryption.ResetContent();
	m_cbEncryption.SetItemData(m_cbEncryption.AddString(_T("Optional")),0);
	m_cbEncryption.SetItemData(m_cbEncryption.AddString(_T("Request Authentication")),1);
	m_cbEncryption.SetItemData(m_cbEncryption.AddString(_T("Request Encryption")),2);
	m_cbEncryption.SetItemData(m_cbEncryption.AddString(_T("Require Authentication")),3);
	m_cbEncryption.SetItemData(m_cbEncryption.AddString(_T("Require Encryption")),4);
	m_cbCompression.ResetContent();
	m_cbCompression.SetItemData(m_cbCompression.AddString(_T("Optional")),0);
	m_cbCompression.SetItemData(m_cbCompression.AddString(_T("Request Compression")),1);
	m_cbCompression.SetItemData(m_cbCompression.AddString(_T("Require Compression")),2);

	m_cbEncryption.SetCurSel((t=QueryDword(_T("EncryptionLevel")))>=0?t:0);
	m_cbCompression.SetCurSel((t=QueryDword(_T("CompressionLevel")))>=0?t:0);

	/* Migrate the old setting */
	if((t=QueryDword(_T("DontUseDomain")))>=0)
	{
		if(t)
		{
			/* If dont use domain is set, force domain to computer name */
			/* The server will automatically pick up the domain otherwise */
			bufLen=sizeof(buf);
			GetComputerName((LPTSTR)buf,&bufLen);
			RegSetValueEx(g_hServerKey,_T("DefaultDomain"),0,REG_SZ,(BYTE*)buf,_tcslen((LPCTSTR)buf));
		}
		RegDeleteValue(g_hServerKey,_T("DontUseDomain"));
		if(g_bPrivileged)
			GetParent()->PostMessage(PSM_CHANGED, (WPARAM)m_hWnd); /* SetModified happens too early */
	}

	m_cbDefaultDomain.ResetContent();
	DWORD dwLen = sizeof(mw_computer)/sizeof(mw_computer[0]);

	m_cbDefaultDomain.AddString(_T("(default)"));

	GetComputerName(mw_computer,&dwLen);
	m_cbDefaultDomain.AddString(mw_computer);
	if(isDomainMember(mw_domain))
	{
		LPWSTR pw_pdc;
		m_cbDefaultDomain.AddString(mw_domain);
		if(!NetGetAnyDCName(NULL,mw_domain,(LPBYTE*)&pw_pdc) || !NetGetDCName(NULL,mw_domain,(LPBYTE*)&pw_pdc))
		{
			wcscpy(mw_pdc,pw_pdc);
			NetApiBufferFree(pw_pdc);
		}
	}

	CString szDefaultDomain = QueryString(_T("DefaultDomain"));
	int n = m_cbDefaultDomain.FindStringExact(-1,szDefaultDomain);
	m_cbDefaultDomain.SetCurSel(n>0?n:0);

	m_cbRunAsUser.ResetContent();
	m_cbRunAsUser.AddString(_T("(client user)"));
	CString usr = QueryString(_T("RunAsUser"));
	if(!usr.GetLength())
		m_cbRunAsUser.SetCurSel(0);
	else
		m_cbRunAsUser.SetCurSel(m_cbRunAsUser.AddString(usr));

	if(!g_bPrivileged)
	{
		m_edTempDir.EnableWindow(FALSE);
		m_edLockServer.EnableWindow(FALSE);
		m_cbEncryption.EnableWindow(FALSE);
		m_cbCompression.EnableWindow(FALSE);
		m_sbServerPort.EnableWindow(FALSE);
		m_sbLockPort.EnableWindow(FALSE);
		m_cbDefaultDomain.EnableWindow(FALSE);
		m_cbRunAsUser.EnableWindow(FALSE);
		m_edAnonUser.EnableWindow(FALSE);
		::EnableWindow(*GetDlgItem(IDC_CHANGETEMP),FALSE);
		::EnableWindow(*GetDlgItem(IDC_LOCKSERVERPORT),FALSE);
		::EnableWindow(*GetDlgItem(IDC_PSERVERPORT),FALSE);
	}

	return TRUE;
}