>_<:there in the MyPaint(...) function respectively use Ellipse(...) draw ellipse, use RoundRect(...) draw rectangle whose angle is round, use Pie(...) draw sector also named fan shap, use Chord(...) draw  arch also named bow shaped.

>_<:the same with previous one, there I don't use message and just put the function of MyPaint(...) in the last of InitInstance(...)

 //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by FE.RC
//
#define IDR_MAINFRAME 128
#define IDD_FE_DIALOG 102
#define IDD_ABOUTBOX 103
#define IDS_APP_TITLE 103
#define IDM_ABOUT 104
#define IDM_EXIT 105
#define IDS_HELLO 106
#define IDI_FE 107
#define IDI_SMALL 108
#define IDC_FE 109
#define IDC_MYICON 2
#define IDC_STATIC -1
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif

resourse.h

 // stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
// #if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_ #if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers // Windows Header Files:
#include <windows.h> // C RunTime Header Files
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h> // Local Header Files // TODO: reference additional headers your program requires here //{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)

StdAfx.h

main.cpp

 #include "stdafx.h"
#include "resourse.h" #define MAX_LOADSTRING 100 // Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
HPEN hPen;
HBRUSH hBru[];
int sBru[]={HS_VERTICAL,HS_HORIZONTAL,HS_CROSS,HS_DIAGCROSS,HS_FDIAGONAL,HS_BDIAGONAL};
// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
void MyPaint(HDC hdc);
//========================================================================================
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg; MyRegisterClass(hInstance);//调用函数向系统注册窗口类别,输入参数hInstance是目前运行程序的对象代码; // 调用InitInstance函数,进行初始化操作;
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
} // 消息循环(通过消息循环来获取信息,
//进行必要的键盘信息转换而后将控制权交给操作系统,
//有操作系统决定哪个程序的消息处理函数处理消息
while (GetMessage(&msg, NULL, , )) //获取程序消息
{
TranslateMessage(&msg);//转换伪码及字符
DispatchMessage(&msg);//将控制权交给系统,再有系统决定负责处理消息的程序;
} return msg.wParam;
}
//===================================================================================== //=============================================================================================
//在建立程序窗口实体之前,必须先定义一个窗口类别,其中包含所要建立窗口的信息,
//并向系统注册,这里的MyRegisterClass函数就是进行定义及注册窗口类别的函数。
//==============================================================================================
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex; //申请一个窗口类别“WNDCLASSEX”和结构”wcex“
//--------------------------------------------------------------
//定义vcex结构的各项信息,其中设定信息处理函数(lpfnWndProc)
//为WNDPROC,类别名称为(lpszClassName)为”fe";
//--------------------------------------------------------------
wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = ;
wcex.cbWndExtra = ;
wcex.hInstance = hInstance;
wcex.hIcon = NULL;
wcex.hCursor = NULL;
wcex.hCursor = LoadCursor(NULL,IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "fe";
wcex.hIconSm = NULL; return RegisterClassEx(&wcex);//调用RegisterClassEx函数注册类别,返回一个“ATOM"形态的字符串
//此字符串即为类别名称”fe";
}
//============================================================================================ //============================================================================================
//按照前面所定义的窗口类别来建立并显示实际的程序窗口
//============================================================================================
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
HDC hdc;
int i;
hInst = hInstance; // 把instance handle 储存在全局变量中; hWnd = CreateWindow("fe","绘图窗口",WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, , CW_USEDEFAULT, , NULL, NULL, hInstance, NULL);
//-----------------------------------------------
//调用CreateWindow函数来建立一个窗口对象
//第一个参数就是窗口建立依据的类别名称
//-----------------------------------------------
if (!hWnd)
{
return FALSE;
}
//------------------------------------------------
//设定窗口的位置及窗口的大小,然后绘制显示在设备上
//-------------------------------------------------
MoveWindow(hWnd,,,,,true);//位置及大小
ShowWindow(hWnd, nCmdShow);//改定窗口显示时的状态
UpdateWindow(hWnd);//将窗口绘制在显示设备上 hPen=CreatePen(PS_SOLID,,RGB(,,));
for(i=;i<=;i++)
{
hBru[i]=CreateHatchBrush(sBru[i],RGB(,,));
} hdc=GetDC(hWnd);
MyPaint(hdc);
ReleaseDC(hWnd,hdc); return TRUE;
}
//============================================================================================ //============================================================================================
void MyPaint(HDC hdc)
{
SelectObject(hdc,hPen); SelectObject(hdc,hBru[]);
Ellipse(hdc,,,,);
TextOut(hdc,,,"椭圆形",strlen("椭圆形")); SelectObject(hdc,hBru[]);
RoundRect(hdc,,,,,,);
TextOut(hdc,,,"圆角矩形",strlen("圆角矩形")); SelectObject(hdc,hBru[]);
Pie(hdc,,,,,,,,);
TextOut(hdc,,,"扇形",strlen("扇形")); SelectObject(hdc,hBru[]);
Chord(hdc,,,,,,,,);
TextOut(hdc,,,"弓形",strlen("弓形"));
} //============================================================================================
//在前面定义类别的时候把WndProc定义为消息处理函数(当某些外部消息发生时,会按消息的类型
//来决定该如何进行处理。此外该函数也是一个回叫函数(CALLBACK)(windows系统函数)每一个
//程序都会接收信息,选择性接受、处理;
//============================================================================================
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc; switch (message) //判断消息类型
{
case WM_PAINT: //窗口重绘制
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY: //处理窗口结束消息
PostQuitMessage();
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return ;
}
//============================================================================================

[游戏模版6] Win32 graph的更多相关文章

  1. [游戏模版2] Win32最小框架

    >_<:Just the minimum Win32  frame don't have any other special function. //{{NO_DEPENDENCIES}} ...

  2. [游戏模版18] Win32 五子棋

    >_<:Learning its AI logic. >_<:resource >_<:code: #include <windows.h> // C ...

  3. [游戏模版3] Win32 画笔 画刷 图形

    >_<:introduce the functions of define\create\use pen and brush to draw all kinds of line and s ...

  4. [游戏模版4] Win32 显示鼠标位置

    >_<:use MOUSE_MOVE message refresh the position information. >_<:use LOWORD(lParam) get ...

  5. [游戏模版5] Win32 折线 弧线

    >_<:first build some points put in poly1[],poly2[] and poly3[] in the function of InitInstance ...

  6. [游戏模版7] Win32 最简单贴图

    >_<:this is the first using mapping. >_<:There will be introducing how to do: First load ...

  7. [游戏模版8] Win32 透明贴图

    >_<:The same with previous introduction. In the InitInstance fanction make a little change: &g ...

  8. [游戏模版9] Win32 半透明 图像处理

    >_<:Previous part we talk about how to map a transparent picture, and this time we will solve ...

  9. [游戏模版10] Win32 平面地图贴图 正

    >_<:picture resource >_<:If you master the ways of mapping picture,then this problem is ...

随机推荐

  1. 8.4 H5知识点总结

    HTML简介 HyperText Markup Language 简称为HTML HyperText: 超文本 (文本 + 图片 + 视频 + 音频 + 链接) Markup Language: 标记 ...

  2. .net正则表达式

    1. "^-?[1-9]\\d*$",//整数 2. "^[1-9]\\d*$", //正整数 3. intege2:"^-[1-9]\\d*$&qu ...

  3. 构建ASP.NET网站十大必备工具(1)

    最近使用ASP.NET为公司构建了一个简单的公共网站(该网站的地址:http://superexpert.com/).在这个过程中,我们使用了数量很多的免费工具,如果把构建ASP.NET网站的必备工具 ...

  4. Decorator(装饰)-对象结构型模式

    1.意图 动态地给一个对象添加一些额外的职责.就增加功能来说,Decorator模式相比生成子类更为灵活. 2.别名 包装器 Wrapper. 3.动机 给某个对象而不是整个类添加一些功能.一个较为灵 ...

  5. 开源PLM软件Aras详解二 汉化以及界面

    Aras安装完毕之后,默认语言为英语,对于国内很多制造业并不适用,那么下面就来说说如何汉化 首先下载汉化包:zh-cn_languagepack-110v3.zip 步骤如下: 步骤1- 设定安装程序 ...

  6. MySQL中如何插入反斜杠,反斜杠被吃掉,反斜杠转义

    问题描述:mysql中带有反斜杠的内容入库后,发现反斜杠无故失踪了(俗话说被吃掉了) 例:插入insert into tb('url') values('absc\eeee'); 结果数据库里的内容是 ...

  7. 简单的jquery插件写法之一

    http://jsfiddle.net/kyu0hdmx/embedded/#HTML

  8. SVN服务器安装

    CentOS 6.5 SVN搭建 (YUM安装)   参考文献:http://www.linuxidc.com/Linux/2013-10/91903.htm 安装说明 安装了一下SVN服务器,过程如 ...

  9. python-->基础-->003->字符串处理

    一.去除字符串首尾白空格 说明:即为去除字符串的首尾(即头部和尾部)的白空格(空格本身,回车\r,换行\n,制表符\t, 换页符\f ) 实例: str01 = ' abc def # ' print ...

  10. svc6 控制台程序利用SoapToolkit3.0调用WebService

    1. 首先要安装SoapToolkit3.0安装包并安装(我的安装目录为:C:\Program Files\Common Files) 2. 新建vc控制台程序(空项目),项目名称:WinConsol ...