MFC C++ project under MS VS2015. My plan is to dynamically create lots of (say >200) CStatic boxes using the extended styles: WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE to make them look nice. It means I can’t use CStatic::Create, instead using:
DWORD style = WS_VISIBLE | WS_CHILD | SS_CENTER | SS_NOTIFY;
p->box = CreateWindowEx(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE, "STATIC", nStr, style,
p->posX, p->posY, p->sizeX, p->sizeY, this->GetSafeHwnd(), NULL, GetModuleHandle(nullptr), NULL );
It would be very convenient to find out if one of the static windows has been clicked so I set the SS_NOTIFY style. According to the docs I should get an STN_CLICKED notification, which is great. But this apparently goes through the WM_COMMAND message.
WM_COMMAND is not listed as an available message in the parent dialog properties.
If I manually create a static box in the parent dialog, and set the Notify property as true, I can get an STN_CLICKED handler which neatly goes in to the message map macro:
ON_STN_CLICKED( IDC_TEST, &CFamilyDlg::OnStnClickedTest )
Since I am dynamically creating the boxes, I can’t put one handler in for each static window. (In any case the CreateWindowEx function generates an HWND rather than having a control ID.)
I want to receive all STN_CLICKED messages, then use the HWND to tell me which one is active so I can do something about it.
Thoughts?
ON_CONTROL_RANGE(STN_CLICKED, STID_MIN, STID_MAX, &YourFunc);Google for ON_CONTROL_RANGE(). If that doesnt work, try ON_NOTIFY_RANGE - Joseph Willcoxson