Esempio n. 1
0
void CShowOneDescriptionDlg::OnButton(wxCommandEvent& event)
{
    if (event.GetId()==wxID_OK)
    {
        int         err;
        wxString CurrentDir = wxGetCwd();
        if (!m_descr)
            return;
        wxFileDialog dialog(GetParent(),
                            wxT("Save current text"),
                            wxT(""),
                            wxT(""),
                            wxT(SZ_ALL_FILES),
                            wxFD_SAVE |  wxFD_OVERWRITE_PROMPT );
        err = dialog.ShowModal();
        wxSetWorkingDirectory(CurrentDir);

        if (wxID_OK == err)
        {
            CFileWriter F;
            if (F.Open(dialog.GetPath().mb_str()))
            {
                F.WriteBuf(m_descr, strlen(m_descr));

                F.Close();
            }
            else
                wxMessageBox(wxT("Can not open file"));

        }

    }
    else if (event.GetId()==wxID_CANCEL)
    {
        StoreSize();
        EndModal(wxID_CANCEL);
    }
}
Esempio n. 2
0
void CShowDescriptionListDlg::SaveAs()
{
    int            err, i;
    CBaseObject  * pObj;
    CStr           S(128);

    wxString CurrentDir = wxGetCwd();
    wxFileDialog dialog(GetParent(),
                        wxT("Save current text"),
                        wxT(""),
                        wxT(""),
                        wxT(SZ_ALL_FILES),
                        wxFD_SAVE |  wxFD_OVERWRITE_PROMPT );
    err = dialog.ShowModal();
    wxSetWorkingDirectory(CurrentDir);

    if (wxID_OK == err)
    {
        CFileWriter F;
        if (F.Open(dialog.GetPath().mb_str()))
        {
            for (i=0; i<m_pItems->Count(); i++)
            {
                pObj = (CBaseObject*)m_pItems->At(i);
                S    = pObj->Description;
                S.TrimRight(TRIM_ALL);
                S << EOL_FILE;
                F.WriteBuf(S.GetData(), S.GetLength());
            }
            F.Close();
        }
        else
            wxMessageBox(wxT("Can not open file"));

    }

}