|
@largeinsd wrote: Basically, the rest of the dialog configuration depends on which radio button is selected... so when it automatically selects somethin', it's configuring the dialog according to that.
Do you have an int member variable that represents all the radio buttons, or do you have a CButton member variable for each?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: Do you have an int member variable that represents all the radio buttons, or do you have a CButton member variable for each?
The former - I have an int variable which is initialzed to -1 (no selection) in the constructor, and then when I get an "OnBnClickedRdBox1" event I do the following:
void CShapeSelect::OnBnClickedRdBox1()<br />
{<br />
m_ShapeSelected = 2;<br />
GetParent()->PostMessage(WM_SHAPE_RADIO_CHANGED);<br />
}
|
|
|
|
|
@largeinsd wrote: The former - I have an int variable...
I would lose that and use a CButton for each. Far less confusing that way.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: I would lose that and use a CButton for each. Far less confusing that way.
Ok, well I'm gonna go ahead and implement that, if nothing else hoping to work around this problem.
But let me ask you this - is there a way to make the dialog class catch the button selection event that is slightly more elegant than they way i've done it here with my own call to PostMessage ?
Thanks - Jason
|
|
|
|
|
@largeinsd wrote: But let me ask you this - is there a way to make the dialog class catch the button selection event that is slightly more elegant than they way i've done it here with my own call to PostMessage ?
Sure. Just use ClassWizard (Ctrl+W) to create a BN_CLICKED handler. All the buttons can use the same handler, or they can each have their own.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Ok, here's the update you're just dying to here:
i encounter the same problem using buttons - as soon as i add an event handler to take action when the radio buttons are selected, it gets activated on initialization. however, using method i can at least use the
m_MyRadioButton.GetChecked()
method to do some screening. it's a fine work around, but where is the ELEGANCE?
|
|
|
|
|
@largeinsd wrote: ...it gets activated on initialization.
The solution to this is to differentiate between initialization and the actual clicking of one of the buttons. I use a bool member variable to denote this.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Also, don't you need a Group Box for the radio buttons to act properly? Is that not true David?
John P.
|
|
|
|
|
jparken wrote: Also, don't you need a Group Box for the radio buttons to act properly? Is that not true David?
Ok, interesting point. For what it's worth I do have the radio buttons enclosed in a group box. If there is some particular initialization required, please let me know.
-Jason
|
|
|
|
|
jparken wrote: Also, don't you need a Group Box for the radio buttons to act properly? Is that not true David?
No, a group control (i.e., a control having the BS_GROUPBOX style) is not necessary. Perhaps you are confusing that with the first radio button of the group having the WS_GROUP style and all others in the group not.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I am trying to programatically create an empty file in a location such as
C:\Program Files\Common Files\myCo\MyTool\Temp.dat
However using the CFile member , I get a failure with code = 3
Is it not possible to create a file where the upper directories have not been created ?
This is the code I am using
<br />
<br />
CFile f;<br />
CFileException e;<br />
<br />
if( !f.Open( m_strFileName, CFile::modeCreate , &e ) )<br />
{<br />
#ifdef _DEBUG<br />
afxDump << "File could not be opened " << e.m_cause << "\n";<br />
#endif <br />
}<br />
else<br />
{<br />
<br />
<br />
}<br />
Help is apprecaite d!
|
|
|
|
|
act_x wrote: Is it not possible to create a file where the upper directories have not been created ?
no
|
|
|
|
|
You might make use of this function.
<br />
bool MakeSureDirectoryPathExists(PCSTR strPath);<br />
It helps when you are unsure of whether the entire path exists or not before you open a file.
Chris Meech
I am Canadian. [heard in a local bar]
|
|
|
|
|
Call SHCreateDirectoryEx() before creating the file.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
On a dialog based application I have attached an OpenGL window which is overlaid on a static control. When the user does a left mouse button down followed by a left mouse button up on the opengl window I want an event to occur. However i have the following constraints:
If the user leaves the area of the opengl window and release the left mouse button i don't want the event to happen
If they then press the left mouse button down outside of the opengl model and then release it whilst in the opengl window i don't want the event to happen.
However if they press the left mouse button inside the opengl window, then leave the opengl window but then come back into it and then release the mouse button the event should happen
I've tried using the left button down event on the main dialog however if the user clicks (down or up) on any of the other buttons on the dialog then the main dialog doesn't handle the event.
Does anyone know how to handle this set of events (or even what I'm talking about? )?
TIA,
Andy
|
|
|
|
|
This is an MFC example, but if you're using straight APIs you can do the same.
::MessageBeep() should get called on the left button up message according
to your requirements (unless I need more caffeine)...
void CMyWindow::OnLButtonDown(UINT nFlags, CPoint point)
{
CWnd::OnLButtonDown(nFlags, point);
SetCapture();
fInCapture = true;
}
void CMyWindow::OnLButtonUp(UINT nFlags, CPoint point)
{
if (fInCapture)
{
ReleaseCapture();
fInCapture = false;
CRect clirect;
GetClientRect(&clirect);
if (PtInRect(&clirect, point))
{
::MessageBeep(-1);
}
}
CWnd::OnLButtonUp(nFlags, point);
} Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
cheers Mark, worked a treat
|
|
|
|
|
Hello,
I have a class derived from CMDIChildWnd .In one of the functions I have written
CMenu p;
GetParentFrame()->SetMenu(&p);
But the menu doesn't change.
What else I need to do to change the menu?
Regards
Prithaa
|
|
|
|
|
You're missing DrawMenuBar .
Iain.
|
|
|
|
|
hot to assign a tooltip to a push button in c++
plz help
dghdfghdfghdfghdgh
|
|
|
|
|
|
LMAO
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
|
I create subclass that derive from CEdit and on my dialog have 2 Edit control that including two DDX variable of this class.
I need to use OnEraseBkgnd funtion for change the color of each edit control.
Can I separate the code for change different color in this function.
|
|
|
|
|
It would be better to handle the WM_CTLCOLOR message each edit send the dialog box. There;s an explanation of this method most days on here, so I'm not going to give you detail.
But one of the parameters will identify the ID of the edit control, or the HWND - and you can get the ID from that.
Then simply return different colours.
Iain.
|
|
|
|