c2c Subj : Help a newbie to C create a Window in WinXP To : borland.public.cpp.borlandcpp From : sweetnjguy29 Date : Fri Feb 18 2005 11:27 am I recently downloaded theForger's Win32 API Tutorial to teach myself the basics of C programming in Windows. I have successfully compiled and run several simple C programs using the Borland's free DOS shell C++ compiler. However, I can not seem to create even a simple window. What am I doing wrong? I get 3 warnings/errors: Two saying that hPrevInstance and lpCmdLine is never used in function WinMain and an error that says Unresolved external _main referenced from C:\BORLAND\BCC55\LIB\COX32.OBJ Can someone provide me with simple steps to resolve this problem. I need some hand holding here. I think it has something to do with making sure that I have specified a Win32 GUI project/makefile/target for the compiler, but I have no clue how to do this in Borland. If it cant be done using Borland's free compiler, what free compiler would? (I have gcc on a Linux machine too) Thanks for your help in advance... My code appears below: #include const char g_szClassName[] = "myWindowClass"; // Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg; //Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } // Step 2: Creating the Window hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, g_szClassName, "The title of my window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, hInstance, NULL); if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); // Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; } . 0