 |
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
 |
Message Automatically Removed
|
|
|
|
 |
|
 |
i want display icons with checkboxs..
how can i display Bitmaps or icons with check boxes on the property sheet
vijay.
|
|
|
|
 |
|
 |
You can rename the init() method to PreSubclassWindow(). Don't forget to rename the declaration as well. This method is called at control construction by the MFC sub-system. Thus the initialization operations executed in the original Init() method will all be executed automatically at construction time.
|
|
|
|
 |
|
 |
when user check/uncheck the checkbox, who will send notification to the parent, the group control or ID_STATICCHECKBOX?
|
|
|
|
 |
|
 |
I too wanted to get the OnCheck notification in the parent, and could not figure it out, so I adjusted the CCheckStatic::OnCommand class to explicitly on-send messages to the parent. Maybe this is unnecessary, however you do what you can get to work!
I noticed that HIWORD(wParam) contained:
0 for checking (both on and off)
6 for SetFocus (despite WM_SETFOCUS being 7)
7 for KillFocus (despite WM_KILLFOCUS being 8)
Can anyone tell me why?
I also changed the Init() function to assign the SAME Ctl ID to the check box as to the parent static thus:
if(!m_Check.Create(caption, WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_CHECKBOX | BS_NOTIFY, CRect(m_rcStatic.left + 10, m_rcStatic.top , m_rcStatic.left + size.cx, m_rcStatic.top + size.cy), this, GetDlgCtrlID()))
AfxMessageBox("Failed");
now removing the need to have a ID set aside to use.
You can now trap the ON_BN_CLICKED message (or use the OnCommand) of the parent dlg to find out when the check was changed by the user.
Here is my new OnCommand.
BOOL CCheckStatic::OnCommand(WPARAM wParam, LPARAM lParam)
{
//if (wParam == ID_STATICCHECKBOX)
if(HIWORD(wParam) == 0)
{
BOOL check = m_Check.GetCheck();
m_Check.SetCheck(!check);
// If we have specified some items to include, step through them
if (m_ItemID.GetSize() > 0)
{
for (int i = 0; i < m_ItemID.GetSize(); i++)
{
GetParent()->GetDlgItem(m_ItemID[i])->EnableWindow(!check);
}
}
// Otherwise, we step through the entire dialog list generated earlier
else
{
for (int i = 0; i < m_IDList.GetSize(); i++)
{
CWnd * pWnd = GetParent()->GetDlgItem(m_IDList[i]);
// We grab the rect of the item, put it into client co-ord's and only modify items inside our static box
CRect rc;
pWnd->GetWindowRect(&rc);
ScreenToClient(&rc);
if (m_rcStatic.PtInRect(rc.TopLeft()) && m_rcStatic.PtInRect(rc.BottomRight()))
pWnd->EnableWindow(!check);
}
}
GetParent()->SendMessage(WM_COMMAND, wParam, lParam);
return TRUE;
}
//Send Focus messages too
GetParent()->SendMessage(WM_COMMAND, wParam, lParam);
return CStatic::OnCommand(wParam, lParam);
}
|
|
|
|
 |
|
 |
Very useful class, just one other small amendment:
Although the check box created at the top of the static box has the WS_TABSTOP style set, it won't behave as a tabstop because its parent is the static box rather than the dialog box. To get it to behave as expected, set the static box as a tabstop and just get the CCheckStatic class to handle WM_SETFOCUS by passing the focus to the check box:
void CCheckStatic::OnSetFocus(CWnd* )
{
m_Check.SetFocus();
}
Gavin Greig
|
|
|
|
 |
|
 |
hey,
Thanks for a great control, but I needed to be able to enable and disable the check box. So I added the following function the header file.
void SetEnabled(BOOL Enable = TRUE) { m_Check.EnableWindow(Enable); };
***********************
Tony Fontenot
Recreational Solutions
tony@recsolutions.com
***********************
|
|
|
|
 |
|
 |
Um... this code is all kinda useless, in that you can't get the check state of the button. Add this to the method list in the header:
BOOL GetCheck() { return m_Check.GetCheck(); };
to fix the problem. You can move the implimentation to the .cpp if you want, but I wanted to post an easy fix.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
 |
|
 |
Shouldn't the controls _inside_ the groupbox rectangle be enabled/disabled
regardless of the WS_TABSTOP style and the taborder?
CWnd* pWnd = pParent->GetWindow(GW_CHILD);
while (pWnd)
{
if (IsTheControlInsideTheGroupBox(pWnd))
pWnd->EnableWindow(IsThisGroupBoxChecked());
pWnd = pWnd->GetNextWindow();
}
syjwg
|
|
|
|
 |
|
 |
If this is the method of enumerating items in a dialog that the MSDN didn't want to reveal to me when I searched, then yes - it would be better than stepping through the tab order, as I am doing.
I'll try it and post an update if it works.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
 |
|
 |
I've had a play and sure enough, if you replace the init code commented out below with the code below it, you'll find that tab order becomes irrelevant, and also if you have more than one IDC_STATIC, everything beyond the second will still work, although only the first item named IDC_STATIC will be disabled.
/* CWnd * pWnd = this;
while (loop == false)
{
pWnd = GetParent()->GetNextDlgTabItem(pWnd, TRUE);
int ID = ::GetDlgCtrlID(pWnd->m_hWnd);
// If we're trying to add the same ID twice, we've gone right round the horn.
for (int i = 0; i< m_IDList.GetSize(); i++)
if (m_IDList[i] == ID)
loop = true;
if (!loop)
m_IDList.Add(ID);
}
*/
CWnd* pWnd = GetParent()->GetWindow(GW_CHILD);
while (pWnd)
{
int ID = ::GetDlgCtrlID(pWnd->m_hWnd);
// If we're trying to add the same ID twice, we've gone right round the horn.
for (int i = 0; i< m_IDList.GetSize(); i++)
if (m_IDList[i] == ID && ID != IDC_STATIC)
loop = true;
if (!loop)
m_IDList.Add(ID);
pWnd = pWnd->GetNextWindow();
}
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
 |
|
 |
In the second pane, if you set the radio button to the included one, then disable the pane, you can set the excluded radio button.
You will notice that both radio buttons are checked! Even if you re-enable the pane they are still slected.
I don't know if there is anything that can be done about this from this control (standard windows behavior with disabled radio buttons in a group) but developers should be aware of this and create their pages and sub-controls with this in mind.
|
|
|
|
 |
|
 |
Thanks for this - I also have realised that if you have more than one IDC_STATIC everything in the dialog beyond the second one will not be turned on/off, using the left pane default behaviour. I admit to having thrown this together on a sleepless night, it probably could have used a little more testing )
As it stands, the fix for the problem you've noted would be to have an On method for each radio button and manually uncheck the disabled one.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
 |