|
When?I don't konw.When I started,it didn't happen.
After I'v finished the program ,I need extra functions and more BUTTON,and then it happened.
the instructions that causes the crash is "CBUTTON m_BUTTON1" in the header file.
|
|
|
|
|
do you allocate memory for you button in the class constructor ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
allocate memory ?oh,I don't konw which operation can allocate memory for buttons in the class constructor?!
|
|
|
|
|
pfff, hey, do you know C++ ? do you know how that language work ?!
in your class, you have a member CBUTTON m_Button1; , but that doesn't create a button for you !!
that just declares a data member in your class that is of type CBUTTON.
if you want to use m_Button1 as a button of your dialog, you must allocate a button and store its address into this member.
Do you know the operator new ?????
Did you ever heard of the constructor of a class ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
|
yeetins wrote:
When?I don't konw.When I started,it didn't happen.
I don't ask when during the developement of your project it happened but when during your program that is running ! Is it when you launch your program or is it when you press the button ??
yeetins wrote:
the instructions that causes the crash is "CBUTTON m_BUTTON1" in the header file.
It is NOT an instruction ! You just declare a variable inside a header file. It is impossible that this is causing the bug. And also, you are using CBUTTON or CButton ? Because CBUTTON is probably then a user defined class ? From where does that come ??
I will suggest you to take some time to understand how to use the debugger because it is a really powerfull tool and you can obtain results much more quickier than posting on the forum. To start the debugger, press F5 and to set breakpoints (points in which the program will be stopped and where you can watch the value of the different variables) press F9. Then what you can do to see what instruction causes the crash is using step by step debugging (with F11 if I remember correctly).
|
|
|
|
|
Thanks for help,I am trying it.
But I think this will not work,because there is no problem when compiling the program.
It happons only when I run the .exe file
|
|
|
|
|
Err, ok, I think the first thing to do is open a C++ book and understand at least the basic of the language, otherwise we won't be of any help...
yeetins wrote:
But I think this will not work,because there is no problem when compiling the program.
No errors at compilation doesn't mean that your program doesn't contain any bug !! The compiler throw errors only if it cannot 'understand' some part of your code, but if it understand your code, it will compile even if they are enormous mistakes within it.
|
|
|
|
|
cedric moonen wrote:
No errors at compilation doesn't mean that your program doesn't contain any bug !!
Otherwise, windows would be free !!! :->
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
yeetins wrote:
the instructions that causes the crash is "CBUTTON m_BUTTON1" in the header file.
Do you mean CButton ? Why not show us the entire .h file instead? It's better to copy/paste rather than re-type code into a post. It would also help if we could see the dialog's DoDataExchange() method.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
thank you very much
But I think I'd better study the basic of c++ frist
I'v found what cause the prablem,but it is not what we discussed above.
thanks again
|
|
|
|
|
well you should still post what the problem was and how you solved it so that other members of CP can benefit from what you learned if they ever come across that same situation
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
Hello,
I have a strange problem with one of my classes. I have the following two classes:
<br />
template <class T0, class T1 ><br />
class SomeClass<br />
{<br />
public:<br />
typedef T0 Type0;<br />
<br />
SomeClass() {}<br />
virtual ~SomeClass() {}<br />
<br />
virtual bool DoFoo(Type0 Param1) = 0;<br />
virtual int DoFoo(Type0 Param1, int nParam2) { }<br />
<br />
};<br />
<br />
class OtherClass : public SomeClass<A, B><br />
{<br />
public:<br />
virtual bool DoFoo(Type0 nParam1) { }<br />
};<br />
And somewhere I have this code:
<br />
void SomeFunction()<br />
{<br />
OtherClass otherClass;<br />
<br />
otherClass.DoFoo(1);
otherClass.DoFoo(1, 1);
}<br />
My problem is that in SomeFunction the compiler issues C2660 for a completly valid function call. The compiler says that it doesn't know DoFoo(int, int) . I have no idea why this error is issued...
[EDIT]
I'm using VS 2005 if it is of any help.
[\EDIT]
Blog[^]
|
|
|
|
|
could be that the compiler gets confused with the A Type0 and T0.
why don^t you try casting...call it like:
otherClass.DoFoo( (Type0)1, 1);
I`m not sure that`ll solve your problem, but I`ve had similar probs..
Greets,
Davy
|
|
|
|
|
Hello,
That doesn't work. It shouldn't even matter, because the compiler says that it doesn't know that function with 2 parameters. It only knows the function with just one parameter.
If I add the function to the derived class, there is no problem..
Blog[^]
|
|
|
|
|
Bob Stanneveld wrote:
class OtherClass : public SomeClass<A, B>
What are A and B?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
A can be any non-class data type (a struct or any primitive type) and B is some policy class..
Blog[^]
|
|
|
|
|
The problem has nothing to do with templates. It's because OtherClass's DoFoo override hides the base class's DoFoo(Type0, int). Just adding
class OtherClass : public SomeClass<A, B>
{
public:
using SomeClass<int,int>::DoFoo;
virtual bool DoFoo(Type0 nParam1) { }
};
solves the problem. The using statement brings all DoFoo overloads of SomeClass into OtherClass's "namespace", so it works fine. This problem occurs whenever you have overloaded virtual methods in the base class and you're selectively overriding them in the derived class.
Caught me on the wrong foot too, I was suspecting template instantiation problems .
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hello,
I didn't know that if you override just one of many base class overloaded functions, all the base class overloads are hidden! Nice to know that this happens.
Thanks a lot
Blog[^]
|
|
|
|
|
I want to make a selection between Low Frecuency "LF_1" and High Frecuency "HF_1" with a radio button so i have to change te parameter of elTipo with it how can i do this because i try but it doesnt works
<br />
<br />
#include "include/Coordinador/CoordinadorFrecELAI.h"<br />
void CRespuestaenfrecuenciav001Dlg::OnCalcularBode() <br />
{<br />
UpdateData(true);<br />
<br />
CList<double,double> elModulo;<br />
CoordinadorFrecELAI elCoordinador;<br />
tipoFiltro elTipo = LF_1;<br />
<br />
elCoordinador.ponerCircuito(elTipo,m_Resistencia,m_Condensador);<br />
<br />
elCoordinador.ponerParamResFr(m_frInicio,m_frFinal,m_frIntervalo,elModulo);<br />
<br />
CString aux;<br />
m_Resultado= "";<br />
POSITION pos = elModulo.GetHeadPosition();<br />
for (int i=0;i<elModulo.GetCount();i++)<br />
{<br />
aux.Format("%f\r\n",elModulo.GetNext(pos));<br />
m_Resultado += aux;<br />
}<br />
UpdateData(false)<br />
}<br />
|
|
|
|
|
alvarillo wrote:
I want to make a selection between Low Frecuency "LF_1" and High Frecuency "HF_1" with a radio button...
The easiest way to deal with radio buttons is to assign each of them a CButton member variable. You can use ClassWizard to do this but only if each of the controls on the dialog's template has the WS_GROUP style. Once you've assigned all of the controls to a CButton member variable, remove the WS_GROUP style from all but the first control. See here for more.
Now it is simply a matter of calling the button's GetCheck() and SetCheck() methods. Using UpdateData() in this context is problematic.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi
I have a listbox on my dialog and some Add, Modify and Remove buttons. If I select an item in the listbox and click Remove, the item gets removed and the Remove button gets disabled (as no item is selected).
When I do this, the item gets removed correctly but now my focus is completely lost. Pressing Tab or Enter or Escape doesn't do anything. I can still use the mouse though.
I tried adding a m_pbtnAdd->SetFocus() to the OnBtnRemove function, but it makes no difference.
Does anyone know the proper way to remove an item from a listbox in this way?
Thanks
d3m0n
|
|
|
|
|
You'll need to post your code as I have several examples of doing this and it works fine.
Cheers,
Tom Archer - Archer Consulting Group
"So look up ahead at times to come, despair is not for us. We have a world and more to see, while this remains behind." - James N. Rowe
|
|
|
|