Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
/* * All the Code is written by Kevin Riehl alias Developer_X * Copyright 2011 */ #include <windows.h> #include <string.h> #include <iostream> using namespace std; string openfilename(char *filter = "All Files (*.*)\0*.*\0", HWND owner = NULL) { OPENFILENAMEW ofn; char fileName[MAX_PATH] = ""; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = owner; ofn.lpstrFilter = filter; ofn.lpstrFile = fileName; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrDefExt = ""; string fileNameStr; if ( GetOpenFileName(&ofn) ) fileNameStr = fileName; return fileNameStr; } int main() { cout << openfilename().c_str() << endl; return 0; } |
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
F:\C++ Projekte\Diagramm Maker\main.cpp||In function 'std::string openfilename(char*, HWND__*)':| F:\C++ Projekte\Diagramm Maker\main.cpp|28|error: 'OPENFILENAMEW' was not declared in this scope| F:\C++ Projekte\Diagramm Maker\main.cpp|28|error: expected ';' before 'ofn'| F:\C++ Projekte\Diagramm Maker\main.cpp|30|error: 'ofn' was not declared in this scope| F:\C++ Projekte\Diagramm Maker\main.cpp|31|error: 'OPENFILENAME' was not declared in this scope| F:\C++ Projekte\Diagramm Maker\main.cpp|36|error: 'OFN_EXPLORER' was not declared in this scope| F:\C++ Projekte\Diagramm Maker\main.cpp|36|error: 'OFN_FILEMUSTEXIST' was not declared in this scope| F:\C++ Projekte\Diagramm Maker\main.cpp|36|error: 'OFN_HIDEREADONLY' was not declared in this scope| F:\C++ Projekte\Diagramm Maker\main.cpp|38|error: 'GetOpenFileName' was not declared in this scope| F:\C++ Projekte\Diagramm Maker\main.cpp||In function 'int main()':| F:\C++ Projekte\Diagramm Maker\main.cpp|44|warning: deprecated conversion from string constant to 'char*'| ||=== Build finished: 8 errors, 1 warnings ===| |
'OPENFILENAMEW' was not declared in this scope
'ofn' was not declared in this scope
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
string openfilename(char *filter = "All Files (*.*)\0*.*\0", HWND owner = NULL) { OPENFILENAMEW ofn; char fileName[MAX_PATH] = ""; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = owner; ofn.lpstrFilter = filter; ofn.lpstrFile = fileName; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrDefExt = ""; string fileNameStr; if ( GetOpenFileName(&ofn) ) fileNameStr = fileName; return fileNameStr; } |
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 |
F:\C++ Projekte\Diagramm Maker\main.cpp||In function 'std::string openfilename(char*, HWND__*)':| F:\C++ Projekte\Diagramm Maker\main.cpp|30|error: int-array initialized from non-wide string| F:\C++ Projekte\Diagramm Maker\main.cpp|34|error: cannot convert 'char*' to 'const WCHAR*' in assignment| F:\C++ Projekte\Diagramm Maker\main.cpp|37|error: cannot convert 'const char [1]' to 'const WCHAR*' in assignment| F:\C++ Projekte\Diagramm Maker\main.cpp|39|error: cannot convert 'OPENFILENAMEW*' to 'tagOFNA*' for argument '1' to 'BOOL GetOpenFileNameA(tagOFNA*)'| F:\C++ Projekte\Diagramm Maker\main.cpp|40|error: invalid conversion from 'WCHAR*' to 'char'| F:\C++ Projekte\Diagramm Maker\main.cpp|40|error: initializing argument 1 of 'std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]'| F:\C++ Projekte\Diagramm Maker\main.cpp||In function 'int main()':| F:\C++ Projekte\Diagramm Maker\main.cpp|45|warning: deprecated conversion from string constant to 'char*'| ||=== Build finished: 6 errors, 1 warnings ===| |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
string openfilename(char *filter = "All Files (*.*)\0*.*\0", HWND owner = NULL) { OPENFILENAME ofn; char fileName[MAX_PATH] = ""; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = owner; ofn.lpstrFilter = filter; ofn.lpstrFile = fileName; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrDefExt = ""; string fileNameStr; if (GetOpenFileName(ofn)) fileNameStr = fileName; return fileNameStr; } |
Quellcode |
|
1 2 3 4 5 |
F:\C++ Projekte\Diagramm Maker\main.cpp||In function 'std::string openfilename(char*, HWND__*)':| F:\C++ Projekte\Diagramm Maker\main.cpp|39|error: cannot convert 'OPENFILENAME' to 'tagOFNA*' for argument '1' to 'BOOL GetOpenFileNameA(tagOFNA*)'| F:\C++ Projekte\Diagramm Maker\main.cpp||In function 'int main()':| F:\C++ Projekte\Diagramm Maker\main.cpp|45|warning: deprecated conversion from string constant to 'char*'| ||=== Build finished: 1 errors, 1 warnings ===| |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
string openfilename(char *filter = "All Files (*.*)\0*.*\0", HWND owner = NULL) { OPENFILENAMEA ofn; char fileName[MAX_PATH] = ""; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = owner; ofn.lpstrFilter = filter; ofn.lpstrFile = fileName; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrDefExt = ""; string fileNameStr; if (GetOpenFileNameA(&ofn)) fileNameStr = fileName; return fileNameStr; } |
Werbeanzeige