hey, i am a beginner in windows programming. I have written a code for drawing shapes as follows:-
#include <windows.h>
void OnPaint(HWND);
void OnDestroy(HWND);
int stdcall WinMain(HINSTANCE HInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdline, int nCmdShow)
{
MSG m;
//PERFORM APPLICATION INITIALIZATION
InitInstance(hinstance, nCmdShow, "Text");
//main message loop
while(GetMessage(&m,NULL,0,0))
DispatchMessage(&m);
return 0;
}
LRESULT CALLBACK WndProc(HWND hWnd , UINT message, WPARAM wParam,LPARAM lParam)
/*WndProc=windows procedure.This function is a message processing function
for our window. It will process any messages Windows sends to our program.
A callback function is a function in your program that is called by the operating system.
You see, in our program we will never actually call the function WndProc().
Windows will do that when ever it sends a message to our program. more on that later.*/
{
switch(message)
{
case WM_DESTROY:
OnDestroy(hWnd);
break;
case WM_PAINT:
OnPaint(hWnd);
break;
default:
return DefWindowProc(hWnd,message,wParam,lParam);
}
return 0;
}
void OnDestroy(HWND hWnd)
{
PostQuitMessage(0);
}
void OnPaint (HWND hWnd)
{
HDC hdc;
PAINTSTRUCT ps;
HBRUSH hbr;
HGDIOBJ holdbr;
POINT pt[5]={250,150,250,300,300,350,400,300,320,190};
hdc=BeginPaint(hWnd,&ps);
hbr=CreateSolidBrush(RGB(25,0,0));
holdbr=SelectObject(hdc,hbr);
MoveToEx(hdc,10,10,NULL);
LineTo(hdc,200,10);
Rectangle(hdc,10,20,200,100);
RoundRect(hdc,10,120,200,220,20,20);
Ellipse(hdc, 10,240,200,340);
Pie(hdc,250,10,350,110,350,110,350,10);
Polygon(hdc,pt,5);
SelectObject(hdc,holdbr);
DeleteObject(hbr);
EndPAint(hWnd, &ps);
}
and i am getting following errors:
C:\Documents and Settings\acer\My Documents\Pelles C Projects\new_try\nn.c(9): error #2001: Syntax error: expected ';' but found 'WinMain'.
C:\Documents and Settings\acer\My Documents\Pelles C Projects\new_try\nn.c(9): warning #2099: Missing type specifier; assuming 'int'.
C:\Documents and Settings\acer\My Documents\Pelles C Projects\new_try\nn.c(10): error #2120: Redeclaration of 'WinMain', previously declared at C:\Program Files\PellesC\Include\Win\winbase.h(1438); expected 'int __stdcall function(HINSTANCE, HINSTANCE, char *, int)' but found 'int __cdecl function(HINSTANCE, HINSTANCE, char *, int)'.
C:\Documents and Settings\acer\My Documents\Pelles C Projects\new_try\nn.c(14): warning #2018: Undeclared function 'InitInstance'; assuming 'extern' returning 'int'.
C:\Documents and Settings\acer\My Documents\Pelles C Projects\new_try\nn.c(14): error #2048: Undeclared identifier 'hinstance'.
C:\Documents and Settings\acer\My Documents\Pelles C Projects\new_try\nn.c(76): warning #2018: Undeclared function 'EndPAint'; assuming 'extern' returning 'int'.
*** Error code: 1 ***
Done.
Please help me out