Muster-Quelltext funktioniert nicht. Tutorial alt?
-
http://www.pronix.de/pronix-1037.html
Hab nun das Tutorial gemacht und auch den Code benutzt.
Aber es kommen noch Fehlermeldungen beim Compilieren obwohl ich exxact den Code genommen habe:Error 1 error C2440: '=' : cannot convert from 'LPCSTR' to 'LPCWSTR'
Error 2 error C2440: '=' : cannot convert from 'LPCSTR' to 'LPCWSTR'
Error 3 error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'LPCSTR' to 'LPCWSTR'
-
Du musst dein Projekt von Unicode auf MBCS (multi-byte character set) umstellen.
-
Oder am besten das Beispiel korrigieren; dann geht es sowohl mit MBCS als auch Unicode:
#include <windows.h> #include <tchar.h> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); LPCTSTR lpszAppName = _T("AppName"); LPCTSTR lpszTitle = _T("Meine erste Applikation"); int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR szCmdLine, int iCmdShow) { HWND hWnd; MSG msg; WNDCLASSEX wc; wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.lpszClassName = lpszAppName; wc.lpszMenuName = lpszAppName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if( RegisterClassEx(&wc) == 0) return 0; hWnd = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, lpszAppName, lpszTitle, WS_OVERLAPPEDWINDOW, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); if( hWnd == NULL) return 0; ShowWindow(hWnd, iCmdShow); UpdateWindow(hWnd); while (GetMessage(&msg, NULL, 0, 0) > 0) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK WndProc(HWND hWnd, UINT umsg, WPARAM wParam, LPARAM lParam) { switch (umsg) { case WM_DESTROY: { PostQuitMessage(0); return 0; } } return DefWindowProc(hWnd, umsg, wParam, lParam); }