怎么用vc画直线
请问各位大虾,怎么用vc做画直线呢?是用mfc吗?算法我知道,就是不知道怎么用c语言实现。c里面用setpixel命令需要加什么头文件吗?[ 本帖最后由 peace1221 于 2011-1-14 11:34 编辑 ]
#include <windows.h> #include <conio.h> int main (void) { HWND hWnd; HDC hDC; HPEN hPen; RECT rect; hWnd = GetForegroundWindow (); hDC = GetDC (hWnd); hPen = CreatePen (PS_SOLID, 1, RGB (255, 0, 0)); SelectObject (hDC, hPen); GetClientRect (hWnd, &rect); LineTo (hDC, rect.right, rect.bottom); MoveToEx (hDC, 0, rect.bottom, NULL); LineTo (hDC, rect.right, 0); getch (); DeleteObject (hPen); ReleaseDC (hWnd, hDC); return 0; }