Permalänk
Medlem

Win GUI Problem (C++)

Hej, när jag kodar i Dev-C++ så får jag inga problem när jag kompilerar.
Men när jag använder MSVC++6 så får jag följande problem:

LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/Zpad.exe : fatal error LNK1120: 1 unresolved externals

så här ser ett kod exempel ut:

#include <windows.h> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { static TCHAR szAppName[] = TEXT("ZPad"); HWND hWnd; MSG Msg; WNDCLASS wndClass; wndClass.style = CS_HREDRAW | CS_VREDRAW; wndClass.lpfnWndProc = WndProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0; wndClass.hInstance = hInstance; wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); wndClass.hCursor = LoadCursor(NULL, IDC_ARROW); wndClass.hbrBackground = (HBRUSH)GetStockObject (WHITE_BRUSH); wndClass.lpszMenuName = NULL; wndClass.lpszClassName = szAppName; if(!RegisterClass (&wndClass)) { MessageBox(NULL, TEXT("This program requires Windows NT!"), szAppName, MB_ICONERROR); return 0; } hWnd = CreateWindow(szAppName, TEXT("ZPad"), WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); ShowWindow(hWnd, iCmdShow); UpdateWindow(hWnd); while(GetMessage(&Msg, NULL, 0,0)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; } LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; RECT rect; switch(Message) { case WM_CREATE: MessageBox(hWnd, TEXT("Welcome to ZPad!"), TEXT("ZPad 2005"), MB_OK); return 0; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); GetClientRect(hWnd, &rect); DrawText(hdc, TEXT("ZPad, Just displat message!"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); EndPaint(hWnd, &ps); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hWnd, Message, wParam, lParam); }

Visa signatur

C#/MonoGame Fanatiker.
Pixel Artist & Game Developer

Permalänk
Medlem

Du måste skapa ett "Win32 project" (Windows projekt alltså), nu kör du med ett "Win32 console project".
Windows och konsol program använder olika subsystem.

[EDIT] Personligen så rekommenderar jag att du inte 6.0 då den versionen suger på alla sätt, använd helst 2003 .Net eller 2005 Beta 2.

Visa signatur

Intel Core i7-3770K | NVIDIA Geforce GTX 980 | 16 GB DDR3 | DELL P2415Q | DELL U2711 | DELL U2410

Permalänk
Medlem

ahaa
Danke.

Visa signatur

C#/MonoGame Fanatiker.
Pixel Artist & Game Developer