硬汉嵌入式论坛

 找回密码
 立即注册
查看: 2393|回复: 3
收起左侧

[emWin] 使用VS2013在对话框WM_Pait事件中绘制矩形框不显示

[复制链接]

13

主题

40

回帖

79

积分

初级会员

积分
79
发表于 2019-3-29 22:22:03 | 显示全部楼层 |阅读模式
代码如下,填充的矩形不显示,但是可以显示字符。这是为什么呀

case WM_PAINT:
  {
          GUI_SetColor(GUI_RED);
          GUI_FillRect(50, 170, 50, 50);

          GUI_SetFont(GUI_FONT_24_ASCII);
          if (flag == 0)
          {
                  GUI_SetColor(GUI_RED);
                  GUI_FillRect(50, 170, 50, 50);
          }
          else
          {
                  GUI_SetColor(GUI_GREEN);
                  GUI_FillRect(50, 170, 50, 50);
          }
          GUI_DispCharAt(text_val2, 30, 170);
          
  }break;

Image 1.png
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
115778
QQ
发表于 2019-3-30 03:13:22 | 显示全部楼层
把你的稍完整测试代码发出来,我试试。
回复

使用道具 举报

13

主题

40

回帖

79

积分

初级会员

积分
79
 楼主| 发表于 2019-3-30 08:47:14 | 显示全部楼层
eric2013 发表于 2019-3-30 03:13
把你的稍完整测试代码发出来,我试试。

#include "GUI.h"

/*********************************************************************
*                                                                    *
*                SEGGER Microcontroller GmbH & Co. KG                *
*        Solutions for real time microcontroller applications        *
*                                                                    *
**********************************************************************
*                                                                    *
* C-file generated by:                                               *
*                                                                    *
*        GUI_Builder for emWin version 5.36                          *
*        Compiled Aug 31 2016, 10:53:09                              *
*        (c) 2016 Segger Microcontroller GmbH & Co. KG               *
*                                                                    *
**********************************************************************
*                                                                    *
*        Internet: www.segger.com  Support: support@segger.com       *
*                                                                    *
**********************************************************************
*/

// USER START (Optionally insert additional includes)
// USER END

#include "DIALOG.h"
#include "string.h"
#include "keyboard.h"
WM_HWIN hwinOld;
WM_HWIN CreateFramewin(void);
/*********************************************************************
*
*       Defines
*
**********************************************************************
*/
WM_HWIN focus_hItem;

#define ID_FRAMEWIN_0  (GUI_ID_USER + 0x00)
#define ID_BUTTON_0  (GUI_ID_USER + 0x01)
#define ID_BUTTON_1  (GUI_ID_USER + 0x02)
#define ID_EDIT_0  (GUI_ID_USER + 0x03)

// USER START (Optionally insert additional defines)
// USER END

/*********************************************************************
*
*       Static data
*
**********************************************************************
*/

// USER START (Optionally insert additional static data)
// USER END

/*********************************************************************
*
*       _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
                { FRAMEWIN_CreateIndirect, "ygrong_test", ID_FRAMEWIN_0, 0, 0, 320, 480, 0, 0x0, 0 },
                { BUTTON_CreateIndirect, "OK", ID_BUTTON_0, 43, 370, 80, 20, 0, 0x0, 0 },
                { BUTTON_CreateIndirect, "cancel", ID_BUTTON_1, 179, 370, 80, 20, 0, 0x0, 0 },
                { EDIT_CreateIndirect, "Edit", ID_EDIT_0, 55, 235, 198, 20, 0, 0x64, 0 },
                // USER START (Optionally insert additional widgets)
                // USER END
};

/*********************************************************************
*
*       Static code
*
**********************************************************************
*/

// USER START (Optionally insert additional static code)
// USER END

/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
        unsigned char buff[50];
        WM_HWIN hwinOld;
        int NCode;
        int Id;
        // USER START (Optionally insert additional variables)
        // USER END
       
        switch (pMsg->MsgId) {
        case WM_PAINT:
                //hwinOld = WM_SelectWindow((pMsg->hWin));

                GUI_DrawGradientRoundedH(35, 100, 60, 20, 5, 0XFF, 0XFFFF);
                //WM_SelectWindow(hwinOld);
                break;
        case WM_INIT_DIALOG:
                //
                // Initialization of 'Edit'
                //
                focus_hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
                EDIT_SetTextAlign(focus_hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
                // USER START (Optionally insert additional code for further widget initialization)
                // USER END
                break;
        case WM_NOTIFY_PARENT:
                Id = WM_GetId(pMsg->hWinSrc);
                NCode = pMsg->Data.v;
                switch (Id) {
                case ID_BUTTON_0: // Notifications sent by 'OK'
                        switch (NCode) {
                        case WM_NOTIFICATION_CLICKED:
                                // USER START (Optionally insert code for reacting on notification message)
                                // USER END
                                break;
                        case WM_NOTIFICATION_RELEASED:                               
                                break;
                                // USER START (Optionally insert additional code for further notification handling)
                                // USER END
                        }
                        break;
                case ID_BUTTON_1: // Notifications sent by 'cancel'
                        switch (NCode) {
                        case WM_NOTIFICATION_CLICKED:
                                // USER START (Optionally insert code for reacting on notification message)
                                // USER END
                                break;
                        case WM_NOTIFICATION_RELEASED:
                                // USER START (Optionally insert code for reacting on notification message)
                               
                                // USER END
                                break;
                                // USER START (Optionally insert additional code for further notification handling)
                                // USER END
                        }
                        break;
                case ID_EDIT_0: // Notifications sent by 'cancel'
                        switch (NCode) {
                        case WM_NOTIFICATION_LOST_FOCUS:
                                // USER START (Optionally insert code for reacting on notification message)
                                memset(buff, 0, sizeof(buff));
                                // USER END
                                break;

                        case WM_NOTIFICATION_CLICKED:
                                // USER START (Optionally insert code for reacting on notification message)
                                // USER END
                                break;
                        case WM_NOTIFICATION_RELEASED:
                                // USER START (Optionally insert code for reacting on notification message)
                                CreateFramewin();
                                WM_SetFocus(WM_GetDialogItem(pMsg->hWin,ID_EDIT_0));
                                // USER END
                                break;
                                // USER START (Optionally insert additional code for further notification handling)
                                // USER END
                        }
                        break;
                        // USER START (Optionally insert additional code for further Ids)
                        // USER END
                }
                break;
                // USER START (Optionally insert additional message handling)
                // USER END
        default:
                WM_DefaultProc(pMsg);
                break;
        }
}

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       Createygrong_test
*/
WM_HWIN Createygrong_test(void);
WM_HWIN Createygrong_test(void) {
        WM_HWIN hWin;

        hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
        GUI_Exec();
        hwinOld = WM_SelectWindow(WM_GetClientWindow(hWin));
        GUI_DrawGradientRoundedH(35, 100, 60, 20, 5, 0XFF, 0XFFFF);
        WM_SelectWindow(hWin);

        return hWin;
}

// USER START (Optionally insert additional public code)
// USER END

/*************************** End of file ****************************/

/*********************************************************************
*
*       MainTask
*/
void MainTask(void)
{
        GUI_Init();
        //CreateFramewin();
        Createygrong_test();
        while (1)
        {
               
                GUI_Delay(10);
        }
}
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
115778
QQ
发表于 2019-3-30 10:06:43 | 显示全部楼层
ygrong_2008 发表于 2019-3-30 08:47
#include "GUI.h"

/*********************************************************************

是不是贴错代码了,你一楼的WM_PAINT内容在3楼代码的什么地方。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-5-18 05:53 , Processed in 0.248976 second(s), 27 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表