|
In C++ how we can associate a function with a variable. means the function should be called automatically when the value of variable changes.
|
|
|
|
|
i don't really understand. this cannot be done automatically - say, when you assign the variable, the function is called automatically.
but if the variable changes, it is because you assigned it, so why no calling the function right after this assignation ?
moreover, i'm not sure, by i have the impression that we don't have the same vocabulary.
what you call by 'variable' is a control over a dialog or a frame, which is associated with a variable ; what you need so is knowing when the control's content is modified so that the framework calls its event handler ?
is so, see the events of your control (EN_CHANGE for a CEdit control).
if i'm wrong, please reformulate your question because it is really not clear enough.
|
|
|
|
|
There is no way to do that in C++, atleast that i know of.
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
Just a thought.
What if you create a class, encapsulating a variable of the desired type?
And then, using operator overloading, call a (class) function when the value changes?
Right out of my mind, I think it should work.
Thoughts, anyone?
|
|
|
|
|
yes, it's a good solution, as you ask my thought.
but i still have a doubt about what the guy was asking, and i suspect him not to express himself correctly and not to want this...
anyway, as he doesn't give feedback...
|
|
|
|
|
yes - and make the actual data private which force all access to happen through the methods.
|
|
|
|
|
There is no standard way to do this. In MSVC you can use __declspec(property) to do it but note this is not portable.
Steve
|
|
|
|
|
I compile a project(ATL dll based) in VS.NET 2005 under windows XP(sp2) and the build configuration is x64. The IDE will always perform a registration after project successfully compiled. This is the trouble, my machine is 32bit and target dll is 64bit, it always show an error:
Project: error PRJ0019: A tool returned an error code from "Performing
registration".
It is deservedly error for 64bit file can't register under 32bit windows.
how could i get the dll under 32bit windows? by config the project setting or something else??(Stop the perform registration action?)
|
|
|
|
|
|
Hi!
I have dynamically created a CButton. How can I remove it totally (i mean it should not be visible anymore).
|
|
|
|
|
Example
CButton *m_Button;
m_Button=new (CButton);
m_Button->Create("Butotn1",WS_CHILD|WS_VISIBLE|BS_NOTIFY,CRect(0,0,100,20),this,IDC_BUTTON1);
m_Button->DestroyWindow();
|
|
|
|
|
Not sure but try
pButton->DestroyWindow()
and then
delete pButton;
should work
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
a CloseWindow() will take it off from screen.
VuNic
|
|
|
|
|
another option that you can try is
MoveWindow(0,0,0,0);
this moves the window showing the same effect as if closing it.
Vision is Always important and so is your ATTITUDE.
Wishes.
Anshuman Dandekar
|
|
|
|
|
this is howful solution, as it doesn't actually deletes the button but reduces its size to 0x0...
do you expect to have a 250Mo dialog box which only has 3 controls on it ?!
|
|
|
|
|
hi all
i m using visuat stdio.net 2003 and mfc based applicaation.
following error occur in my application
debug assertion failed at atlsmptr.h at line 472
Expression (iChar>=0 && iChar <=GetLength())
it gives this error when i reach at this line marked by * during the debugging/executing.
asc=(int)m_strBarcodeValues[index].GetAt(1); * this line give error
where CString m_strBarcodeValues[91];
m_strBarcodeValues[32]=_T("011000100");//spacebar
asc=(int)m_strBarcodeValues[index].GetAt(0); works fine for this line
ddd
|
|
|
|
|
tasleem143 wrote: (iChar>=0 && iChar <=GetLength())
Means that either you are requesting a char at a position which is less than 0 or greater than the maximun length of the string itself, post the actual code then we will know more
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
thanks for reply
actually i was not calling the function that that used to initilze that particular cstring array. thanks once again.
ddd
|
|
|
|
|
Hello Tasleem
I am not getting y u r using an array of CString.
just declare an object of it as
CString str;
for (int i=0; i < somecondition ; ++i)
str.SetAt(i, somevalue);
I hope u got it.;)
By the way r u from Poona college.
|
|
|
|
|
thanks for the reply.
no yar i had not seen poona even in my dreams. i m from islamabd, pakistan.
ddd
|
|
|
|
|
Hello
I need some help with compiling some code. I need this for my class, and my C++ client isnt being to good to me.
I'm using MS Visual Studio 6.0
Visual C++ 6.0
And I'm trying to compile a bunch of data out to a text file. I can build the exe, but i cant run it (obviously). This error comes up:
"Cannot compile the file 'xxxxOUTPUT DIRECTORY.txt'; no compile tool is associated with the file extension."
Is there anything I can download, or any setting I can change? I'm really tight for time here, I got so much more to do and I'm stuck trying to fix this!
Any help is greatly appriciated!
Thanks
|
|
|
|
|
roborappa69 wrote: Is there anything I can download
Yep download some brain
but seriously man, that didn't make any sense
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
Come on man. I'm in high school and this thing is due in one week, and I got alot to get through. I'm asking why does this error come up when I need to compile to a text file?
My textbook shows it printing to an output as a txt file. And When I go and hit Build to "Text1.txt" it comes up with that error.
Is there any tool I can download to associate the compiler with the txt extension, or is there any settings I can change to associate it?
Whats so complicated about that?
|
|
|
|
|
Create a simple ATL project(dll),and then insert a simple ATL object into it!
Then add IShellExtInit and IContextMenu interface and associated functions, if you use the VC6(sp5) for compile, it work fine, but i use the VS.NET 2005, and it can't even compile, the errors are:
d:\workshop\Format.h(36) : error C2787: 'IContextMenu' : no GUID has been associated with this object
d:\workshop\Format.h(36) : error C2440: 'initializing' : cannot convert from 'DWORD_PTR' to 'const IID *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
d:\workshop\Format.h(36) : error C2440: 'initializing' : cannot convert from 'ATL::_ATL_CREATORARGFUNC (__cdecl *)' to 'DWORD_PTR' There is no context in which this conversion is possible
What should i do to fix this problem?
Tomorrow may be not exciting, but the exciting tomorrow surely will come.
|
|
|
|
|
VC6 and VS2005 are not compatiple
if you create a project in VS6 then it may or may not compile in VS2005 as the VS6 compiler was not "standards compliant"
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|