Code Monkey home page Code Monkey logo

drawing's Introduction

drawing

环境配置

参考 Visual Studio 2019 配置汇编和masm32教程-CSDN博客

开发工具

  • Visual Studio Community 2022
  • MASM32
  • Win32 API

项目配置

  • 新建空项目

  • 右键选中项目名称->生成依赖项->生成自定义->勾选masm

  • 新建一个源文件,命名为*.asm (该步骤必须)

  • 项目属性->链接器->常规->附加库目录->添加~/masm32/lib,我这里是C:\DevTools\masm32\lib

  • 项目属性->Microsoft Macro Assembler->General->Include paths->添加~/masm32/include,我这里是C:\DevTools\masm32\include

  • 将项目配置为 'Debug/Release' 构建模式和 'X86' 目标平台

项目结构

header.inc 头文件,声明函数,定义全局常量

main.asm 程序入口,创建窗口

menu.asm 菜单相关,创建菜单,菜单项响应处理函数

paint.asm 绘制相关,橡皮擦函数、自由绘制函数等

winproc.asm 窗口消息处理,如VM_COMMAND

Window

Win32桌面应用的开发过程就是,创建窗口,循环处理事件消息(鼠标、键盘)

GDI

绘图最重要的一个结构体是PAINTSTRUCT

它有一个成员变量HDC hdc存储了绘制设备相关属性,比如画笔属性

所有绘图操作都在BeginPaintEndPaint两个函数之间完成

以画笔Pen为例,设置画笔属性有三种方式:

可参考设置笔或画笔颜色 - Win32 apps | Microsoft Learn

  • SetDCPenColor直接修改当前的HDC.PEN的属性

  • GetStockObject或者CreatePen返回一个全新Pen,然后通过SelectObject设置一个新的Pen

关于画笔的样式,可查看CreatePen的API,参数iStyle可设置为实线、虚线等

成员分工

...

参考

绘画和绘图 - Win32 apps | Microsoft Learn

使用 Win32 API 生成桌面 Windows 应用 - Win32 apps | Microsoft Learn

drawing's People

Contributors

pzr21 avatar grinffin avatar geh2001 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.