|
---Mark--- wrote:
What if I want to wait for user input?
You don't have to do anything special to wait for user input. cin >> foo won't complete until the user presses Enter.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Maybe that was confusing. I didn't mean actual input like a number or character, I meant to wait for the user to acknowledge that what is being displayed on the console has been read and the program can progress or end. In that case is the way I mentioned a good way to do that or are there better?
Thanks
-Mark
We're sorry, we were unable to complete you request. The website administrator has been automatically notified.
REFRESH? ¥492077616E74206120726566756E6400¥
|
|
|
|
|
Ah, gotcha.
I don't know you'd do that in a console program without resorting to assembly programming. I did something similar decades ago on a VMS system - my function waited for user input for upto "n" seconds. This kind of stuff is easy to do in a GUI Windows app.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
system() is almost always a bad choice.
--
My name in Katakana is ヨルゲン.
My name in German is Jörgen.
I blog too now[^]
|
|
|
|
|
Where should I write the declaration of gobal variables and functions in MFC?
I found errors in my program:
In my MFC dialog application, I have 2 classes, class A and class B. I write the global variables in the cpp file of class A, i.e. A.cpp, and the class view has shown them as global. However, I cannot access them in class B. Why is this so?
If I want to declare variables and functions that can be used by all classes, where should I write the declaration?
Thanks
|
|
|
|
|
hi friend
if you declare it as the follwing:
int x;
<br />
class A{<br />
...<br />
};
try to write the following in class B.cpp:
//B.CPP
extern int x;
<br />
class B{<br />
...<br />
}
I hope this works
|
|
|
|
|
Dear Friend,
I think you cannot access a global variable outside its class directly.
Suppose your variable is declared in class 'A'.
To access it in class 'B', you should create an object of class 'A' in class 'B'. Now you can access the variable using this object.
|
|
|
|
|
For functions that you want to use globally, put their declaration in a header file and include the header file wherever you want to use the function.
For variables, you have to declare it outside the scope of a class in one file. In all other files, you have to declare it as extern. For eg.
File1.cpp
int x;
class SomeClass {...};
File2.cpp
extern int x;
// Your code here.
The extern keyword tells the compiler that the variable is defined in some other file. In fact, if you forget to define it in File1.cpp, you'll get a linker error, not a compiler error.
Regards
Senthil
|
|
|
|
|
|
|
You are right, _bstr_t instead of CComBstr helped in throwing exception, now each of put_* methods works fine, thx.
But href has still wrong value ;-(. Perhaps there are another way to set default document ;-(
Luda
|
|
|
|
|
|
Hi.
I'm developing a program that instantiates a COM executable.
In my machine the problem doesn't occur, but in the machine of a colleague we have this problem. The source code are the same, without any modification. We are using Visual C++ 6.0 SP5, Win2K and WinXP.
The code below are the code that works in one machine and in another doesn't work.
HRESULT hr;
IUnknown * pXXXXX;
IConnectionPointContainer * pCPC;
IConnectionPoint * pCPIXXXXXEvents;
<br>
pXXXXX = NULL;
pCPIXXXXXEvents = NULL;
pCPC = NULL;
m_pIXXXXXEvents = new CIXXXXXEvents(this);
m_bComError = TRUE;
<br>
hr = CoCreateInstance(CLSID_XXXXX, NULL, CLSCTX_LOCAL_SERVER, IID_IUnknown, (LPVOID*)&pXXXXX);
if (FAILED(hr))
{
pXXXXX = NULL;
OutputDebugString("Failed to create XXXXX COM object");
}
<br>
hr = pXXXXX->QueryInterface(IID_IXXXXX, (LPVOID*)&m_pIXXXXX);
if (FAILED(hr))
{
m_pIXXXXX = NULL;
OutputDebugString("Couldn't QueryInterface for m_pIXXXXX");
}
<br>
hr = pXXXXX->QueryInterface(IID_IConnectionPointContainer, (LPVOID*)&pCPC);
if(FAILED(hr))
{
OutputDebugString("Couldn't QueryInterface for pCPC");
}
<br>
hr = pCPC->FindConnectionPoint(__uuidof(_IXXXXXEvents), &pCPIXXXXXEvents);
if(FAILED(hr))
{
OutputDebugString("Couldn't FindConnectionPoint for pCPIXXXXXEvents");
}
<br>
hr = pCPIXXXXXEvents->Advise(m_pIXXXXXEvents, &ulAdviseSFN);
if(FAILED(hr))
{
:((
OutputDebugString("Couldn't Advise for m_pIXXXXXEvents");
}
Anyone has any idea of what is happening and a suggestion of how to solve it?
Thanks
Dennis
|
|
|
|
|
Hi
I wrote a small program to count how many points are clicked using array. My count array doesnt work even though i wrote the declaration before or in the function itself.
For example:
int count=0;<br />
if((nFlags & MK_LBUTTON) == MK_LBUTTON){<br />
count++<br />
}
and
if((nFlags & MK_LBUTTON) == MK_LBUTTON){<br />
int count;<br />
count++;<br />
}
From what I can see is everytime a left mouse is clicked the array reset itself. The code is inside a OnMouseMove(UINT nFlags CPoint point) class.
Thanks
|
|
|
|
|
jw81 wrote:
int count=0;
if((nFlags & MK_LBUTTON) == MK_LBUTTON){
count++
actaully problem is of Scope of variable count .it is local variable in function.
let see what actually happening in your code-> Every time you click on mouse the count variable created in memory and as function ends, count variable scope end and program release it from memory.
now to solve this problem with either declare it in global or make it local to class which handlling you onmousemove function rather declarign it in function.
"I Think this Will Help"
[Vote One Here,.....]
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
ThatsAlok wrote:
now to solve this problem with either declare it in global or make it local to class which handlling you onmousemove function rather declarign it in function
Or ... let it where it is now, but declare it as static .
By the "lifetime" point of view, global or static is mostly the same.
Declare it as class member will let every calss instance hace its own.
That is: if yor class is used to handle many windows and you want each one to have its own counter, make it a class member.
If you want a same single counter to count everything in all instances, declare it as static . In the function if only that function use it; In the class if many function class use it; globally if you have to access it from everywhere.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
emilio_grv wrote:
: if yor class is used to handle many windows and you want each one to have its own counter, make it a class member.
i think, it just a beginner problem,so i have given beginner answer.
conecpt of static is little complicated for beginner.
"I Think this Will Help"
[Vote One Here,.....]
<h5
alok="" gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
I guess Alok answered my question, thanks.
|
|
|
|
|
Hello,
I don't understand your problem exactly, but if this declaration is inside a funktion, well you declare a variable and reset it to zero, then ++ it.
could you please try using 'static int ... ' instead of your currnt statement? does it solve any problem?
|
|
|
|
|
I think you need to declare the count variable outside this function, eg. declare it as global or class member variable. If you declare in this function, every time you click the mouse, the counter is reset to zero.
|
|
|
|
|
how to write into the serial/parallel/USB port
using VC++6?
thx
|
|
|
|
|
|
up.
Before the main frame is created I want to display splashwindow for 3 seconds. how to do it?
|
|
|
|
|
Add A Splash window Control in your project.
you can find Splash window Control here ->
Project->add to Project->Component and Controls
Select Directory ->Visual C++ Components
and scroll to SplashWnd and insert it into your project.
"I Think this Will Help"
[Vote One Here,.....]
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
hi!!
You can just create a dialog window... and use "BitBlt" to display any bitmap... add a timer control..and after the timer expires... start the app.. hope you fing this useful - V.G
|
|
|
|