OnDraw中
MoveTo
LineTo
MoveTo
LineTo
解决方案 »
- 使用VC/mfc如何抓取网络数据,我想分析其中的某些数据
- 请问:怎么样使用Excel类型库导出的excel8里面的MenuBars, MenuBar, Menus, Menu, MenuItems, MenuItem等类
- 一个我也不知道是什么问题的问题,各位前辈请进
- 大家在用vc6搭配visual assist6的时候有没有遇到这样的问题?
- 如何在CHTMLVIEW类的ONNEWWINDOWS2的消息响应函数中获取新窗口的URL?
- vc6下GDI+编程问题(在线给分)!!!
- 急:要把数据库中的地址一个个打印到明信片上,该怎么办呢?
- 我在客户区绘图,我想像cad里那样,鼠标放在某个点上就能获得具体的坐标值,求高手赐教啊
- 使用MFC循环写串口时Sleep报错
- 好疑惑,游戏窗口为什么会遮蔽输入法窗口或者说分层窗口?
- 求教:CStdioFile.WriteString时,编译无问题,运行程序后提示磁盘满的错误信息抛出
- OBJ文件的格式?
http://www.truevcl.com
以下程序可以在控制台上画个圆并在中间用渐变色画一条带子.最上面是标准的hello world.
// consoledraw.cpp : Defines the entry point for the console application.
//#include "stdafx.h"
#include <windows.h>
#include <conio.h>HWND GetConsoleHwnd(void);int main(int argc, char* argv[])
{
printf("Hello World!\n");
HWND hwnd=GetConsoleHwnd();
RECT rectcli,rect;
GetClientRect(hwnd,&rectcli);
memcpy(&rect,&rectcli,sizeof(rect));
rect.bottom =10;
OffsetRect(&rect,0,(rectcli.bottom -rectcli.top-10)/2);
HDC hdc=GetDC(hwnd);
for (int i=rect.left;i<rect.right ;i++){
HPEN hpen=CreatePen(PS_SOLID,1,RGB(255-(255*i)/(rect.right -rect.left),0,0));
HPEN hpenOld=(HPEN)SelectObject(hdc,hpen);
MoveToEx(hdc,i,rect.top,NULL);
LineTo(hdc,i,rect.bottom );
SelectObject(hdc,hpenOld);
DeleteObject(hpen);
}
HPEN hpen=CreatePen(PS_SOLID,1,RGB(0,255,0));
HPEN hpenOld=(HPEN)SelectObject(hdc,hpen);
LOGBRUSH lb;
memset(&lb,0,sizeof(lb));
lb.lbStyle =BS_NULL;
HBRUSH hbrush=CreateBrushIndirect(&lb);
HBRUSH hbrOld=(HBRUSH)SelectObject(hdc,hbrush);
Ellipse(hdc,rectcli.left ,rectcli.top,rectcli.right,rectcli.bottom);
SelectObject(hdc,hpenOld);
DeleteObject(hpen);
SelectObject(hdc,hbrOld);
DeleteObject(hbrOld);
ReleaseDC(hwnd,hdc);
getch();
return 0;
}HWND GetConsoleHwnd(void) { #define MY_BUFSIZE 1024 // buffer size for console window titles
HWND hwndFound; // this is what is returned to the caller
char pszNewWindowTitle[MY_BUFSIZE]; // contains fabricated WindowTitle
char pszOldWindowTitle[MY_BUFSIZE]; // contains original WindowTitle // fetch current window title GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE); // format a "unique" NewWindowTitle wsprintf(pszNewWindowTitle,"%d/%d",
GetTickCount(),
GetCurrentProcessId()); // change current window title SetConsoleTitle(pszNewWindowTitle); // ensure window title has been updated Sleep(40); // look for NewWindowTitle hwndFound=FindWindow(NULL, pszNewWindowTitle); // restore original window title SetConsoleTitle(pszOldWindowTitle); return(hwndFound);}
全屏方式,我也不知道怎么办