Hi,
I'm trying to fill circles and blink those circles with the help of checkbox. But I'm unable to do so. Could you please help me.
Regards,
Saieesh Kumar A
Hi,
I'm trying to fill circles and blink those circles with the help of checkbox. But I'm unable to do so. Could you please help me.
Regards,
Saieesh Kumar A
Hello,
Not sure if we understand you correctly, but this issue does not seem to be related to Embedded Studio.
Could you clarify what product you are using and what you are trying to achieve exactly?
Best regards,
Nino
Hi,
I'm using STM32F746G-Disco Board, My target is to fill the circle(random color in white Background) when checkbox is checked and unfill the circle when checkbox is unchecked.
Please do help me.
Regards,
Saieesh Kumar A
Hi,
try this:
#include "DIALOG.h"
#include "stdlib.h"
/*********************************************************************
*
* Externals
*
**********************************************************************
*/
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define RADIUS 50
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _cbBk
*/
static void _cbBk(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
int NCode;
int Id;
int State;
int xPos;
int yPos;
GUI_COLOR aColor[] = {GUI_RED, GUI_GREEN, GUI_BLUE, GUI_MAGENTA, GUI_CYAN, GUI_YELLOW };
int Index;
switch (pMsg->MsgId) {
case WM_PAINT:
//
// Clear with white
//
GUI_SetBkColor(GUI_WHITE);
GUI_Clear();
//
// Calculate the center of the screen
//
xPos = LCD_GetXSize() >> 1;
yPos = LCD_GetYSize() >> 1;
//
// get 'random' index and set a foreground color to draw the circles with
//
Index = rand() % GUI_COUNTOF(aColor);
GUI_SetColor(aColor[Index]);
//
// Get handle of the CHECKBOX and get its state
//
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_CHECK0);
State = CHECKBOX_GetState(hItem);
if (State == 0) {
GUI_DrawCircle(xPos, yPos, RADIUS); // Only a cricle outline
} else {
GUI_FillCircle(xPos, yPos, RADIUS); // A circle filled with color
}
break;
case WM_NOTIFY_PARENT:
//
// Check who sends a message and what type of message
//
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch (Id) {
case GUI_ID_CHECK0:
switch (NCode) {
case WM_NOTIFICATION_VALUE_CHANGED:
//
// Each time the state of the CHECKBOX changes we mark the desktop window
// as invalid, next time GUI_Delay() (or GUI_Exec()) gets called the window
// gets redrawn.
//
WM_InvalidateWindow(WM_HBKWIN);
break;
}
break;
}
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* MainTask
*/
void MainTask(void) {
WM_HWIN hCheckbox;
CHECKBOX_SKINFLEX_PROPS Props;
GUI_Init();
//
// Set a callback for the desktop window, this will manage the
// drawing and handles the notifications send from the CHECKBOX.
//
WM_SetCallback(WM_HBKWIN, _cbBk);
//
// Create a CHECKBOX as child of the desktop window (WM_HBKWIN).
//
hCheckbox = CHECKBOX_CreateEx(10, 10, 80, 20, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_CHECK0);
while (1) {
GUI_Delay(100);
}
}
/*************************** End of file ****************************/
Display More
Regards,
Sven
Hi Sven,
I have dumped the code provided by you but the same case is repeated here: Checkbox is not enabled and color is not filled.
Regards,
Saieesh Kumar A
Hi Sven,
Could you please help me with the logic. I have dumped the code provided by you but the same case is repeated here: Checkbox is not enabling and color is not filled. Initially it is unchecked and checkbox is not giving functionality to enable it.
Regards,
Saieesh Kumar A
Don’t have an account yet? Register yourself now and be a part of our community!