谁能帮我用c解决这个问题(采纳追加)

来源:百度知道 编辑:UC知道 时间:2024/06/05 08:56:40
具体要求:(用vc实现)鼠标在屏幕上取点,取第二个点时,与第一个点用直线连接,第三个点与第二个点用直线连接。。。直至回车键结束。最后那个点与第一个点连接。然后,在这个封闭的图形中用斜阴影线填充。
如果有源代码最好,若能提供相关网页或者指导,同样感激万分。
在此先谢了。

应该是用Win32 API吧
工程类型选Win32 Application,然后选一个空的Win32项目,再新建一个cpp,把下面的代码复制进去编译就行了

#include <windows.h>
#include <stdlib.h>
#include <string.h>

LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
BOOL InitWindowClass(HINSTANCE);
BOOL InitWindow(HINSTANCE,int);
char szAppName[]="test";
char szAppTitle[]="test";

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) {
if(!InitWindowClass(hInstance))
return false;
if(!InitWindow(hInstance,nCmdShow))
return false;
MSG msg;
while(GetMessage(&msg,NULL,0,0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) {
HDC hdc;
HBRUSH hb;
PAINTSTRUCT ps;
static POINT pt[100];
static int i=0;
int j;