Formatierung mit einer Variablen und _T()



  • Hallo

    Ich arbeite mit embedded c++ 4.0

    da soll per buttonclick ein Datei öffnen dialog geöffnet werden

    jetzt hab ich aber das problem, dass er alles an strings egal wo (MessageBoxes etc) mit _T() "umgewandelt" haben will

    sprich:

    MessageBox(_T("Fehler"),NULL,MB_OK);

    so, da das für die datei öffnen aber ne struktur ist, muss ich dort eine variable damit "umwandeln" lassen.

    kann mir jemand sagen wie ich das machen muss?

    hier der code

    //Header

    typedef struct tagOFN
    	{
    		DWORD         lStructSize;
    		HWND          hwndOwner;
    		HINSTANCE     hInstance;
    		LPCTSTR       lpstrFilter;
    		LPTSTR        lpstrCustomFilter;
    		DWORD         nMaxCustFilter;
    		DWORD         nFilterIndex;
    		LPTSTR        lpstrFile;
    		DWORD         nMaxFile;
    		LPTSTR        lpstrFileTitle;
    		DWORD         nMaxFileTitle;
    		LPCTSTR       lpstrInitialDir;
    		LPCTSTR       lpstrTitle;
    		DWORD         Flags;
    
    		WORD          nFileOffset;
    		WORD          nFileExtension;
    		LPCTSTR       lpstrDefExt;
    		DWORD         lCustData;
    		LPOFNHOOKPROC lpfnHook;
    		LPCTSTR       lpTemplateName;
    	} OPENFILENAME;
    

    //CPP
    [cpp]

    void CTestDlg::OnButton3()
    {
    // TODO: Add your control notification handler code here
    //OPENFILE initialisieren
    char DateiName[_MAX_PATH+1] = "";
    ofn.lStructSize = sizeof (OPENFILENAME);
    ofn.hwndOwner = NULL;
    ofn.nMaxFile = _MAX_PATH;
    ofn.lpstrFile = DateiName; //diese Zeile muss gewandelt werden
    ofn.lpstrFilter = _T("All Files (.)\0*.*\0");

    //Get Filename
    GetOpenFileName(&ofn);

    m_strFileName.Format(_T("%s"),ofn.lpstrFile);
    }
    [/cpp]



  • Warum definierst Du "DateiName" als "char"??? Das ist natprlich ein grosser Bruch... und macht das ganze UNICODE wieder zu nichte...
    Definiere es bitte als TCHAR...



  • jo, alles klar

    danke dir


Anmelden zum Antworten