Tuesday, July 14, 2009

Whats wrong with the following code but it gives me the linking error in microsoft visual c++?

#define WIN32_LEAN_AND_MEAN


#include%26lt;windows.h%26gt;


LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam);


int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hprevinstance,LPSTR lpCmdLine,int nShowCmd)


{


WNDCLASSEX wc;


HWND hwnd;


MSG msg;


////////Window Class Structure


wc.cbSize=sizeof(WNDCLASSEX);


wc.style=CS_HREDRAW | CS_VREDRAW;


wc.cbClsExtra=0;


wc.cbWndExtra=0;


wc.hInstance=hinstance;


wc.hIcon=LoadIcon(NULL,IDI_APPLICATIO...


wc.hCursor=LoadCursor(NULL,IDC_ARROW)...


wc.hbrBackground=(HBRUSH)GetStockObje...


wc.lpszMenuName=NULL;


wc.lpszClassName="sono";


wc.hIconSm=LoadIcon(NULL,IDI_WINLOGO)...


wc.lpfnWndProc=WndProc;


/////////////////////


//register the class


if(!RegisterClassEx(%26amp;wc))


{


return 0;


}


hwnd=CreateWindow("sono","My APP", WS_OVERLAPPED | WS_POPUP ,100,100,250,250,NULL,NULL,hinstance,NUL...


/////////////


if(hwnd==NULL)


{


return 0;


}


ShowWindow(hwnd,nShowCmd);


UpdateWindow(hwnd);


bool done=true;


while(done)


{


PeekMessage(%26amp;msg,hwnd,0,0,PM_REMOVE)...


if(msg.message==WM_QUIT)


done=false;


else


{


TranslateMessage(%26amp;msg);


DispatchMessage(%26amp;msg);


}


}


return msg.wParam;


}


LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)


{


HDC hdc;


char string[]="Ha ha ha";


PAINTSTRUCT paint;


switch(message)


{


case WM_PAINT:


hdc=BeginPaint(hwnd,%26amp;paint);





SetTextColor(hdc,COLORREF(0x00FF0000...


TextOut(hdc,150,150,string,sizeof(st...


EndPaint(hwnd,%26amp;paint);


return 0;


break;


default:


break;


}


return DefWindowProc(hwnd,message,wparam,lparam...


}

Whats wrong with the following code but it gives me the linking error in microsoft visual c++?
A linker error isn't caused by any syntax error in your code. You're probably missing some library that you had to link to. but i've never had any problem compiling something as basic as that, so i have no idea which.





Can you put the exact linker error to clarify what is the problem?


No comments:

Post a Comment