Exemple #1
0
void __fastcall TFormMain::AutoRunClick(TObject *Sender)
{
	TRegistry *regedit = new TRegistry();
	regedit->RootKey = HKEY_CURRENT_USER;
	regedit->OpenKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", false);
	if (this->AutoRun->Checked == true) {
		try {
			regedit->WriteString("ScreenShot", Application->ExeName);
			ShowMessage("Given program will be launched at start computer");
		} catch (Exception *e) {
			ShowMessage("Error: I can not remove autorun");
			DebugOutput(e->Message);
		}
	} else {
		try {
			regedit->DeleteValue("ScreenShot");
			ShowMessage("Autorun was deleted");
		} catch (Exception *e) {
			ShowMessage("Error: i Can't delete a autorun");
            DebugOutput(e->Message);
		}
	}
	regedit->CloseKey();
	regedit->Free();
}
Exemple #2
0
//---------------------------------------------------------------------------
void __fastcall TPrefsForm::ApplyButtonClick(TObject* Sender) {
  CheckPrefsInterOpt();
  CheckReadonlyOpt(PrefFileOpt);
  TRegistry* Reg = new TRegistry;
  TIniFile* Ini = new TIniFile(PrefFileOpt);

  try {
    Ini->WriteBool("Options", "FadeShow", FadeShow->Checked);
    Ini->WriteBool("Options", "URLDetect", URLDetect->Checked);
    Ini->WriteBool("Options", "MinOnClose", MinOnClose->Checked);
    Ini->WriteBool("Options", "StartWithWindows", StartWithWindows->Checked);
    Ini->WriteBool("Options", "TopPages", TopPages->Checked);
    Ini->WriteBool("Options", "Transparency", Transparency->Checked);
    Ini->WriteInteger("Options", "TransValue", TransValue->Position);
    Ini->WriteBool("Options", "MultiLines", MultiLines->Checked);
    Ini->WriteBool("Options", "WorkMode", NormalMode->Checked);
    Ini->WriteInteger("Options", "FadeSpeed", StrToInt(FadeSpeed->Text));
    Ini->WriteString("Options", "DefaultFont", FontComboBox1->FontName);
    Ini->WriteInteger("Options", "DefaultFontSize", StrToInt(DefaultSize->Text));
    Ini->WriteBool("Options", "FadeHide", FadeHide->Checked);
    Ini->WriteBool("Options", "XPEffects", XPEffects->Checked);
    Ini->WriteInteger("Options", "Style", StyleBox->ItemIndex);
    Ini->WriteBool("Options", "TaskbarIcon", TaskbarCheck->Checked);
    Ini->WriteBool("Options", "TrayIcon", IconInTray->Checked);
    Ini->WriteBool("Options", "HideWindow", HideWind->Checked);
    Ini->WriteInteger("Options", "HideTimeout", HideTimePosition->Position);
    Ini->WriteBool("Options", "AskOnFormatChange", AskFormat->Checked);

    if (FormatPageBox->ItemIndex == 0)
      Ini->WriteString("Options", "DefaultPageFormat", "RTF");
    else
      Ini->WriteString("Options", "DefaultPageFormat", "TXT");

    Reg->RootKey = HKEY_CURRENT_USER;
    Reg->OpenKey("\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", true);

    if (StartWithWindows->Checked) {
      AnsiString Path = Application->ExeName;
      Reg->WriteString("SimpleNotes", Path );
    } else {
      if (Reg->ValueExists("SimpleNotes") && (Reg->ReadString("SimpleNotes") == Application->ExeName))
        Reg->DeleteValue("SimpleNotes");
    }

    if (TopPages->Checked)
      SNotesXMForm->AllTabs->TabPosition = tpTop;
    else
      SNotesXMForm->AllTabs->TabPosition = tpBottom;

    SNotesXMForm->AllTabs->MultiLine = MultiLines->Checked;
    SNotesXMForm->RichEdit1->AutoURLDetect = URLDetect->Checked;

    if ((OSopt == "Win2K") || (OSopt == "WinXP") || (OSopt == "Win2003")) {
      SNotesXMForm->AlphaBlend = Transparency->Checked;
      SNotesXMForm->AlphaBlendValue = TransValue->Position;
    } else
      SNotesXMForm->AlphaBlend = false;

    switch (StyleBox->ItemIndex) {
      case 0:
        SNotesXMForm->TBXSwitcher1->Theme = "Default";
        break;

      case 1:
        SNotesXMForm->TBXSwitcher1->Theme = "OfficeXP";
        break;

      default:
        SNotesXMForm->TBXSwitcher1->Theme = "OfficeXP";
        break;
    }

    SNotesXMForm->TBXSwitcher1->EnableXPStyles = XPEffects->Checked;
    Ini->WriteString("Options", "BackUpPath", BackupPath->Text);
    WasTop = TopPages->Checked;
    WasXPEffects = SNotesXMForm->TBXSwitcher1->EnableXPStyles;
    WasMultiLine = SNotesXMForm->AllTabs->MultiLine;
    WasTrayIcon = SNotesXMForm->CoolTray->IconVisible;
    WasTrans = SNotesXMForm->AlphaBlend;
    TransIs = SNotesXMForm->AlphaBlendValue;
    StyleIs = StyleBox->ItemIndex;
    ApplyButton->Enabled = false;
  } catch (...) {
    Application->MessageBoxA(LMessagesOpt.WritePrefsError, LMessagesOpt.Error, MB_OK + MB_ICONERROR);
  }

  delete Ini;
  delete Reg;
}