C语言以下代码可以在vc6中编译通过,codeblocks和vs2013中出错 50
#include<windows.h>#include<conio.h>intmain(){HWNDhwnd=GetForegroundWindow();printf("...
#include<windows.h>
#include<conio.h>
int main()
{
HWND hwnd=GetForegroundWindow();
printf("%X\n",hwnd);
RECT rect,rce;
GetWindowRect(hwnd,&rect);
HDC dc=GetDC(hwnd);
HBRUSH holdbrush,hnewbrush;
hnewbrush=GetSysColorBrush(rand()&21);
holdbrush=(HBRUSH)SelectObject(dc,hnewbrush);
while(!kbhit())
{
rce.left=rand()%rect.right;
rce.right=rand()%(rect.right-rect.left);
rce.top=rand()%rect.bottom;
rce.bottom=rand()%(rect.bottom-rect.top);
Ellipse(dc,rce.left,rce.top,rce.right,rce.bottom);
Sleep(100);
hnewbrush=GetSysColorBrush(rand()%21);
SelectObject(dc,hnewbrush);
}
SelectObject(dc,holdbrush);
ReleaseDC(hwnd,dc);
system("pause");
return 0;
}
codeblocks提示undefined reference to ellipse,
undefined reference to selectobject
在vs2013中可以编译,但运行时提示错误 展开
#include<conio.h>
int main()
{
HWND hwnd=GetForegroundWindow();
printf("%X\n",hwnd);
RECT rect,rce;
GetWindowRect(hwnd,&rect);
HDC dc=GetDC(hwnd);
HBRUSH holdbrush,hnewbrush;
hnewbrush=GetSysColorBrush(rand()&21);
holdbrush=(HBRUSH)SelectObject(dc,hnewbrush);
while(!kbhit())
{
rce.left=rand()%rect.right;
rce.right=rand()%(rect.right-rect.left);
rce.top=rand()%rect.bottom;
rce.bottom=rand()%(rect.bottom-rect.top);
Ellipse(dc,rce.left,rce.top,rce.right,rce.bottom);
Sleep(100);
hnewbrush=GetSysColorBrush(rand()%21);
SelectObject(dc,hnewbrush);
}
SelectObject(dc,holdbrush);
ReleaseDC(hwnd,dc);
system("pause");
return 0;
}
codeblocks提示undefined reference to ellipse,
undefined reference to selectobject
在vs2013中可以编译,但运行时提示错误 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询