惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
S
Securelist
MyScale Blog
MyScale Blog
Jina AI
Jina AI
罗磊的独立博客
The Cloudflare Blog
美团技术团队
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
雷峰网
雷峰网
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
大猫的无限游戏
大猫的无限游戏
博客园 - Franky
博客园 - 聂微东
Y
Y Combinator Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
T
Tailwind CSS Blog
Attack and Defense Labs
Attack and Defense Labs
博客园_首页
Latest news
Latest news
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Hacker News
The Hacker News
G
GRAHAM CLULEY
Simon Willison's Weblog
Simon Willison's Weblog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
U
Unit 42
D
Docker
Webroot Blog
Webroot Blog
N
Netflix TechBlog - Medium
T
Tor Project blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
B
Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
Security Latest
Security Latest
V2EX - 技术
V2EX - 技术
N
News | PayPal Newsroom
Microsoft Security Blog
Microsoft Security Blog

博客园 - Clingingboy

冒个泡,刷刷存在感 使用文件映射和信号量来进程间通信 Xperf Basics: Recording a Trace (the easy way)(转) Xperf Basics: Recording a Trace(转) Xperf Analysis Basics(转) Android相关sdk使用 Uniscribe文字自动换行 Chrome RenderText分析(2) c++智能指针 codepage IMLangCodePages GUI 快捷键的实现思路 Menu实现逻辑 2个函数宏技巧 绘图 Painter转接口封装的方式 DirectUI消息循环的简单封装 c++以代理的方式来实现接口化编程 c++对象工厂 使用模板来解决接口继承问题 VC++ 使用attributes定义接口
控件保持多种绘图状态的做法
Clingingboy · 2013-11-21 · via 博客园 - Clingingboy

控件保持多种绘图状态的做法

2013-11-21 15:03  Clingingboy  阅读(357)  评论()    收藏  举报

基本思路

#pragma once
#include <map>

struct IPainter
{
    void Paint() {}
};

class Element
{
    void SetPainterState(int dwState, IPainter* pPainter)
    {
        m_mapStatePainter[dwState]=pPainter;

        if(dwState==m_dwState)
        {
            GoToState(dwState);
        }
    }

    IPainter* GetPainterState(int dwState)
    {
        return m_mapStatePainter[m_dwState];
    }

    int GetState()
    {
        return m_dwState;
    }

    void GoToState(int dwState)
    {
        m_dwState=dwState;

        //InvalidateRect();
    }

    void Paint() 
    {
        m_mapStatePainter[m_dwState]->Paint();
    }

private:
    int        m_dwState;
    std::map<int,IPainter*>     m_mapStatePainter;
};