when i compile this code i get an error. I got this code from a tutorial so i think it must be the program i am using to compile it. I tried Microsoft visual and borland and both of them dident word.
// Find out if the window was created
if( !hWnd ) // If the window was not created,
return 0; // stop the application
// Display the window to the user
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);
// Decode and treat the messages
// as long as the application is running
while( GetMessage(&Msg, NULL, 0, 0) )
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg,
WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
// If the user wants to close the application
case WM_DESTROY:
// then close it
PostQuitMessage(WM_QUIT);
break;
default:
// Process the left-over messages
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
// If something was not done, let it go
return 0;
}
------------------------------------
HERES THE ERROR MESSAGE!!!!!!!!!!!
WHAT IS THE PROBLEM????????????
------------------------------------
bcc32 -D_DEBUG -g100 -j25 -Od -r- -k -y -v -vi- -tWC -c -IC:\CBuilderX\include -o"C:\Documents and Settings\StealthOp1217\cbproject\ConsoleApp1\windows\Debug_Build\File1.obj" File1.cpp
Borland C++ 5.6.4 for Win32 Copyright (c) 1993, 2002 Borland
File1.cpp:
"File1.cpp": W8057 Parameter 'hPrevInstance' is never used in function __stdcall WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) at line 63
"File1.cpp": W8057 Parameter 'lpCmdLine' is never used in function __stdcall WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) at line 63
"File1.cpp": W8057 Parameter 'nCmdShow' is never used in function __stdcall WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) at line 63
ilink32 -D -ap -Tpe -x -Gn -v -LC:\CBuilderX\lib c0x32.obj windows\Debug_Build\File1.obj,"C:\Documents and Settings\StealthOp1217\cbproject\ConsoleApp1\windows\Debug_Build\ConsoleApp1.exe",,cw32.lib import32.lib,,
Turbo Incremental Link 5.65 Copyright (c) 1997-2002 Borland
Error: Unresolved external '_main' referenced from C:\CBUILDERX\LIB\C0X32.OBJ
ILINK32 exited with error code: 2
Build cancelled due to errors
If you use VC, the error may be caused by /SUBSYSTEM, one of linker's switches. It can be set as "CONSOLE" for CUI application and "WINDOWS" for GUI application, respectively. When linking, the linker will look for _main if /SUBSYSTEM:CONSOLE is set.
The solutions:
1. Click on the Link tab of the Project Settings dialog box and change the /SUBSYSTEM:CONSOLE switch to /SUBSYSTEM: WINDOWS.
2. Click on the Link tab of the Project Settings dialog box and delete the /SUBSYSTEM:WINDOWS switch entirely. Now, the linker will simply do the right thing based on which function you implement in your source code.