| 网站首页 | 业界新闻 | 群组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 编程论坛
共有 750 人关注过本帖
标题:又见win32。画图出现的诡异现象
只看楼主 加入收藏
man94ht
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2017-5-7
结帖率:100%
  问题点数:0  回复次数:1   
又见win32。画图出现的诡异现象
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int wmId, wmEvent;
    PAINTSTRUCT ps;
    HDC hdc;

    switch (message)
    {
    case WM_COMMAND:
        wmId    = LOWORD(wParam);
        wmEvent = HIWORD(wParam);

        // 分析菜单选择:
        switch (wmId)
        {
        case DROP_DOWN_LIST:
        {
            .......省略
            if (idx >= 0)
            {
                ZeroMemory(g_szMessage, sizeof(g_szMessage));
                SendMessage(drop_down_list, CB_GETLBTEXT, idx, (WPARAM)g_szMessage);    //获取第点击项的数据
                //宽字符转换
                wcs2mbs(g_szMessage, g_chResult);        
                if (strcmp(g_chResult, "圆") == 0)
                {
                    g_Temp = 0;
                }
                SendMessage(hWnd, WM_PAINT, 0, 0);
            }        
            break;
        }
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        break;
    case WM_PAINT:
    {
        hdc = BeginPaint(hWnd, &ps);
        // TODO:  在此添加任意绘图代码...
        HPEN pen1 = CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
        HPEN pen2 = CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
        SelectObject(hdc, pen1);
        SelectObject(hdc, pen2);

                //如果我用if条件。   但我用combobox点击“圆”这个选项。画不出来圆,但是如果我移动屏幕。使窗口不断重绘,圆会慢慢画出来。
        if (g_Temp == 0)
        {
            circle(hdc, LPPOINT(pen1), LPPOINT(pen2));//画圆
        }
               
                //但是如果我把这个函数不用if。会画出一个圆。并不需要像上述那样。
                circle(hdc, LPPOINT(pen1), LPPOINT(pen2));//画圆
               
        DeleteObject(pen1);
        DeleteObject(pen2);
        EndPaint(hWnd, &ps);
        break;
    }
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}


好吧,我啥也不会。只是求解。这不好百度,所以发论坛。求知道的人提点下。感激不尽
2017-07-26 18:13
yangfrancis
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:134
帖 子:1493
专家分:7546
注 册:2014-5-19
  得分:0 
combobox里面点击圆不会响应WM_PAINT消息的,但移动窗体会响应
2017-08-01 17:59







关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033384 second(s), 8 queries.
Copyright©2004-2018, BCCN.NET, All Rights Reserved