Can GUI_CreateDialogBox() generate WM_CREATE message?

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Can GUI_CreateDialogBox() generate WM_CREATE message?

      When I use GUI_CreateDialogBox() to create a dialog including a window, I find that the code in WM_CREATE branch of callback function is not excuted. Then I set breakpoint in WM_CREATE branch and find it never arrived. However, if I just use WM_CreateWindow() to create the window with the same callback function, the WM_CREATE branch can be excuted. So my quesiton is does GUI_CreateDialogBox() really can not sent the WM_CREATE message or is there something wrong when I use GUI_CreateDialogBox()?

      Here is my code:

      C Source Code

      1. #include "DIALOG.h"
      2. #include "GUI.h"
      3. #define ID_WINDOW_LOADING (GUI_ID_USER + 0x01)
      4. static const GUI_WIDGET_CREATE_INFO _aLoadingDiologCreate[] = {
      5. { WINDOW_CreateIndirect, "Window", ID_WINDOW_LOADING, 0, 0, 480, 800, 0, 0x0, 0 },
      6. };
      7. void _cbLoading(WM_MESSAGE * pMsg) {
      8. switch (pMsg->MsgId) {
      9. case WM_CREATE:
      10. GUI_SetBkColor(GUI_BLACK);
      11. break;
      12. default:
      13. WM_DefaultProc(pMsg);
      14. break;
      15. }
      16. }
      17. void MainTask(void) {
      18. WM_SetCreateFlags(WM_CF_MEMDEV);
      19. GUI_Init();
      20. // This can't trig WM_CREATE
      21. GUI_CreateDialogBox(_aLoadingDiologCreate, GUI_COUNTOF(_aLoadingDiologCreate), _cbLoading, WM_HBKWIN, 0, 0);
      22. // This can trig WM_CREATE
      23. // WM_CreateWindow(0,0,480,800,WM_CF_SHOW,_cbLoading,0);
      24. while(1)
      25. {
      26. GUI_Delay(100);
      27. }
      28. }
      Display All
    • Hello,

      it is nothing wrong with your dialog.

      The WM_CREATE message is for simple windows.

      For dialog windows you should use the WM_INIT_DIALOG message instead of WM_CREATE.

      Just change it in your callback _cbLoading().

      Also you should call any drawing functions from callbacks in WM_PAINT message. If you want to achieve the black background on your dialog then you can use a special function for this purpose WINDOW_SetBkColor().

      C Source Code

      1. ...
      2. void _cbLoading(WM_MESSAGE * pMsg) {
      3. switch (pMsg->MsgId) {
      4. case WM_INIT_DIALOG:
      5. WINDOW_SetBkColor(pMsg->hWin, GUI_BLACK);
      6. break;
      7. default:
      8. WM_DefaultProc(pMsg);
      9. break;
      10. }
      11. }
      12. ...
      Display All

      Once you set it in WM_INIT_DIALOG it will draw with the specified bk color in WM_PAINT automatically.

      Alex.

      The post was edited 6 times, last by LexaGb ().