winapi - infinite loop inside the getmessage (DispatchMessage(& msg ); is not working) -


i creating button application using resource editor. after creating button try this-

 m_hwndpreview = createdialogparam( g_hinst,makeintresource(idd_maindialog), m_hwndparent,(dlgproc)dialogproc, (lparam)this);           if (m_hwndpreview == null)         {           hr = hresult_from_win32(getlasterror());         }     msg  msg;         bool bret;         while ( (bret=getmessage (& msg,0, 0,0)) != 0)         {// msg contains data -msg = {msg=0x0000c03e wp=0x0000000000000012//always 12 don't know why ??  lp=0x0000000000000000}             if (bret == -1)             {                 bret = hresult_from_win32(getlasterror());                 messagebox(null, l"hurr  error",l"error",mb_iconerror | mb_ok);             }              else if (!isdialogmessage (m_hwndpreview, & msg))             {                  translatemessage (&msg); //on debugging  translatemessage = 0x000007feee615480 translatemessage                  dispatchmessage(& msg ); //but show nothing when put cursor on method know value means it's not called                   messagebox(null, l"there no error in receiving before dispatch message",l"error",                   mb_iconerror | mb_ok);//this messagebox  repeats again , again after call dialogproc function , not able come out of loop , here need restart pc 

at other place define createdialog function this- //this function called on createdialogparam() function.after controls go getmessage loops.

bool callback amepreviewhandler::dialogproc(hwnd m_hwndpreview, uint umsg, wparam wparam, lparam lparam)      { //this dialogproc function declares static in code otherwise createdialogparam give error dlgproc  invalid conversion  //this umsg alays creates strange value 48 , 32 etc.. , wparam contains big value 12335423526 (i mean big , strange) , lparam contains 0.         switch(umsg)         {         case wm_initdialog:              {                 messagebox(null, l"inside wm_initdialog function",l"error",                  mb_iconerror | mb_ok);              return true;             }             break;          case wm_create:             {             /////////////////             messagebox(null, l"inside wm_create",l"error",                  mb_iconerror | mb_ok);             /////////////////////////////////             }             break;          case wm_command:             {   //here 2 buttons created me should show messagebox on click                 int ctl = loword(wparam);                 int event = hiword(wparam);//i don't know why event in blue colour ..  not pqrt of problem right now.                  if (ctl == idc_previous && event == bn_clicked )                  {                              messagebox(m_hwndpreview,l"button  clicked next inside wm_command ",l"btn wnd",mb_iconinformation);                      return 0;                 }                           if (ctl == idc_next && event == bn_clicked )                  {                              messagebox(m_hwndpreview,l"button  clicked previous inside wm_command",l"btn wnd",mb_iconinformation);                     return 0;                 }                           return false;              }break;           case wm_destroy:             {                  ////////////////::                     messagebox(null, l"inside wm_destroy",l"error",                  mb_iconerror | mb_ok);                     //////////////////                  postquitmessage(0);                 return 0;              }             break;             case wm_close:                 {                     messagebox(null, l"inside wm_close",l"error",                  mb_iconerror | mb_ok);                      destroywindow (m_hwndpreview);                     return true;                              }                 break;                    }                 messagebox(null, l"outside defwindowproc function",l"error",                  mb_iconerror | mb_ok);          return 0;     } 

the problem occurring when debut control first go createdialogparam , go getmessage control don't come out of loop causing restart problem. , have no display of button , image @ preview pane. expect if go fine after debugging should show picture on preview pane , have 2 buttons "next" , "previous" show blank window (the buttons , photo have created using resource editor... that's correct sure that) .. don't know why not coming out getmessage function , dispatchmessage not called (because saw on debugging).

so can try comment getmessage part code out if problem because creating button using idd_maindialog , createdialogparam directly calls dailogproc function receive wm_command , handle code behind.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -