[ IvanBeograd @ 23.06.2006. 03:20 ] @
Pozdrav,pokusavam da napravim nesto preko WinAPI-ja,ovo sam cesto radio u Delphiju, i nikada nisam imao problema,ja ne vidim u cemu je problem,gde gresim,nece ni obican prozor da mi napravi. Koristim Visual Studio 2005,a i pokusao sam kompajlirati i preko Free Command Line Tools-a,i nece, prijavljuje gresku oko kastovanja,guglovao sam i nalazio primere neke i tutoriale,ali code je bukvalno isti ali moj ne radi,a ni code iz tutoriala ne radi,sto je cudno jer je to tutorial,moze li neko da pogleda i da mi kaze gde gresim,hvala unapred. Code: #include <windows.h> const char ClsName[] = "proba"; LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg,WPARAM wParam, LPARAM lParam) { switch(Msg){ case WM_DESTROY: PostQuitMessage(WM_QUIT); break; default: return DefWindowProc(hWnd, Msg, wParam, lParam); } return 0; } INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow) { MSG Msg; HWND hWnd; WNDCLASSEX WndClsEx; WndClsEx.cbSize = sizeof(WNDCLASSEX); WndClsEx.style = CS_HREDRAW | CS_VREDRAW; WndClsEx.lpfnWndProc = WndProcedure; WndClsEx.cbClsExtra = 0; WndClsEx.cbWndExtra = 0; WndClsEx.hIcon = LoadIcon(NULL, IDI_APPLICATION); WndClsEx.hCursor = LoadCursor(NULL, IDC_ARROW); WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); WndClsEx.lpszMenuName = NULL; WndClsEx.lpszClassName = ClsName; // ovo kad kastujem (LPCWSTR)ClsName kompajler pokazuje jednu gresku manje WndClsEx.hInstance = hInstance; WndClsEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION); RegisterClassEx(&WndClsEx); // i kod ove f-je mi javlja gresku ali nemogu da je neutralisem :( hWnd = CreateWindowEx( WS_EX_CLIENTEDGE, ClsName, "Naslov moje forme", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL ); if( !hWnd ) return 0; ShowWindow(hWnd, SW_SHOWNORMAL); UpdateWindow(hWnd); while( GetMessage(&Msg, NULL, 0, 0) ) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; } A ovo mi prijavi : Code: ------ Build started: Project: f1, Configuration: Debug Win32 ------ Compiling... f1.cpp c:\documents and settings\ivan\my documents\visual studio 2005\projects\f1\f1\f1.cpp(32) : error C2440: '=' : cannot convert from 'const char [6]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast c:\documents and settings\ivan\my documents\visual studio 2005\projects\f1\f1\f1.cpp(51) : error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [6]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast c:\documents and settings\ivan\my documents\visual studio 2005\projects\f1\f1\f1.cpp(65) : warning C4244: 'return' : conversion from 'WPARAM' to 'int', possible loss of data Build log was saved at "file://c:\Documents and Settings\Ivan\My Documents\Visual Studio 2005\Projects\f1\f1\Debug\BuildLog.htm" f1 - 2 error(s), 1 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Hvala unapred,pozz |