|
CodingLover wrote: Can someone tel me what's the equivalent
There is no equivalent ISO C++ function available, you will have to write your own.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi all,
I've get a sample code from one of my friends used in word processing application. Written on C++ 6.
I'll try to run it on VS.Net 2003. At compile time I got an error on this.
ifstream fin(lpszPathName, ios::in | ios::nocreate | ios::binary);
Actually I got the error on ios::nocreate
I've never see this identifier for ios base. Can anyone clarify me on this.
Thanks
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Hi.
CodingLover wrote: I've get a sample code from one of my friends used in word processing application. Written on C++ 6.
I'll assume that you meant Visual C++ 6, since there is no "C++ 6"...
CodingLover wrote: Actually I got the error on ios::nocreate
I've never see this identifier for ios base. Can anyone clarify me on this.
Assuming that by "error" you mean a "compiler error"... This has to do more with history of the pre-standard C++ era. Take a look at this[^].
Regards.
Stupidity is an International Association - Enrique Jardiel Poncela
Die deutsche Sprache sollte sanft und ehrfurchtsvoll zu den toten Sprachen abgelegt werden, denn nur die Toten haben die Zeit, diese Sprache zu lernen. - Mark Twain
|
|
|
|
|
Wondering if anyone has encountered this issue:
I put a modeless dialog into one of my apps, which has two controls -- a CAnimateCtrl, and a static text. It's basically a little splash to keep the user happy, while one of my DLLs is doing some lengthy work. I put some text there to tell them what's happening, and a little animation for eye candy.
Doesn't quite work though!
The animation will show, but not play.
Pretty simple stuff, and works if the little dialog is modal, but won't play when modeless, unless I make the dialog visible on startup -- and then it only plays on startup -- not after I call it up with ShowWindow (which calls the Play function).
Everything seems to be in order, so the only thing I can think of, is perhaps there is a threading issue between my main app, and the work the DLL is doing...?
Any ideas...?
Thanx,
Rick
|
|
|
|
|
Does the animation play when you move the mouse over it? If so, then you may need to start a timer to keep the message loop running. Try something like SetTimer(1, 50, NULL); in OnInitDialog().
|
|
|
|
|
Hi Hans,
Tried that -- no go...
Upon further testing, it will work fine, unless I do a call to the DLL. I've even tried pumping the message queue from the DLL during the process, but still doesn't help.
BTW, the function in the DLL, is building image lists to be used in the main app, using a pointer to a CListCtrl in the main app. The function works fine, as the memory is allocated in the main app through a callback.
I think I may have to implement this directly in the DLL -- I'll try that, and see if it works ok there...
|
|
|
|
|
Just in case anybody runs into this issue, I did manage to get it to work, albeit, not the way it should (according to the way the CAnimateCtrl should work).
I can get it to play if:
a) The function in the DLL does not use Begin/End WaitCursor.
b) The DLL function must constantly pump its message queue during processing.
In my case, it was somewhat easy, since I write the DLL, and can tweak it. Not sure what happens if you are using a function from a 3rd party DLL. In that case, you might have to start a worker thread in your app to run the animation properly, as a timer won't do it...
Supposedly, pumping the message queue is expensive, although I use it quite a bit without any issues -- just a simple function:
MSG msg;
while ( PeekMessage ( &msg, NULL, 0, 0, PM_NOREMOVE ))
AfxGetThread()->PumpMessage();
|
|
|
|
|
I'm using CWinFormControl to create instances of .Net UserControls.
CWinFormsControl<myproject::mycontrol xmlns:myproject="#unknown"> m_control;
m_control.CreateManagedControl( WS_CHILD | WS_VISIBLE, rect, this, IDC_HOSTCONTROL );
This works fine. The problem occurs when I try to destroy the control. I need a deterministic call to the 'MyControl' finalizer, so I wrote the following:
m_control.DestroyWindow();
System::GC::Collect();
This code does not cause the Finalize\Dispose code to be called on 'MyControl'. In fact, 'MyControl' sticks around in memory until the MFC app closes. What am I doing wrong here?
Thanks,
Aaron
|
|
|
|
|
tags.
This function destroys variable0 and variable1 upon completion:
void variableCopy0(variable variable0, variable variable1) {
int time0;
variable1.numTimes = variable0.numTimes;
for (time0 = 0; time0 < variable0.numTimes; time0++) {
dateCopy1(variable0.dates[time0], variable1.dates[time0]);
variable1.values[time0] = variable0.values[time0];
};
};
I call it with the following code:
vars = new variable [numVars + maxInterventions + 1];
for (var0 = 0; var0 < numVars + maxInterventions + 1; var0++) {
vars[var0].setUp(inVars[var0].numTimes);
variableCopy0(inVars[var0], vars[var0]);
};
Upon return, vars[var0] and inVars[var0] are also destroyed. I want to keep them. How do I do that. Here's the class definition:
class variable {
public:
double *values;
date *dates;
int time0;
int numTimes;
variable() {
numTimes = -1;
};
variable(int inTimes) {
values = new double [inTimes + 20];
dates = new date [inTimes + 20];
numTimes = inTimes;
};
void setUp(int inTimes) {
values = new double [inTimes + 20];
dates = new date [inTimes + 20];
numTimes = inTimes;
};
~variable() {
delete [] values;
delete [] dates;
cout << "got into variable destructor" << '\n';
};
};
Phred
|
|
|
|
|
try passing by reference
void variableCopy0(variable &variable0, variable &variable1)
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Thank you very much. That worked.
|
|
|
|
|
Fred Andres wrote: This function destroys variable0 and variable1 upon completion:
void variableCopy0(variable variable0, variable variable1)
Yes it does, because the scope of those variables is the function.
The original variables you pass remain unaltered.
You need to pass by reference. Try something like
void variableCopy0(<code>const variable &</code>variable0, variable <code>&</code>variable1) {
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have the following code:
int numAmt;
string preFix;
numAmt = 10;
preFix = numAmt.ToString();
How come I can't convert the intger 10 to string '10' using the ToString function provided by the .NET framwork?
Quecumber256
|
|
|
|
|
|
Quecumber256 wrote: How come I can't convert the intger 10 to string '10' using the ToString function provided by the .NET framwork?
Good question why you can't.
Your C# code works just fine for me.
C# Discussion Board[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
While I was reading some C++ code, I saw a code snippet which declared an object like this:
#include <string>
#include <cassert>
#include "BaseGameEntity.h"
#include "Locations.h"
class State;
class Miner : public BaseGameEntity
{
private:
State* m_pCurrentState;
.....
};
Another way of declaring an object is to include the header file and then declare the object in the class:
#include <string>
#include <cassert>
#include "BaseGameEntity.h"
#include "Locations.h"
#include "State.h"
class Miner : public BaseGameEntity
{
private:
State m_pCurrentState;
.....
};
Yes, in the first code snippet, an object pointer is declared while in the second one, it is a normal object.
Other than that,is there difference between these 2 ways of declaring an object?
When should either method be used?
|
|
|
|
|
KaKa' wrote:
Yes, in the first code snippet, an object pointer is declared while in the second one, it is a normal object.
Other than that,is there difference between these 2 ways of declaring an object?
The first code snippet, you have forward declared the class. So you don't need to include the corresponding header file. If both classes are independent one, it doesn't matter. Both code snippet work well.
Well, it does matter when you have two classes which circular dependency. In that case, your second code snippet won't work. Check out this link[^] for more information. So, in summery, both code snippets are not exactly the same in all conditions.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Thanks alot Jijo......that explains alot
For the second code snippet with the class forward declaration, does this method work if the forward declared class file is located in another directory?
|
|
|
|
|
In MSDN it says:
When the user allocates their own buffer to accommodate OFN_ALLOWMULTISELECT, the buffer cannot be larger than 2048 or else everything gets corrupted (2048 is the maximum size).
So in a Unicode program, do it mean only 1024/MAX_PATH (3 at most) can be opened once?
|
|
|
|
|
|
|
Hi all,
I have web browser object in my dialog, and i run flash advertisement in it.
problem is some of the flash advertisement steal the focus from my dialog, so if i am typing inside an edit box and advertisement is changed, focus is being steal from my edit to the internet explorer server object.....
is there a way to prevent it?
thanks
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
You could try handling the WM_KILLFOCUS message and reset the focus back to your edit control if the browser object was the one that grabbed the focus from the edit control.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
thank you for your reply...
i tried what you said but the problem is that clicking on the advertisemnt should launch a web page
but if i click the advertisement and the kill focus from the edit is called, the focus is set back to the edit and the web page is never launched...
how can i bypass that?
thanks again
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
You should be able to check if the user switched the focus (via the keyboard or mouse) or if the ad window grabbed the focus.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|