Msgbox
-
Hi Leute,
Ich habe mir eine Funktion zum ausgeben einer Messagebox geschrieben. Übergeben werden zwei Strings, die dann Titel und Text angeben.
Variablen "a" und "b" sind die übergabeparameter.
Leider funktioniert das Ganze nicht:void msgbox(String a, String b) { typedef int (WINAPI *MessageBoxTimeOutWFunc)(HWND hWndParent,PWCHAR strText,PWCHAR strCaption, UINT uType,WORD wLanguageId,DWORD dwMilliseconds); HMODULE hMod = LoadLibrary("user32.dll"); MessageBoxTimeOutWFunc pMessageBoxTimeout = (MessageBoxTimeOutWFunc)GetProcAddress(hMod,"MessageBoxTimeoutW"); pMessageBoxTimeout(NULL,L""+a,L""+b,MB_OK | MB_SETFOREGROUND,0,3000); FreeLibrary(hMod); }Fehler:
http://Jesusfreak777.je.funpic.de/error.JPG
cya
David
-
Hallo
Du kannst einen AnsiString nicht auf ein C-String-Literal addieren, auf ein Widechar-Literal schon gar nicht. Da es dir ja offenbar nur um die konvertierung von AnsiString in WideString geht, reicht ja das hier
void msgbox(const String& a, const String& b) { typedef int (WINAPI *MessageBoxTimeOutWFunc)(HWND hWndParent,PWCHAR strText,PWCHAR strCaption, UINT uType,WORD wLanguageId,DWORD dwMilliseconds); HMODULE hMod = LoadLibrary("user32.dll"); MessageBoxTimeOutWFunc pMessageBoxTimeout = (MessageBoxTimeOutWFunc)GetProcAddress(hMod,"MessageBoxTimeoutW"); WideString a1 = a; WideString b1 = b; pMessageBoxTimeout(NULL,a1.c_bstr(),b1.c_bstr(),MB_OK | MB_SETFOREGROUND,0,3000); FreeLibrary(hMod); }bis bald
akari
-
SUPER!
Das funktioniert- danke
-
Außerdem ist der Verzeichnisname C++ denkbar ungünstig. Das wird zu Problemen im BCB führen.