catching clicks on dialog items in wina32 api

Started by
1 comment, last by xplo 22 years, 1 month ago
Hi, I''m quite new to window/dialog coding directly in the win32 API but so far I''ve enjoyed exploring it a lot. However I''m at a point that I can''t get past: How do I catch clicks on certain items (not buttons) in a dialog callback function? I''ve tried if the items send a WM_COMMAND just like buttons but they don''t seem to. I also tried somehow getting the WM_MBUTTONDOWN coordinates to be checked against the Positions of the objects but I can''t figure out how to get the coordinates of the items. The particular thing I''m trying to do is simply catching all clicks on a "picture control" (static, type frame) and executing stuff on clicks. Any hints on what I could do? Peace Out. [xplo]
Peace Out. [xplo]
Advertisement
You have to handle WM_COMMAND. You''ll need to use GetDlgItem to retrieve a handle to the object in question.
case WM_COMMAND:{  long code = HIWORD(wParam); // notification code  long ID = LOWORD(wParam);   // item/control/accelerator id  if(code) // message is from an accelerator  {  }  else     // message is from a menu/control  {    HWND hctrl = (HWND)lParam; // control handle    switch(ID)    {      case DLG_ITEM: // whatever DLG_ITEM actually is      {        HWND hitem = GetDlgItem(hctrl, ID);        // do your thang      }      break;      // other cases    }  }}return 0; 


[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
Thanks for the detailed reply. It did help me, but an important thing I forgot to activate is give the static control the "SS_NOTIFY" property. W/o that static controls don''t seem to send WM_COMMAND''s at all when clicked.

Peace Out. [xplo]
Peace Out. [xplo]

This topic is closed to new replies.

Advertisement