Git Product home page Git Product logo

windows-ui's Issues

基于windows gdi+的常用自绘控件

1:通过对UI(CDialog(CWnd) -> CButton(CImageButton) -> CRaidoButton -> CCheckButton -> CSpinButton -> CComboBox -> CStatic)等的重绘,实现MFC常用控件的自定义。

windows-ui 使用流程

  • 1.拷贝所有ui文件夹中对应.h .cpp至对应的代码文件所在目录。如下:

1
并在vs中将.h .cpp添加至工程
image
如果vs提示未包含pch.h,将全部stdafx.h替换成pch.h(vs版本导致预编译头名字不同)。
提示某些cpp文件不明错误的点出菜单[高级保存选项]修改格式:
image

  • 2.修改对话框继承父类

将原先对话框继承的父类CDialogEx替换成COwnerDrawWindowDlg
[注意:对话框.cpp中的全部基于CDialogEx的调用过程也需要替换至COwnerDrawWindowDlg,且此时应当将ui中的img文件夹拷贝至程序当前所在目录
image
,否则没有对应的绘图效果];

image

COwnerDrawWindowDlg中OnInitDialog对gdi+进行了初始化,其他地方无需初始化,若工程没有任何对象继承至此,则需要寻找合适地方初始化gdi+,参考 #1 问题解决方案;

  • 3.添加自定义控件(此处以checkbox为例)

1 为控件添加变量

image
image

2 修改其所绑定变量类型

将原有的CCheckBox类型替换至COwnerDrawCheckButton,在此处须先包含OwnerDrawCheckButton.h

image

  • 4.其他控件类似3中的添加方式

效果如下
微信截图_20200616222744

关于开源协议

因为想用来美化一下公司MFC软件,所以问一下开源协议。是属于作者免责,使用随意?

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.