-
June 30th, 2014, 07:57 AM
#1
[RESOLVED] BS_PUSHBUTTON starts disabled on creation
Hi,
I am trying to create a button on a panel. On creation however it starts off disabled and I can't find out why.
In my class:
Code:
CButton m_ZoomIncrease;
On creation of the panel:
Code:
m_ZoomIncrease.Create(CString((LPCTSTR)IDS_ZOOM_INCREASE),WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON,CRect(0,0,20,20),this,IDC_INCREASEZOOM);
If I change BS_PUSHBUTTON to either BS_AUTO3STATE or BS_AUTOCHECKBOX it works fine. If I change it to BS_RADIOBUTTON however it still doesn't work.
Any help would be greatly appreciated.
-
June 30th, 2014, 09:42 AM
#2
Re: BS_PUSHBUTTON starts disabled on creation
I used this code:
Code:
CButton myButton2;
...
// Create a radio button.
myButton2.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON,
CRect(10,40,100,70), this, 2);
And it works:
Victor Nijegorodov
-
June 30th, 2014, 10:06 AM
#3
Re: BS_PUSHBUTTON starts disabled on creation
Here is what I get with my code.
Copied your code just in case and I get the same result. So something somewhere else in the code is disabling it?
-
June 30th, 2014, 10:29 AM
#4
Re: BS_PUSHBUTTON starts disabled on creation
Code you post a small project that can reproduce this behaviour?
Zip it up (not including .ncb, .aps, .sdf files nor Debug. Release, ipch folders) and we will try to test it.
Victor Nijegorodov
-
June 30th, 2014, 11:53 AM
#5
Re: BS_PUSHBUTTON starts disabled on creation
Create a button handler for it.
-
July 1st, 2014, 08:26 AM
#6
Re: BS_PUSHBUTTON starts disabled on creation
I have identified the problem however I don't understand why it occurs.
In my OnPaint() function I call CPaintDC dc(this) which is what causes the buttons to become disabled. Anyone know why this may be?
Code:
void MxScopePanel::OnPaint()
{
DWORD ix, inc;
int y;
DWORD col;
DWORD grpix, strmix;
MxScopeGroup *pGroup;
MxScopeStream *pStream;
CRect clientarea, area;
MxScopeManager *pScope = MxScopeManager::GetDefault();
CString tempHeight = MxGlobals().CurrentDigital.Get();
DWORD Heighti = MXUtils::ConvertMetricVal(tempHeight);
//Fill the background with the doc's background
CPaintDC dc(this); // device context for painting
// Get the colour here
col = dc.GetBkColor();
dc.SetBkMode(TRANSPARENT);
this->GetClientRect(clientarea);
-
July 1st, 2014, 08:34 AM
#7
Re: BS_PUSHBUTTON starts disabled on creation
1. What is MxScopePanel?
2. What are you going to paint in ints OnPaint method? What for?
3. BTW, you whole pane (post#3) looks like disabled. Is it by design?
Victor Nijegorodov
-
July 1st, 2014, 08:48 AM
#8
Re: BS_PUSHBUTTON starts disabled on creation
MxScopePanel is my class which is used to produce a data scope panel.
This is what gets created through OnPaint.
What I am currently working with produces the data scope and draws it through OnPaint. What I have added is the + and - button and the slider.
The slider works fine so that isn't disabled. If I comment out the CPaintDC dc(this) along with all the dc parts within the rest of OnPaint the buttons become enabled and functional however the rest of the scope isn't drawn as dc is needed throughout OnPaint to draw the data scope.
Last edited by David-I; July 1st, 2014 at 08:51 AM.
-
July 1st, 2014, 09:13 AM
#9
Re: BS_PUSHBUTTON starts disabled on creation
Originally Posted by David-I
MxScopePanel is my class which is used to produce a data scope panel.
This is what gets created through OnPaint.
...
What I am currently working with produces the data scope and draws it through OnPaint. What I have added is the + and - button and the slider.
The slider works fine so that isn't disabled. If I comment out the CPaintDC dc(this) along with all the dc parts within the rest of OnPaint the buttons become enabled and functional however the rest of the scope isn't drawn as dc is needed throughout OnPaint to draw the data scope.
- What is your class derived from?
- Isn't it possible to add radio button in the resource editor?
- CPaintDC dc(this) is used within OnPaint. It is by design of Microsoft Framework. So if you comments it out then nothing will be painted on the panel. Except the controls that draw themselves (all visible child controls)
- If your radio button gets (or, at least looks like) disabled because of executing the code in OnPaint then you are doing your drawing wrong!
Victor Nijegorodov
-
July 1st, 2014, 10:21 AM
#10
Re: BS_PUSHBUTTON starts disabled on creation
Solved it.
I examined how the CImageButton help button that is currently on there works and found it has an extra Message Map handle that I didn't spot before. So I passed my buttons through it and they now work as expected.
Code:
BEGIN_MESSAGE_MAP(MxScopePanel, MxScopePanel_Base)
...
ON_UPDATE_COMMAND_UI(IDC_BTNHELP, OnHelpUI)
ON_UPDATE_COMMAND_UI(IDC_INCREASEZOOM, OnHelpUI)
ON_UPDATE_COMMAND_UI(IDC_DECREASEZOOM, OnHelpUI)
ON_CONTROL_RANGE(BN_CLICKED, IDC_INCREASEZOOM, IDC_DECREASEZOOM, OnModifyZoom)
END_MESSAGE_MAP()
void MxScopePanel::OnHelpUI(CCmdUI *pCmdUI)
{
// Update the command checkbox based on mode
pCmdUI->Enable();
}
Thank you for your help and time Victor. Much appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|