硬汉嵌入式论坛

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

[emWin] 求助!求助!enwin的控件英文显示不全,怎么解决?

[复制链接]

2

主题

10

回帖

16

积分

新手上路

积分
16
发表于 2024-9-19 16:05:15 | 显示全部楼层 |阅读模式
BUTTON控件应该显示“Button1”“Button2”“Button3”“Button4”“Button5”“Button6”“Button7”“Button8

显示效果

显示效果
回复

使用道具 举报

2

主题

10

回帖

16

积分

新手上路

积分
16
 楼主| 发表于 2024-9-19 16:06:30 | 显示全部楼层
static const GUI_WIDGET_CREATE_INFO _aDialogCreate1[] = {
  { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 480, 272, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button1", ID_BUTTON_0, 18, 87, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button2", ID_BUTTON_1, 130, 87, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button3", ID_BUTTON_2, 245, 87, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button4", ID_BUTTON_3, 361, 87, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button5", ID_BUTTON_4, 18, 161, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button6", ID_BUTTON_5, 130, 161, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button7", ID_BUTTON_6, 245, 161, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button8", ID_BUTTON_7, 361, 161, 88, 44, 0, 0x0, 0 },
  { EDIT_CreateIndirect, "Edit", ID_EDIT_0, 48, 239, 80, 26, 0, 0x64, 0 },
  { TEXT_CreateIndirect, "Text", ID_TEXT_0, 370, 2, 112, 20, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "Text", ID_TEXT_1, 368, 24, 112, 20, 0, 0x0, 0 },
  { EDIT_CreateIndirect, "Edit", ID_EDIT_1, 348, 239, 80, 26, 0, 0x64, 0 },
  { TEXT_CreateIndirect, "Frt", ID_TEXT_2, 109, 1, 237, 20, 0, 0x0, 0 },
  // USER START (Optionally insert additional widgets)
  // USER END
};

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


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

/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog1(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int     NCode;
  int     Id;
  char    buf[20];
  RTC_TimeTypeDef RTC_TimeStruct;
  RTC_DateTypeDef RTC_DateStruct;//                        //显示日期

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

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'Edit'
    //
GUI_SetFont(GUI_FONT_8X18);
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
    EDIT_SetText(hItem, "12345678");
    //
    // Initialization of 'Edit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1);
    EDIT_SetText(hItem, "123456.78");
       

    //
    // Initialization of 'Frist'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
    TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
    TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    // USER START (Optionally insert additional code for further widget initialization)
    // USER END

    break;


    /* 定时器消息 */
  case WM_TIMER:   //--------------(1)

                //显示日期
                HAL_RTC_GetDate(&hrtc,&RTC_DateStruct,RTC_FORMAT_BIN);//获取日期
                sprintf((char*)buf,"20%02d-%02d-%02d",RTC_DateStruct.Year,RTC_DateStruct.Month,RTC_DateStruct.Date);
                TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_0), (const char*)buf);               
                //显示时间
                HAL_RTC_GetTime(&hrtc,&RTC_TimeStruct,RTC_FORMAT_BIN);//获取时间
                sprintf((char*)buf,"%02d:%02d:%02d",RTC_TimeStruct.Hours,RTC_TimeStruct.Minutes,RTC_TimeStruct.Seconds);        
                TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_1), (const char*)buf);

                WM_RestartTimer(pMsg->Data.v, 1000);
                break;
       
         case WM_KEY:
                switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key)
                {
                        case GUI_KEY_ESCAPE:
                                        GUI_EndDialog(pMsg->hWin, 1);
                                        break;
                        case GUI_KEY_TAB:
                                 WM_SetFocusOnNextChild(pMsg->hWin);
                                 break;
                }
                break;

  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case ID_BUTTON_0: // Notifications sent by 'Button1'
      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
          GUI_EndDialog(pMsg->hWin, 0);
          CreateSECOND();
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_1: // Notifications sent by 'Button2'
      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_BUTTON_2: // Notifications sent by 'Button3'
      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_BUTTON_3: // Notifications sent by 'Button4'
      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_BUTTON_4: // Notifications sent by 'Button5'
      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_BUTTON_5: // Notifications sent by 'Button6'
      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_BUTTON_6: // Notifications sent by 'Button7'
      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_BUTTON_7: // Notifications sent by 'Button8'
      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 'Edit'
      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;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // 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_1: // Notifications sent by 'Edit'
      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;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // 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;
    // 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
*
**********************************************************************
*/
/*********************************************************************
*
*       CreateWindow
*/

WM_HWIN CreateWindow(void) {
  WM_HWIN hWin;
  WM_HTIMER hTimer;
  hWin = GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), _cbDialog1, WM_HBKWIN, 0, 0);
        WM_SetFocus(hWin);
  /* 给对话框hDlg创建定时器,溢出时间是100ms */
  hTimer = WM_CreateTimer(hWin, 0, 1000, 0); //--------------(2)

  return hWin;
}

void MainTask1(void)
{
    /* 初始化 */
    //GUI_Init();
   
    /* 窗口自动使用存储设备 */
    WM_SetCreateFlags(WM_CF_MEMDEV);

//    /* 创建对话框,使用GUIBulder生成的对话框创建函数 */
//          GUI_SetFont(GUI_FONT_8X18);
//                GUI_DispStringAt("Frist",0,0);
//                GUI_DispStringAt("Button1",0,32);          
    CreateWindow();


    while (1)
    {
        GUI_Delay(100);
    }
}
回复

使用道具 举报

2

主题

10

回帖

16

积分

新手上路

积分
16
 楼主| 发表于 2024-9-19 16:26:57 | 显示全部楼层
右上角的日期也显示错误,应该是“2015-12-08”
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117535
QQ
发表于 2024-9-20 09:31:24 | 显示全部楼层
shuangrenyu 发表于 2024-9-19 16:26
右上角的日期也显示错误,应该是“2015-12-08”

调用下按钮字体设置API,看楼主的代码里面貌似没有设置。
回复

使用道具 举报

2

主题

10

回帖

16

积分

新手上路

积分
16
 楼主| 发表于 2024-9-20 10:49:32 | 显示全部楼层
eric2013 发表于 2024-9-20 09:31
调用下按钮字体设置API,看楼主的代码里面貌似没有设置。

您好,我在GUI_X_Config()里已经调用了GUI_SetDefaultFont(GUI_FONT_6X8)
回复

使用道具 举报

2

主题

10

回帖

16

积分

新手上路

积分
16
 楼主| 发表于 2024-9-20 11:29:48 | 显示全部楼层
eric2013 发表于 2024-9-20 09:31
调用下按钮字体设置API,看楼主的代码里面貌似没有设置。

并且用FontCvt V5.28生成了一套字体也是也没有用
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2);       
    BUTTON_SetFont(hItem,&GUI_FontFontSong24);  
    BUTTON_SetText(hItem, "Button8");
按钮上显示的是Buttnn
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117535
QQ
发表于 2024-9-21 09:58:38 | 显示全部楼层
shuangrenyu 发表于 2024-9-20 11:29
并且用FontCvt V5.28生成了一套字体也是也没有用
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_ ...

有可以在模拟器上直接测试运行的完全代码没,我测试下
回复

使用道具 举报

2

主题

10

回帖

16

积分

新手上路

积分
16
 楼主| 发表于 2024-9-24 11:03:46 | 显示全部楼层
eric2013 发表于 2024-9-21 09:58
有可以在模拟器上直接测试运行的完全代码没,我测试下


static const GUI_WIDGET_CREATE_INFO _aDialogCreate1[] = {
  { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 480, 272, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button1", ID_BUTTON_0, 18, 87, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button2", ID_BUTTON_1, 130, 87, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button3", ID_BUTTON_2, 245, 87, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button4", ID_BUTTON_3, 361, 87, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button5", ID_BUTTON_4, 18, 161, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button6", ID_BUTTON_5, 130, 161, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button7", ID_BUTTON_6, 245, 161, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button8", ID_BUTTON_7, 361, 161, 88, 44, 0, 0x0, 0 },
  { EDIT_CreateIndirect, "Edit", ID_EDIT_0, 48, 239, 80, 26, 0, 0x64, 0 },
  { TEXT_CreateIndirect, "Text", ID_TEXT_0, 370, 2, 112, 20, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "Text", ID_TEXT_1, 368, 24, 112, 20, 0, 0x0, 0 },
  { EDIT_CreateIndirect, "Edit", ID_EDIT_1, 348, 239, 80, 26, 0, 0x64, 0 },
  { TEXT_CreateIndirect, "Frt", ID_TEXT_2, 109, 1, 237, 20, 0, 0x0, 0 },
  // USER START (Optionally insert additional widgets)
  // USER END
};

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


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

/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog1(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int     NCode;
  int     Id;
  char    buf[20];
  RTC_TimeTypeDef RTC_TimeStruct;
  RTC_DateTypeDef RTC_DateStruct;//                        //显示日期

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

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'Edit'
    //
GUI_SetFont(GUI_FONT_8X18);
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
    EDIT_SetText(hItem, "12345678");
    //
    // Initialization of 'Edit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1);
    EDIT_SetText(hItem, "123456.78");
      

    //
    // Initialization of 'Frist'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
    TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
    TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    // USER START (Optionally insert additional code for further widget initialization)
    // USER END

    break;


    /* 定时器消息 */
  case WM_TIMER:   //--------------(1)

                //显示日期
                HAL_RTC_GetDate(&hrtc,&RTC_DateStruct,RTC_FORMAT_BIN);//获取日期
                sprintf((char*)buf,"20%02d-%02d-%02d",RTC_DateStruct.Year,RTC_DateStruct.Month,RTC_DateStruct.Date);
                TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_0), (const char*)buf);               
                //显示时间
                HAL_RTC_GetTime(&hrtc,&RTC_TimeStruct,RTC_FORMAT_BIN);//获取时间
                sprintf((char*)buf,"%02d:%02d:%02d",RTC_TimeStruct.Hours,RTC_TimeStruct.Minutes,RTC_TimeStruct.Seconds);        
                TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_1), (const char*)buf);

                WM_RestartTimer(pMsg->Data.v, 1000);
                break;
      
         case WM_KEY:
                switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key)
                {
                        case GUI_KEY_ESCAPE:
                                        GUI_EndDialog(pMsg->hWin, 1);
                                        break;
                        case GUI_KEY_TAB:
                                 WM_SetFocusOnNextChild(pMsg->hWin);
                                 break;
                }
                break;

  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case ID_BUTTON_0: // Notifications sent by 'Button1'
      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
          GUI_EndDialog(pMsg->hWin, 0);
          CreateSECOND();
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_1: // Notifications sent by 'Button2'
      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_BUTTON_2: // Notifications sent by 'Button3'
      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_BUTTON_3: // Notifications sent by 'Button4'
      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_BUTTON_4: // Notifications sent by 'Button5'
      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_BUTTON_5: // Notifications sent by 'Button6'
      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_BUTTON_6: // Notifications sent by 'Button7'
      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_BUTTON_7: // Notifications sent by 'Button8'
      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 'Edit'
      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;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // 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_1: // Notifications sent by 'Edit'
      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;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // 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;
    // 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
*
**********************************************************************
*/
/*********************************************************************
*
*       CreateWindow
*/

WM_HWIN CreateWindow(void) {
  WM_HWIN hWin;
  WM_HTIMER hTimer;
  hWin = GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), _cbDialog1, WM_HBKWIN, 0, 0);
        WM_SetFocus(hWin);
  /* 给对话框hDlg创建定时器,溢出时间是100ms */
  hTimer = WM_CreateTimer(hWin, 0, 1000, 0); //--------------(2)

  return hWin;
}

void MainTask1(void)
{
    /* 初始化 */
    //GUI_Init();
   
    /* 窗口自动使用存储设备 */
    WM_SetCreateFlags(WM_CF_MEMDEV);

//    /* 创建对话框,使用GUIBulder生成的对话框创建函数 */
//          GUI_SetFont(GUI_FONT_8X18);
//                GUI_DispStringAt("Frist",0,0);
//                GUI_DispStringAt("Button1",0,32);         
    CreateWindow();


    while (1)
    {
        GUI_Delay(100);
    }
}
回复

使用道具 举报

2

主题

10

回帖

16

积分

新手上路

积分
16
 楼主| 发表于 2024-9-24 11:05:47 | 显示全部楼层
eric2013 发表于 2024-9-21 09:58
有可以在模拟器上直接测试运行的完全代码没,我测试下

我在模拟器上也模拟了,显示正常,没有问题,现在是想不到哪里会引起这个显示错误的原因
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117535
QQ
发表于 2024-9-25 10:17:31 | 显示全部楼层
shuangrenyu 发表于 2024-9-24 11:05
我在模拟器上也模拟了,显示正常,没有问题,现在是想不到哪里会引起这个显示错误的原因

帮你在我们的V7板子上测试了下,是正常的,你的原始测试代码

1234.png

[C] 纯文本查看 复制代码
/*
*********************************************************************************************************
*	                                  
*	模块名称 : GUI界面主函数
*	文件名称 : MainTask.c
*	版    本 : V1.0
*	说    明 : emWin测试。
*              
*	修改记录 :
*		版本号   日期         作者          说明
*		V1.0    2021-02-06   Eric2013  	    首版    
*                                     
*	Copyright (C), 2021-2030, 安富莱电子 [url]www.armfly.com[/url]
*
*********************************************************************************************************
*/
#include "bsp.h"
#include "MainTask.h"

#define ID_WINDOW_0              (GUI_ID_USER + 0x00)
#define ID_BUTTON_0              (GUI_ID_USER + 0x01)
#define ID_BUTTON_1              (GUI_ID_USER + 0x02)
#define ID_BUTTON_2              (GUI_ID_USER + 0x03)
#define ID_BUTTON_3              (GUI_ID_USER + 0x04)
#define ID_BUTTON_4              (GUI_ID_USER + 0x05)
#define ID_BUTTON_5              (GUI_ID_USER + 0x06)
#define ID_BUTTON_6              (GUI_ID_USER + 0x07)
#define ID_BUTTON_7              (GUI_ID_USER + 0x08)
#define ID_EDIT_0              (GUI_ID_USER + 0x09)
#define ID_EDIT_1              (GUI_ID_USER + 0x0A)
#define ID_TEXT_0              (GUI_ID_USER + 0x0B)
#define ID_TEXT_1              (GUI_ID_USER + 0x0C)
#define ID_TEXT_2              (GUI_ID_USER + 0x0D)

static const GUI_WIDGET_CREATE_INFO _aDialogCreate1[] = {
  { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 480, 272, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button1", ID_BUTTON_0, 18, 87, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button2", ID_BUTTON_1, 130, 87, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button3", ID_BUTTON_2, 245, 87, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button4", ID_BUTTON_3, 361, 87, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button5", ID_BUTTON_4, 18, 161, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button6", ID_BUTTON_5, 130, 161, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button7", ID_BUTTON_6, 245, 161, 88, 44, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button8", ID_BUTTON_7, 361, 161, 88, 44, 0, 0x0, 0 },
  { EDIT_CreateIndirect, "Edit", ID_EDIT_0, 48, 239, 80, 26, 0, 0x64, 0 },
  { TEXT_CreateIndirect, "Text", ID_TEXT_0, 370, 2, 112, 20, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "Text", ID_TEXT_1, 368, 24, 112, 20, 0, 0x0, 0 },
  { EDIT_CreateIndirect, "Edit", ID_EDIT_1, 348, 239, 80, 26, 0, 0x64, 0 },
  { TEXT_CreateIndirect, "Frt", ID_TEXT_2, 109, 1, 237, 20, 0, 0x0, 0 },
  // USER START (Optionally insert additional widgets)
  // USER END
};

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


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

/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog1(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int     NCode;
  int     Id;
  char    buf[20];
  RTC_TimeTypeDef RTC_TimeStruct;
  RTC_DateTypeDef RTC_DateStruct;//                        //显示日期

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

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'Edit'
    //
GUI_SetFont(GUI_FONT_8X18);
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
    EDIT_SetText(hItem, "12345678");
    //
    // Initialization of 'Edit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1);
    EDIT_SetText(hItem, "123456.78");
      

    //
    // Initialization of 'Frist'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
    TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
    TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    // USER START (Optionally insert additional code for further widget initialization)
    // USER END

    break;


    /* 定时器消息 */
  case WM_TIMER:   //--------------(1)

//                //显示日期
//                //HAL_RTC_GetDate(&hrtc,&RTC_DateStruct,RTC_FORMAT_BIN);//获取日期
//                sprintf((char*)buf,"20%02d-%02d-%02d",RTC_DateStruct.Year,RTC_DateStruct.Month,RTC_DateStruct.Date);
//                TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_0), (const char*)buf);               
//                //显示时间
//                HAL_RTC_GetTime(&hrtc,&RTC_TimeStruct,RTC_FORMAT_BIN);//获取时间
//                sprintf((char*)buf,"%02d:%02d:%02d",RTC_TimeStruct.Hours,RTC_TimeStruct.Minutes,RTC_TimeStruct.Seconds);        
//                TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_1), (const char*)buf);

                WM_RestartTimer(pMsg->Data.v, 1000);
                break;
      
         case WM_KEY:
                switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key)
                {
                        case GUI_KEY_ESCAPE:
                                        GUI_EndDialog(pMsg->hWin, 1);
                                        break;
                        case GUI_KEY_TAB:
                                 WM_SetFocusOnNextChild(pMsg->hWin);
                                 break;
                }
                break;

  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case ID_BUTTON_0: // Notifications sent by 'Button1'
      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
          GUI_EndDialog(pMsg->hWin, 0);
          //reateSECOND();
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_1: // Notifications sent by 'Button2'
      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_BUTTON_2: // Notifications sent by 'Button3'
      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_BUTTON_3: // Notifications sent by 'Button4'
      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_BUTTON_4: // Notifications sent by 'Button5'
      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_BUTTON_5: // Notifications sent by 'Button6'
      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_BUTTON_6: // Notifications sent by 'Button7'
      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_BUTTON_7: // Notifications sent by 'Button8'
      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 'Edit'
      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;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // 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_1: // Notifications sent by 'Edit'
      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;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // 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;
    // 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
*
**********************************************************************
*/
/*********************************************************************
*
*       CreateWindow
*/

WM_HWIN CreateWindow(void) {
  WM_HWIN hWin;
  WM_HTIMER hTimer;
  hWin = GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), _cbDialog1, WM_HBKWIN, 0, 0);
        WM_SetFocus(hWin);
  /* 给对话框hDlg创建定时器,溢出时间是100ms */
  hTimer = WM_CreateTimer(hWin, 0, 1000, 0); //--------------(2)

  return hWin;
}


/*
*********************************************************************************************************
*	函 数 名: MainTask
*	功能说明: GUI主函数
*	形    参: 无
*	返 回 值: 无
*********************************************************************************************************
*/
void MainTask(void) 
{
	
	/* 初始化 */
	GUI_Init();
	
	/*
	 关于多缓冲和窗口内存设备的设置说明
	   1. 使能多缓冲是调用的如下函数,用户要在LCDConf_Lin_Template.c文件中配置了多缓冲,调用此函数才有效:
		  WM_MULTIBUF_Enable(1);
	   2. 窗口使能使用内存设备是调用函数:WM_SetCreateFlags(WM_CF_MEMDEV);
	   3. 如果emWin的配置多缓冲和窗口内存设备都支持,二选一即可,且务必优先选择使用多缓冲,实际使用
		  STM32H7 + 32位SDRAM + RGB565/RGB888平台测试,多缓冲可以有效的降低窗口移动或者滑动时的撕裂
		  感,并有效的提高流畅性,通过使能窗口使用内存设备是做不到的。
	   4. 所有emWin例子默认是开启三缓冲。
	*/
	WM_MULTIBUF_Enable(1);
	
	/*
       触摸校准函数默认是注释掉的,电阻屏需要校准,电容屏无需校准。如果用户需要校准电阻屏的话,执行
	   此函数即可,会将触摸校准参数保存到EEPROM里面,以后系统上电会自动从EEPROM里面加载。
	   TOUCH_Calibration(2); 参数为2表示两点校准
	   TOUCH_Calibration(4); 参数为4表示四点校准
	*/
#if 0
	LCD_SetBackLight(255);
    TOUCH_Calibration(2);
#endif

	/* 设置桌面窗口的背景色是白色,并且支持重绘 */
	WM_SetDesktopColor(GUI_BLUE); 
	
    CreateWindow();
	
    /* 屏幕显示后点亮,有效防止瞬间高亮 */
    GUI_Delay(200);
	LCD_SetBackLight(255);
		
	while(1) 
	{
		GUI_Delay(10);
	}
}

/***************************** 安富莱电子 [url]www.armfly.com[/url] (END OF FILE) *********************************/

回复

使用道具 举报

2

主题

10

回帖

16

积分

新手上路

积分
16
 楼主| 发表于 2024-9-25 11:58:41 | 显示全部楼层
eric2013 发表于 2024-9-25 10:17
帮你在我们的V7板子上测试了下,是正常的,你的原始测试代码

谢谢,麻烦你了,我自己在PC模拟也是显示正常的,但是在板子上就显示不正常。
板子上的程序改成这样,中英文显示都是正常的,这个能不能排除SDRAM和LTDC、enwin的移植问题啊?
void MainTask(void)
{
    /* 初始化 */
    GUI_Init();   
    /* 窗口自动使用存储设备 */
    WM_SetCreateFlags(WM_CF_MEMDEV);

//    /* 创建对话框,使用GUIBulder生成的对话框创建函数 */
   GUI_SetFont(&GUI_FontFontSong24);
    GUI_DispStringAt("Frt",0,0);
    GUI_DispStringAt("Button1",0,32);         
    GUI_DispStringAt("时间设置",0,32);         
    GUI_UC_SetEncodeUTF8();       
    //CreateWindow();
    while (1)
    {
        GUI_Delay(100);
    }
}
回复

使用道具 举报

356

主题

2180

回帖

3253

积分

版主

Rank: 7Rank: 7Rank: 7

积分
3253
发表于 2024-9-25 13:17:15 | 显示全部楼层
本帖最后由 caicaptain2 于 2024-9-25 13:20 编辑
shuangrenyu 发表于 2024-9-25 11:58
谢谢,麻烦你了,我自己在PC模拟也是显示正常的,但是在板子上就显示不正常。
板子上的程序改成这样,中 ...

这个看着像内存空间溢出冲突造成的。
改一下emwin的缓存空间大小和地址看看。
回复

使用道具 举报

2

主题

10

回帖

16

积分

新手上路

积分
16
 楼主| 发表于 2024-9-25 15:02:29 | 显示全部楼层
caicaptain2 发表于 2024-9-25 13:17
这个看着像内存空间溢出冲突造成的。
改一下emwin的缓存空间大小和地址看看。

你好,enwin的内存配置如下,改了也是没有用

/* emWin动态内存首地址 */
#define SDRAM_APP_BUF     ((uint32_t)0xC0900000)

#define EX_SRAM   1/*1 used extern sram, 0 used internal sram */

#if EX_SRAM
#define GUI_NUMBYTES  (1024*1024*8)
#else
#define GUI_NUMBYTES  (100*1024)
#endif

/* Define the average block size */
#define GUI_BLOCKSIZE 0x80

U32 *aMemory;
void GUI_X_Config(void)
{
#if EX_SRAM

        aMemory = (U32 *)SDRAM_APP_BUF;
       
        /*  Assign memory to emWin */
        GUI_ALLOC_AssignMemory(aMemory, GUI_NUMBYTES);
        GUI_ALLOC_SetAvBlockSize(GUI_BLOCKSIZE);
#else       
        /* 32 bit aligned memory area */
        static U32 aMemory[GUI_NUMBYTES / 4];
       
        /*  Assign memory to emWin */
        GUI_ALLOC_AssignMemory(aMemory, GUI_NUMBYTES);
        GUI_ALLOC_SetAvBlockSize(GUI_BLOCKSIZE);
#endif
}
回复

使用道具 举报

2

主题

10

回帖

16

积分

新手上路

积分
16
 楼主| 发表于 2024-9-25 15:05:27 | 显示全部楼层
enwin的内存debug调试看了
批注 2024-09-25 143936.png
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117535
QQ
发表于 2024-9-25 15:43:29 | 显示全部楼层
shuangrenyu 发表于 2024-9-25 15:02
你好,enwin的内存配置如下,改了也是没有用

/* emWin动态内存首地址 */

这个地方使用内部SRAM正常不。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-8-13 09:46 , Processed in 0.055115 second(s), 28 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

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