|
jimwawar wrote: The above code throws an errors as Node has not been declared. Can Node be used inside the struct Node?
Thanks for any help.
It is a little easier to do with a class than a struct, but you need a struct name rather than a typedef, and you need pointer references.
<br />
typedef struct stNode<br />
{<br />
struct stNode *child[4];<br />
} Node;<br />
The main reason you want pointer references is that every child would have children, which would have children, which would have children, which would have children, etc. A pointer is a fixed size.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
If you could define such a structure you'd need a beefy machine to make use of it; it would require an infinite amount of memory!
Steve
|
|
|
|
|
Hi,
In my darkest of hours, you guys never fail to provide shining light. So here goes...
I'm creating a radio button dialog that goes on top of another dialog, and I'm having a problem with initialization of the whole thing. Specifically, when my radio button dialog is being initialized something is firing off an OnBnClicked event for one of the radio buttons.
1) What could possibly be doing this? It happens in such a way as not to actually leave the button selected. (Yet when you step through you definitely get sent to that event handler.)
2) Is it somehow possible using the magic of VisualStudio to trace what's triggering an event handler?
3) As I mentioned, this radio button dialog window gets pasted on top of another dialog window. Is there something weird about this process?
Thanks - eagerly awaiting any replies - Jason
|
|
|
|
|
So if you set a breakpoint in the event handler and check the call stack, what do you see?
In any case, why is this a problem? Is it causing something to not get drawn?
"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
|
|
|
|
|
Dave,
Thanks for your interest! It's a problem for the opposite reason, it IS causing something to be drawn. 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. And I'm trying to design it so that it comes up blank, ready for a radio button to be selected.
Here's the first entry in the call stack prior to the event handler:
>Direct3DMFC.exe!_AfxDispatchCmdMsg(CCmdTarget * pTarget=0x0012e460, unsigned >int nID=1062, int nCode=0, void (void)* pfn=0x00523fb6, void * >pExtra=0x00000000, unsigned int nSig=56, AFX_CMDHANDLERINFO * >pHandlerInfo=0x00000000) Line 82 C++
Any further suggestions? I should point out that in attempting to debug this little caper i have done the following:
1) Moved the radio button to another location (bug persists)
2) Deleted the message map according to this event handler (bug goes away)
3) Created another radio button with another name for handling similar events. (This one now takes the problem.)
4) Checked as many params etc as I can think of to see why this radio button would be different from all the others? The only thing that I can think of is that it may have been the last one that I put on there.
Yay - debugging!
Thanks again - Jason
|
|
|
|
|
@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
|
|
|
|