Franks C++ .NET Programmiertips für einige kniffelige Probleme
Wie kann ich ein Item in einer ComboBox (ohne Mouse) selektieren und auslesen?
...
HWND myHandle= (HWND)this->comboBox1->Handle.ToPointer();
//HWND Konvertierung
::SendMessage(myHandle, CB_SETCURSEL, (WPARAM)0, 0 );
//WPARAM 0 ist erstes Item in der Droplist
comboBox1->Text=comboBox1->SelectedItem->ToString();
//damit wird der Itemtext ins ComboBox Textfeld übertragen
...
zum Linken ist es notwendig: #pragma comment(lib, "user32.lib") einzufügen!
Wie kann ich das aktuelle Arbeitsverzeichnis ermitteln?
//Aktuelles Arbeitsverzeichnis ermitteln und in root speichern...
wchar_t w_pcRootLocation[MAX_PATH+100];
GetCurrentDirectoryW(MAX_PATH, w_pcRootLocation);
//Verzeichnis als wchar_t auslesen
char pfstr[MAX_PATH+100];
wcstombs(pfstr, w_pcRootLocation,MAX_PATH+100);
//nun als char
std::string tstr = pfstr;
//nun als std::string
root=gcnew System::String(tstr.c_str());
//nun endlich als String^
...