void MainWindow::on_StartTracking()
{
	if (m_ToolModelFileName.empty())
	{
		auto sphere = vtkSmartPointer<vtkSphereSource>::New();
		sphere->SetRadius(10);
		sphere->Update();
		m_Tool = sphere->GetOutput();
	}
	auto reader = vtkSmartPointer<vtkSTLReader>::New();
	reader->SetFileName(m_ToolModelFileName.c_str());
	reader->Update();
	m_Tool = reader->GetOutput();

	//connect tracking object
	m_3d_View->AddPolySource(m_Tool);
	std::cout << "Number of actors: " << m_3d_View->GetNumberOfActors() << std::endl;
	m_3d_View->ConnectObjectTracker(1, 0);
	m_3d_View->SetReferenceIndex(1);

	//add target to view
	if (!m_TargetFileName.empty())
	{
		auto reader_ = vtkSmartPointer<vtkSTLReader>::New();
		reader_->SetFileName(m_TargetFileName.c_str());
		reader_->Update();
		m_Target = reader_->GetOutput();
		m_3d_View->AddPolySource(m_Target);
	}

	m_3d_View->StartTracking();
}
Beispiel #2
0
static BOOL
DoSaveFileAs(
    HWND hWnd,
    PCONSOLE_CHILDFRM_WND pChildInfo)
{
    OPENFILENAME saveas;
    TCHAR szPath[MAX_PATH];

    DPRINT1("pChildInfo %p\n", pChildInfo);
    DPRINT1("FileName %S\n", pChildInfo->pFileName);

    ZeroMemory(&saveas, sizeof(saveas));

    if (pChildInfo->pFileName != NULL)
    {
        _tcscpy(szPath, pChildInfo->pFileName);
    }
    else
    {
        GetWindowText(pChildInfo->hwnd, szPath, MAX_PATH);
        _tcscat(szPath, TEXT(".msc"));
    }

    saveas.lStructSize = sizeof(OPENFILENAME);
    saveas.hwndOwner = hWnd;
    saveas.hInstance = hAppInstance;
    saveas.lpstrFilter = L"MSC Files\0*.msc\0";
    saveas.lpstrFile = szPath;
    saveas.nMaxFile = MAX_PATH;
    saveas.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
    saveas.lpstrDefExt = L"msc";

    if (GetSaveFileName(&saveas))
    {
        /* HACK: Because in ROS, Save-As boxes don't check the validity
         * of file names and thus, here, szPath can be invalid !! We only
         * see its validity when we call DoSaveFile()... */
        SetFileName(pChildInfo, szPath);

        if (DoSaveFile(hWnd, pChildInfo))
        {
//            UpdateWindowCaption();
            return TRUE;
        }
        else
        {
            SetFileName(pChildInfo, NULL);
            return FALSE;
        }
    }
    else
    {
        return FALSE;
    }
}
Beispiel #3
0
BOOL DIALOG_FileSaveAs(VOID)
{
    OPENFILENAME saveas;
    TCHAR szDir[MAX_PATH];
    TCHAR szPath[MAX_PATH];

    ZeroMemory(&saveas, sizeof(saveas));

    GetCurrentDirectory(SIZEOF(szDir), szDir);
    if (Globals.szFileName[0] == 0)
        _tcscpy(szPath, txt_files);
    else
        _tcscpy(szPath, Globals.szFileName);

    saveas.lStructSize = sizeof(OPENFILENAME);
    saveas.hwndOwner = Globals.hMainWnd;
    saveas.hInstance = Globals.hInstance;
    saveas.lpstrFilter = Globals.szFilter;
    saveas.lpstrFile = szPath;
    saveas.nMaxFile = SIZEOF(szPath);
    saveas.lpstrInitialDir = szDir;
    saveas.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY |
                   OFN_EXPLORER | OFN_ENABLETEMPLATE | OFN_ENABLEHOOK;
    saveas.lpstrDefExt = szDefaultExt;
    saveas.lpTemplateName = MAKEINTRESOURCE(DIALOG_ENCODING);
    saveas.lpfnHook = DIALOG_FileSaveAs_Hook;

    if (GetSaveFileName(&saveas))
    {
        /* HACK: Because in ROS, Save-As boxes don't check the validity
         * of file names and thus, here, szPath can be invalid !! We only
         * see its validity when we call DoSaveFile()... */
        SetFileName(szPath);
        if (DoSaveFile())
        {
            UpdateWindowCaption();
            return TRUE;
        }
        else
        {
            SetFileName(_T(""));
            return FALSE;
        }
    }
    else
    {
        return FALSE;
    }
}
Beispiel #4
0
/*------------------------------------------------------------------------*/
logfile :: logfile(const char *file_name, bool create, unsigned long max_size)
{
  SetFileName(file_name);
	CreateFlag = create;
  MaxSize = max_size;

}
Beispiel #5
0
VOID DIALOG_FileSaveAs(VOID)
{
    OPENFILENAME saveas;
    TCHAR szDir[MAX_PATH];
    TCHAR szPath[MAX_PATH];

    ZeroMemory(&saveas, sizeof(saveas));

    GetCurrentDirectory(SIZEOF(szDir), szDir);
    if (Globals.szFileName[0] == 0)
        _tcscpy(szPath, txt_files);
    else
        _tcscpy(szPath, Globals.szFileName);

    saveas.lStructSize       = sizeof(OPENFILENAME);
    saveas.hwndOwner         = Globals.hMainWnd;
    saveas.hInstance         = Globals.hInstance;
    saveas.lpstrFilter       = Globals.szFilter;
    saveas.lpstrFile         = szPath;
    saveas.nMaxFile          = SIZEOF(szPath);
    saveas.lpstrInitialDir   = szDir;
    saveas.Flags             = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT |
        OFN_HIDEREADONLY | OFN_EXPLORER | OFN_ENABLETEMPLATE | OFN_ENABLEHOOK;
    saveas.lpstrDefExt       = szDefaultExt;
    saveas.lpTemplateName    = MAKEINTRESOURCE(DIALOG_ENCODING);
    saveas.lpfnHook          = DIALOG_FileSaveAs_Hook;

    if (GetSaveFileName(&saveas)) {
        SetFileName(szPath);
        UpdateWindowCaption();
        DoSaveFile();
    }
}
Beispiel #6
0
/**
 * Returns:
 *   TRUE  - User agreed to close (both save/don't save)
 *   FALSE - User cancelled close by selecting "Cancel"
 */
BOOL DoCloseFile(VOID)
{
    int nResult;

    if (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0))
    {
        /* prompt user to save changes */
        nResult = AlertFileNotSaved(Globals.szFileName);
        switch (nResult)
        {
            case IDYES:
                if(!DIALOG_FileSave())
                    return FALSE;
                break;

            case IDNO:
                break;

            case IDCANCEL:
                return FALSE;

            default:
                return FALSE;
        }
    }

    SetFileName(empty_str);
    UpdateWindowCaption();

    return TRUE;
}
void MainWindow::on_Load_Atlas()
{
	QString fileName = QFileDialog::getOpenFileName(this,
		tr("Open Image"), "E:/", tr("Image Files (*.nii)"));
	if (fileName.isEmpty())
	{
		return;
	}
	else
	{
		m_AtlasFileName = fileName.toStdString();
		auto reader = vtkSmartPointer<vtkNIFTIImageReader>::New();
		reader->SetFileName(m_AtlasFileName.c_str());
		reader->Update();
		m_Atlas = reader->GetOutput();

		m_Sagittal_View->Set_Mask_Img(m_Atlas);
		m_Axial_View->Set_Mask_Img(m_Atlas);
		m_Coronal_View->Set_Mask_Img(m_Atlas);

		m_Sagittal_View->RenderView();
		m_Axial_View->RenderView();
		m_Coronal_View->RenderView();
	}

}
Beispiel #8
0
VOID DIALOG_FileSaveAs(VOID)
{
    OPENFILENAME saveas;
    WCHAR szPath[MAX_PATH];
    WCHAR szDir[MAX_PATH];
    static const WCHAR szDefaultExt[] = { 't','x','t',0 };
    static const WCHAR txt_files[] = { '*','.','t','x','t',0 };

    ZeroMemory(&saveas, sizeof(saveas));

    GetCurrentDirectory(SIZEOF(szDir), szDir);
    lstrcpy(szPath, txt_files);

    saveas.lStructSize       = sizeof(OPENFILENAME);
    saveas.hwndOwner         = Globals.hMainWnd;
    saveas.hInstance         = Globals.hInstance;
    saveas.lpstrFilter       = Globals.szFilter;
    saveas.lpstrFile         = szPath;
    saveas.nMaxFile          = SIZEOF(szPath);
    saveas.lpstrInitialDir   = szDir;
    saveas.Flags             = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT |
        OFN_HIDEREADONLY;
    saveas.lpstrDefExt       = szDefaultExt;

    if (GetSaveFileName(&saveas)) {
        SetFileName(szPath);
        UpdateWindowCaption();
        DoSaveFile();
    }
}
void GcEditorSequenceMain::OnOK()
{
	// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.

	SetFileName();
	GcEditorPropertyPage::OnOK();
}
void CalibrationWindow::Act_Load_nii()
{
	QString fileName = QFileDialog::getOpenFileName(this,
		tr("Open Image"), "E:/", tr("Image Files (*.nii)"));
	if (fileName.isEmpty())
	{
		return;
	}
	
	auto reader = vtkSmartPointer<vtkNIFTIImageReader>::New();
	reader->SetFileName(fileName.toStdString().c_str());
	reader->Update();

	//extract 3d model
	auto marchingCubes = vtkSmartPointer<vtkMarchingCubes>::New();
	marchingCubes->SetInputData(reader->GetOutput());
	marchingCubes->SetValue(0, 500);
	marchingCubes->Update();

	auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
	mapper->SetInputData(marchingCubes->GetOutput());

	m_Actor2 = vtkSmartPointer<vtkActor>::New();
	m_Actor2->SetMapper(mapper);
	m_Renderer->AddActor(m_Actor2);
	m_Renderer->ResetCamera();
	m_View->Render();
}
Beispiel #11
0
/***********************************************************************
 *          HandleCommandLine
 *
 *  Handle command line options
 *
 *  ARGUMENTS:
 *    - command line options passed to the program (as string):
 *         char *cmdline
 *  RETURNS: none
 */
static void HandleCommandLine(char *cmdline)
{
    /* file name is passed in the command line */
    if (*cmdline) {
        /* Remove double-quotes from filename */
        /* Double-quotes are not allowed in Windows filenames */
        if (cmdline[0] == '"')
        {
            char *wc;
            cmdline++;
            wc = cmdline;
            while (*wc && *wc != '"') wc++;
            *wc = 0;
        }
        if (FileExists(cmdline)) {
            DoOpenFile(cmdline);
            InvalidateRect(Globals.hMainWnd, NULL, false);
        }
        else {
            switch (AlertFileDoesNotExist(cmdline)) {
                case IDYES:
                    SetFileName(cmdline);
                    UpdateWindowCaption();
                    break;

                case IDNO:
                    break;

                case IDCANCEL:
                    DestroyWindow(Globals.hMainWnd);
                    break;
            }
        }
     }
}
Beispiel #12
0
CLogOutput::CLogOutput()
    : fileName("")
    , filePath("")
{
    // multiple infologs can't exist together!
    assert(this == &logOutput);
    assert(!filelog);

    SetFileName("infolog.txt");

    bool doRotateLogFiles = false;
    std::string rotatePolicy = "auto";
    if (configHandler != NULL) {
        rotatePolicy = configHandler->GetString("RotateLogFiles");
    }
    if (rotatePolicy == "always") {
        doRotateLogFiles = true;
    } else if (rotatePolicy == "never") {
        doRotateLogFiles = false;
    } else { // auto
#ifdef DEBUG
        doRotateLogFiles = true;
#else
        doRotateLogFiles = false;
#endif
    }
    SetLogFileRotating(doRotateLogFiles);
}
Beispiel #13
0
BOOL OSndStreamWAV::OpenStream( const CUString& strFileName )
{
	SF_INFO wfInfo;

    memset(&wfInfo,0,sizeof(SF_INFO));
	wfInfo.samplerate  = GetSampleRate();
	wfInfo.frames      = -1;
	wfInfo.sections	   = 1;
	wfInfo.channels    = GetChannels();
	wfInfo.format      = (SF_FORMAT_WAV | m_OutputFormat) ;

	// Set file name
	SetFileName(strFileName);
	
    CUStringConvert strCnv;

	// Open stream
    #ifdef _UNICODE
    if (! (m_pSndFile = sf_open(	(const tchar*)strCnv.ToT( GetFileName() + _W( "." ) + GetFileExtention() ),
									SFM_WRITE,
									&wfInfo ) ) )
    #else
	if (! (m_pSndFile = sf_open(	strCnv.ToT( GetFileName() + _W( "." ) + GetFileExtention() ),
									SFM_WRITE,
									&wfInfo ) ) )
    #endif
	{
		ASSERT( FALSE );
		return FALSE;
	}

	// return Success
	return TRUE;
}
//---------------------------------------------------
//
void	TargetNode::ConvertFileName()
{
	char	*pszName = GetFileName(), szNewName[2*_MAX_PATH+1];

	if ( pszName )
		{
		 InternalConvertFileName(pszName, szNewName);
		 DeleteFileName();
		 SetFileName(szNewName );
		}
	pszName = GetFilePath();
	if ( pszName )
		{
		 InternalConvertFileName(pszName, szNewName);
		 DeleteFilePath();
		 SetFilePath(szNewName );
		}

	TargetNode* pTarget = GetFirstChildTarget();
	while ( pTarget )
		{
		 pTarget->ConvertFileName();
		 pTarget= pTarget->GetNext();
		}
}
Beispiel #15
0
void SubsController::Save(agi::fs::path const& filename, std::string const& encoding) {
	const SubtitleFormat *writer = SubtitleFormat::GetWriter(filename);
	if (!writer)
		throw "Unknown file type.";

	int old_autosaved_commit_id = autosaved_commit_id, old_saved_commit_id = saved_commit_id;
	try {
		autosaved_commit_id = saved_commit_id = commit_id;

		// Have to set this now for the sake of things that want to save paths
		// relative to the script in the header
		this->filename = filename;
		config::path->SetToken("?script", filename.parent_path());

		FileSave();

		writer->WriteFile(context->ass, filename, encoding);
	}
	catch (...) {
		autosaved_commit_id = old_autosaved_commit_id;
		saved_commit_id = old_saved_commit_id;
		throw;
	}

	SetFileName(filename);
}
Beispiel #16
0
plSoundBuffer::plSoundBuffer( const plFileName &fileName, uint32_t flags )
{
    IInitBuffer();
    SetFileName( fileName );
    fFlags = flags;
    fValid = IGrabHeaderInfo();
}
void CalibrationWindow::Act_LoadSTL()
{
	QString fileName = QFileDialog::getOpenFileName(this,
		tr("Open Image"), "E:/", tr("Image Files (*.stl)"));
	if (fileName.isEmpty())
	{
		return;
	}
	auto reader = vtkSmartPointer<vtkSTLReader>::New();
	reader->SetFileName(fileName.toStdString().c_str());
	reader->Update();
	
	auto image = vtkSmartPointer<vtkPolyData>::New();
	image = reader->GetOutput();
	auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
	mapper->SetInputData(image);
	m_Actor = vtkSmartPointer<vtkActor>::New();
	m_Actor->SetMapper(mapper);
	//vtkSmartPointer<vtkAxesActor> axes =
	//	vtkSmartPointer<vtkAxesActor>::New();
	//axes->SetTotalLength(200.0, 200.0, 200.0);
	//
	//m_Actor = axes;
	m_Renderer->AddActor(m_Actor);
	m_Renderer->ResetCamera();
	m_View->Render();
}
bool CCollectionFile::InitFromLink(CString sLink)
{
	CED2KLink* pLink = NULL;
	CED2KFileLink* pFileLink = NULL;
	try 
	{
		pLink = CED2KLink::CreateLinkFromUrl(sLink);
		if(!pLink)
			throw GetResString(IDS_ERR_NOTAFILELINK);
		pFileLink = pLink->GetFileLink();
		if (!pFileLink)
			throw GetResString(IDS_ERR_NOTAFILELINK);
	} 
	catch (CString error) 
	{
		CString strBuffer;
		strBuffer.Format(GetResString(IDS_ERR_INVALIDLINK),error);
		LogError(LOG_STATUSBAR, GetResString(IDS_ERR_LINKERROR), strBuffer);
		return false;
	}

	taglist.Add(new CTag(FT_FILEHASH, pFileLink->GetHashKey()));
	md4cpy(m_abyFileHash, pFileLink->GetHashKey());

	taglist.Add(new CTag(FT_FILESIZE, pFileLink->GetSize()));
	SetFileSize(pFileLink->GetSize());

	taglist.Add(new CTag(FT_FILENAME, pFileLink->GetName()));
	SetFileName(pFileLink->GetName(), false, false);

	delete pLink;
	return true;
}
Beispiel #19
0
bool COggData::InitOggFile(const VfsPath& itemPath)
{
	int buffersToStart = g_SoundManager->GetBufferCount();	
	if ( OpenOggNonstream( g_VFS, itemPath, ogg) == INFO::OK )
	{
		m_FileFinished = false;

		SetFormatAndFreq(ogg->Format(), ogg->SamplingRate() );
		SetFileName( itemPath );
	
		AL_CHECK
		
		alGenBuffers(buffersToStart, m_Buffer);
		
		if(alGetError() != AL_NO_ERROR) 
		{
			LOGERROR( L"- Error creating initial buffer !!\n");
			return false;
		}
		else
		{
			m_BuffersUsed = FetchDataIntoBuffer(buffersToStart, m_Buffer);
			if (m_FileFinished)
			{
				m_OneShot = true;
				if (m_BuffersUsed < buffersToStart)
				{
					alDeleteBuffers(buffersToStart - m_BuffersUsed, &m_Buffer[m_BuffersUsed]);
				}
			}
			AL_CHECK
		}
		return true;
	}
Beispiel #20
0
TiXmlElement* CXmlFile::Load(const wxFileName& fileName)
{
	if (fileName.IsOk())
		SetFileName(fileName);

	wxCHECK(m_fileName.IsOk(), 0);

	delete m_pDocument;
	m_pDocument = 0;

	TiXmlElement* pElement = GetXmlFile(m_fileName);
	if (!pElement)
	{
		m_modificationTime = wxDateTime();
		return 0;
	}

	{
		wxLogNull log;
		m_modificationTime = m_fileName.GetModificationTime();
	}

	m_pDocument = pElement->GetDocument();
	return pElement;
}
Beispiel #21
0
/**
 * Returns:
 *   TRUE  - User agreed to close (both save/don't save)
 *   FALSE - User cancelled close by selecting "Cancel"
 */
BOOL DoCloseFile(void)
{
    int nResult;
    static const WCHAR empty_strW[] = { 0 };

    if (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0))
    {
        /* prompt user to save changes */
        nResult = AlertFileNotSaved(Globals.szFileName);
        switch (nResult) {
            case IDYES:     DIALOG_FileSave();
                            break;

            case IDNO:      break;

            case IDCANCEL:  return(FALSE);
                            break;

            default:        return(FALSE);
                            break;
        } /* switch */
    } /* if */

    SetFileName(empty_strW);

    UpdateWindowCaption();
    return(TRUE);
}
Beispiel #22
0
TiXmlElement* CXmlFile::Load(const wxFileName& fileName)
{
	if (fileName.IsOk())
		SetFileName(fileName);

	wxCHECK(m_fileName.IsOk(), 0);

	delete m_pDocument;
	m_pDocument = 0;

	wxString error;
	TiXmlElement* pElement = GetXmlFile(m_fileName, &error);
	if (!pElement)
	{
		if (!error.empty())
		{
			m_error.Printf(_("The file '%s' could not be loaded."), m_fileName.GetFullPath().c_str());
			if (!error.empty())
				m_error += _T("\n") + error;
			else
				m_error += wxString(_T("\n")) + _("Make sure the file can be accessed and is a well-formed XML document.");
			m_modificationTime = wxDateTime();
		}
		return 0;
	}

	{
		wxLogNull log;
		m_modificationTime = m_fileName.GetModificationTime();
	}

	m_pDocument = pElement->GetDocument();
	return pElement;
}
Beispiel #23
0
//---------------------------------------------------------------------------
void __fastcall TFormMain::FormCreate(TObject *Sender)
{
  SetFileName("");
  PaintBox->ControlStyle = PaintBox->ControlStyle << csOpaque;
  SetZoom(11);

  Graphics::TBitmap* BM = new Graphics::TBitmap;
  __try
  {
    BM->Width = 64;
    BM->Height = 64;
    
    for (int i = 0; i < YETI_TEXTURE_MAX; i++)
    {
      for (int y = 0; y < 64; y++)
      {
        for (int x = 0; x < 64; x++)
        {
          int c = textures[i][y][x];
          BM->Canvas->Pixels[x][y] = (TColor) RGB(
            palette[c][0], palette[c][1], palette[c][2]);
        }
      }
      TListItem* LI = ListView->Items->Add();
      LI->Caption = String("#") + i;
      LI->ImageIndex = ILTextures->Add(BM, NULL);
    }
  }
  __finally
  {
    BM->Free();
  }
  ListView->ItemIndex = 0;
}
JFileID::JFileID
	(
	const JCharacter* fullName
	)
{
	SetFileName(fullName);
}
Beispiel #25
0
CXmlFile::CXmlFile(wxString const& fileName, wxString const& root)
{
	if (!root.empty()) {
		m_rootName = root;
	}
	SetFileName(fileName);
}
void CPropFunction::FillDialog()
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState( ));

    SetFileName();
    string buf;
    ReadFileContent(CString(m_ProjectPath) + _T("\\") + m_sFileName, buf);
    m_FunctionText = buf.c_str();
    m_Function = (Function *)ParsePou(m_FunctionText, m_Function);
    InitFromFile(m_Function);
    COperation::FillDialog();
    GetDialog()->SetCreateUser(m_sCreateUser);
    GetDialog()->SetCreateDate(m_sCreateDate);
    GetDialog()->SetLastModUser(m_sLastModUser);
    GetDialog()->SetLastModDate(m_sLastModDate);
    GetDialog()->SetAlias(m_sAlias);
    GetDialog()->SetName(m_sName);
    GetDialog()->SetText1(m_sUsrText[0]);
	GetDialog()->SetText2(m_sUsrText[1]);
	GetDialog()->SetText3(m_sUsrText[2]);
	GetDialog()->SetHelpUrl(m_sHelpUrl);
	GetDialog()->SetUrl(m_sUrl);

    GetDialog()->SetMembers(m_pMembers);
    m_pMembers = NULL;

    GetDialog()->SetReturnType(m_sFunctionType);
}
CXmlFile::CXmlFile(std::wstring const& fileName, std::string const& root)
{
	if (!root.empty()) {
		m_rootName = root;
	}
	SetFileName(fileName);
}
Beispiel #28
0
void CMeshShape::Init(Data::PParams Desc)
{
	InitialTfm.ident(); //??? (was in mangalore, see XML CompositeLoader)
	SetTransform(InitialTfm);
	SetMaterialType(CMaterialTable::StringToMaterialType(Desc->Get<nString>(CStrID("Mtl"), "Metal")));
	SetFileName(Desc->Get<nString>(CStrID("File")));
}
Beispiel #29
0
VOID DoOpenFile(LPCTSTR szFileName)
{
    static const TCHAR dotlog[] = _T(".LOG");
    HANDLE hFile;
    LPTSTR pszText = NULL;
    DWORD dwTextLen;
    TCHAR log[5];

    /* Close any files and prompt to save changes */
    if (!DoCloseFile())
        return;

    hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
                       OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    if (hFile == INVALID_HANDLE_VALUE)
    {
        ShowLastError();
        goto done;
    }

    if (!ReadText(hFile, (LPWSTR *)&pszText, &dwTextLen, &Globals.iEncoding, &Globals.iEoln))
    {
        ShowLastError();
        goto done;
    }
#ifndef UNICODE
    pszText = ConvertToASCII(pszText);
    if (pszText == NULL) {
        ShowLastError();
        goto done;
    }
#endif
    SetWindowText(Globals.hEdit, pszText);

    SendMessage(Globals.hEdit, EM_SETMODIFY, FALSE, 0);
    SendMessage(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0);
    SetFocus(Globals.hEdit);

    /*  If the file starts with .LOG, add a time/date at the end and set cursor after
     *  See http://support.microsoft.com/?kbid=260563
     */
    if (GetWindowText(Globals.hEdit, log, SIZEOF(log)) && !_tcscmp(log, dotlog))
    {
        static const TCHAR lf[] = _T("\r\n");
        SendMessage(Globals.hEdit, EM_SETSEL, GetWindowTextLength(Globals.hEdit), -1);
        SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)lf);
        DIALOG_EditTimeDate();
        SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)lf);
    }

    SetFileName(szFileName);
    UpdateWindowCaption();
    NOTEPAD_EnableSearchMenu();
done:
    if (hFile != INVALID_HANDLE_VALUE)
        CloseHandle(hFile);
    if (pszText)
        HeapFree(GetProcessHeap(), 0, pszText);
}
Beispiel #30
0
CLogFile::CLogFile(TCHAR *name)
{
    hLogFile = INVALID_HANDLE_VALUE;//初始化
    memset(file_name,0,MAX_PATH);//名清0

    SetFileName(name);//设置文件名
    InitFile();
}