I need to create a window on the screen, create a TEXT control under the window to display a dynamic number, in order to avoid the refresh is flashing, add code in the main function:
WM_SetCreateFlags(WM_CF_MEMDEV);
However, after adding the background image, it can not be displayed (do not add the above function picture to display normal), run the error prompt:
GUI_PNG.c:Error in _png_cexcept_errot().
The detailed code is as follows, the picture code is attached, I look forward to the answer, thank you
Display All
WM_SetCreateFlags(WM_CF_MEMDEV);
However, after adding the background image, it can not be displayed (do not add the above function picture to display normal), run the error prompt:
GUI_PNG.c:Error in _png_cexcept_errot().
The detailed code is as follows, the picture code is attached, I look forward to the answer, thank you
C Source Code
- #include "DIALOG.h"
- #include "backgrond.h"
- #define ID_WINDOW_0 (GUI_ID_USER + 0x00)
- #define ID_IMAGE_0 (GUI_ID_USER + 0x01)
- #define ID_TEXT_0 (GUI_ID_USER + 0x02)
- #define ID_IMAGE_0_IMAGE_0 0x00
- #define RECOMMENDED_MEMORY (1024L * 160)
- static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
- { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 800, 480, 0, 0x0, 0 },
- { IMAGE_CreateIndirect, "Image_png", ID_IMAGE_0, 0, 0, 800, 480, 0, 0, 0 },
- { TEXT_CreateIndirect, "Text1", ID_TEXT_0, 30, 198, 100, 41, 0, 0x64, 0 },
- };
- static const void * _GetImageById(U32 Id, U32 * pSize) {
- switch (Id) {
- case ID_IMAGE_0_IMAGE_0:
- *pSize = sizeof(_acBackgrond);
- return (const void *)_acBackgrond;
- }
- return NULL;
- }
- static void _cbDialog(WM_MESSAGE * pMsg) {
- const void * pData;
- WM_HWIN hItem;
- U32 FileSize;
- switch (pMsg->MsgId) {
- case WM_INIT_DIALOG:
- WINDOW_SetBkColor(pMsg->hWin, GUI_GRAY);
- // Initialization of 'Image_png'
- hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_0);
- pData = _GetImageById(ID_IMAGE_0_IMAGE_0, &FileSize);
- IMAGE_SetPNG(hItem, pData, FileSize);
- // Initialization of 'Text1'
- hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
- TEXT_SetFont(hItem, GUI_FONT_D32);
- TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x00FFFFFF));
- TEXT_SetText(hItem, "00");
- break;
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- // USER START (Optionally insert additional public code)
- void MainTask(void) {
- WM_HWIN hWin;
- WM_HWIN hText;
- char acText[3] = { 0 };
- int value=0;
- WM_SetCreateFlags(WM_CF_MEMDEV);
- GUI_Init();
- if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) {
- GUI_ErrorOut("Not enough memory available.");
- return;
- }
- hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
- while (1) {
- GUI_Delay(10);
- sprintf(acText, "%2d", value++);
- hText = WM_GetDialogItem(hWin, ID_TEXT_0);
- TEXT_SetText(hText, acText);
- }
- }
- // USER END
The post was edited 1 time, last by OpFancy ().