|
|
What version of compiler you using? What kind of project is it? What is the error that you are getting?
|
|
|
|
|
Microsoft Visual Studio 2005
Version 8.0.50727.42 (RTM.050727-4200)
Microsoft .NET Framework
Version 2.0.50727
Installed Edition: Professional
Microsoft Visual C++ 2005 77626-009-0000007-41598
Microsoft Visual C++ 2005
Project:
Dialog window made with MFC Application Wizzard. I added only: 1 button to main window, create 1 dialog and call it as Modal window tih this botton.
|
|
|
|
|
As Christian pointed out, it is entirely possible that you need to give him the runtime libraries. For your version of VC it will be the msvc*80.dlls. There should only be a couple of them.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
|
|
|
|
|
If he has XP, it could be a problem related to a missing manifest file ? If you linked statically to MFC, it's probably the C run time that you're using and need to distribute. What version of VC are you using ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I believe the problem is solved. I made the same project from the begining, now using Static Library. I don't know why it did't work last time. Maybe I should delete previous bild .exe file. Anyway... thans for your time and help.
|
|
|
|
|
Hi. I've this problem: A thread is waiting on a semaphore handle with WaitForSingleObject. Another threads closes the semaphora handle with CloseHandle. The problem is that the wait doesn't release the thread...the timeout is INFINITE, so it stays there. Is this possible? Is there any way to tell the wait family functions to return an error (or at least to return) if this situation occurs?
I would really apprecciate any hint about this problem.
Thanks in advance,
Federico
|
|
|
|
|
Only the Mutex has a condition that occurs when the handle is deleted. Other synchronization handles assume you are being a good citizen. The solution is to add a shutdown event and do a WaitForMultipleObjects .
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
If the semaphore handle is being Create/Open-ed once, then you should get an error condition from WaitForSingleObject(), like WAIT_ABANDONED. It certainly works this way for Events. This assumes that the handle is created in one thread, and directly passed to another, rather than one thread using CreateXXXX and the other using OpenXXXX.
Steve S
Developer for hire
|
|
|
|
|
This one is a first for me.
"The value of ESP was not properly saved across a function call"
It's happening on a timer callback function I have placed in a base class, and it only occurs when I declare the non-static member as virtual. Here is the code
void *CSpecialFx::thisPtr;
CSpecialFx::CSpecialFx()
{
thisPtr = this;
uTimerId = SetTimer(0,0,30,(TIMERPROC)StaticProc);
}
CSpecialFx::~CSpecialFx()
{
KillTimer(0,uTimerId);
}
VOID CALLBACK CSpecialFx::TimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime)
{
static int i = 0;
i++;
}
VOID CALLBACK CSpecialFx::StaticProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime)
{
CSpecialFx *tmp = (CSpecialFx*)thisPtr;
tmp->TimerProc(hwnd,uMsg,idEvent,dwTime);
}
The code runs for a few seconds, but it never steps into the virtual callback. The error also goes on to mention the calling conventions being a probable cause. What did I miss?
|
|
|
|
|
Can you show the class declaration? Which function is static? which is virtual? I can probably assume which is which but just to be sure.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Sure
class CSpecialFx
{
public:
CSpecialFx();
virtual ~CSpecialFx();
protected:
virtual VOID CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime);
private:
static VOID CALLBACK StaticProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime);
static void *thisPtr;
UINT uTimerId;
};
|
|
|
|
|
I think maybe I have solved it. The object was declared within the scope of a function, so I have a feeling it was goind out of scope. I declared it as static and it seems to be working fine.
|
|
|
|
|
In your destructor be sure to set the thisPtr to NULL, and in the StaticProc be sure to check for NULL. If you don't you could run into problems if you have multiple instances of your class active.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
thanks for the heads up. I'm really bad when it comes to error checking, well bad or just plain lazy...
|
|
|
|
|
PJ Arends wrote: In your destructor be sure to set the thisPtr to NULL, and in the StaticProc be sure to check for NULL. If you don't you could run into problems if you have multiple instances of your class active.
He won't be able to have multiple instances of this object. What he has is a hacked-up singleton (which I don't think is what he wants).
I can't test this at the moment, but I believe if you pass SetTimer your member function as &CMyClass::MyTimerFunc it will avoid the need to make it static.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Does this help?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello,
I was trying to add a child window to another window that is not running with the same application instance. I used enumWindows to find the window I was looking for and then used createWindowEx to create the child window specifying the window handler that was found as the parent. It didn't work.
Is this possible?
thanks.
|
|
|
|
|
You said it didn't work what did you get error or a null handle.
|
|
|
|
|
I'm new in ATL control programming, I did write some ActiveX Controls, so I started with ATL Controls project intuitively, and I start find some problems.
Ie:
I'm developing an ATL Control with MFC support and a Composite Control.
Then I put a button and I write code for OnButton like that:
<br />
LRESULT OnClickedButton1(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)<br />
{<br />
AfxMessageBox("Hello");<br />
return 0;<br />
}<br />
That work fine using the control in a VB application.
But if I add a Dialog class and handle the OnButton1 in the CDialog class, the button do nothing when it's pressed in a VB application.
I know, I miss something to tell the control that the handle is in the Dialog class, but what?
I need the dialog class because I will have more controls there and members variables and more handles for every control.
I would really appreciate any help, meanwhile I'm going to read some ATL articles.
Thank you.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
hi
need a little help as new to c++.
when i run the code below to save the names to a text file and then output the names back to the console application i have all the names together with no spaces.
eg: markjohnpeterjames
what i need to know is there a way to output the data from the txt file to the console but with spaces between the names ( or if you can play around with the output format in general ) or is it possible to save them to the text file in a particular format ?????
This one has me stuck !!!!!
Plus any sugestions for improvements on the code below will be much appreciated.
char xx [20];
ofstream fout;
fout.open("c:/out.txt", ios::app);
cout<< "Please enter your first name: \t";
cin>> xx;
fout<< xx;
// close file
fout.close();
char yy;
ifstream myfile("c:/out.txt");
cout<< "\nAll names entered on file: \t";
while (!myfile.eof())
{
myfile>> yy;
cout<< yy;
}
Thanks in advance !!!!
The problem with political jokes is they get elected.
|
|
|
|
|
When wring the file, write the name in either of the following ways:
fout << name << endl;
four << name << " ";
For print the file to the screen:
#include <iterator>
#include <algorithm>
#include <vector>
#include <string>
vector<string> names;
copy(istream_iterator<string>(myFile), istream_iterator<string>(), back_inserter(names));
copy(names.begin(), names.end(), ostream_iterator<string>(cout, "\n"));
Note that depending on the version of your compiler/STL library, it may or may not have overrides for reading string types in this manner, in which case you would need to switch it to a vector of character buffers of some size.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hi Zac
The input and output format issues are working ok now thanks, but one small issue and i dont know why its happening.
The last name that i enter is saved to the text file no problems but is always printed twice on the console application after the program is run ????? ( only saved once on the text file!!!! )
eg:
mark
peter
james
james
Any suggestions why this might be the case.
Sorry for the hassle.
The problem with political jokes is they get elected.
|
|
|
|
|
What does your code look like exactly?
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
char xx [20];
ofstream fout;
fout.open("c:/out.txt", ios::app);
cout<< "Please enter your first name: \t";
cin>> xx;
fout<< xx << endl;
fout.close();
char yy[100];
ifstream myfile("c:/out.txt");
cout<< "\nAll names entered on file: \t";
while (!myfile.eof())
{
myfile.getline(yy,100,'n');
cout << yy;
}
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|