visual studio下实现图形函数调用

实现功能

1.实现点,线,矩形,三角形,圆形画法;
2.可以对图形的形状进行调整,主要通过其在运行窗口上的坐标来实现;
3.纯虚函数进行实现不同图形的同一接口;

代码实现

graphics.h

#pragma once
#ifdef DLL_IMPLEMENT 
 #define DLL_API __declspec(dllexport) 
#else 
 #define DLL_API __declspec(dllimport) 
#endif 
#include<Windows.h>
/*函数功能:获得控制台窗口句柄*/
HWND DLL_API getConsoleHwnd(void);
/*函数功能:在窗口上用创建的hpen画笔以(cx,cy)为圆心,r为半径画圆*/
void DLL_API circle(HDC, HPEN hpen,int cx, int cy, int r);
/*函数功能:在窗口上用创建的画刷画坐标为(lx,ly)点*/
void DLL_API point(HDC, HBRUSH hbrush,int lx, int ly);
/*函数功能:在窗口上用创建的画笔画出以(sx,sy)作为起点,(ex,ey)作为终点的一条直线*/
void DLL_API line(HDC hdc, HPEN hpen, int sx, int sy, int ex, int ey);
/*函数功能:在窗口上用创建的画笔画出以(left,top)为左上角坐标,(right,bottom)为右下角坐标的矩形*/
void DLL_API rect(HDC hdc, HPEN hpen, int left, int top, int right, int bottom);

graphics.cpp

//#define DLL_IMPLEMENT
#include"Graphics.h"
#define MY_BUFSIZE 100
HWND getConsoleHwnd(void)
{  
    char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated  
  • 2
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值