|
Hi:
I have recently created a "Win32 Application" project or, more accurately "A Simple Win32 Application".
but i need to use a Worker-Thread in this app so i used AfxBeginThread()
function,but when i want to compile project,i receive the following error:
error C2065: 'AfxBeginThread' : undeclared identifier
Am i doing somethimg wrong? or Is it possible to use this function in
Win32 Application ?
Please Help me.
Best Regards.
|
|
|
|
|
AfxBeginThread() is a method of CWnd , which is only available if you create an MFC application. Use CreateThread() (and related Win32 functions) if you're not using MFC.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
AfxBeginThread() is a method of CWnd
No, but of MFC.
Ravi Bhavnani wrote:
Use CreateThread() (and related Win32 functions) if you're not using MFC.
But preferably _beginthreadex() from the C runtime.
--
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. (Douglas Adams)
|
|
|
|
|
Johann Gerell wrote:
No, but of MFC.
Ooops, you're so right!
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I am using a Listview-based window for an application, in which the List ctrl takes up the whole window. I would actually like to put other controls above the ListCtrl portion, but am not sure how to do this. The ListView creates the controls itself, i.e. there is not a resource that I can play with. Is there some place I can adjust and add things to this?
[I am actually using the code from the sample rowlist app that Microsoft supplies. This subclasses CListViewEx from CListView)
|
|
|
|
|
Derive your view class from CFormView instead and add the list control (and other controls) to the view's dialog resource.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Thanks for the response.
I know I could do that, but I would lose all the added functionality of the CListViewEx class, which is why I wanted to use it in the first place.
Tel
|
|
|
|
|
Hi, everyone!
I meet with troubles when reading integers from a file.
Such is my output and source code. I want to know why
the last character can not be read.
Can anyone help?
Output:
--------
10
Error!
--------
Source Code:
--------
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
int a, b;
char space;
ifstream ifs ("c:\\test.txt"); //10 and 100 in this file
istream is = ifs;
is.exceptions (ios::failbit|ios::eofbit);
if (is.good())
{
try {
is >> a;
cout << a << endl;
is >> b;
cout << b << endl;
}catch (ios::failure e)
{
cout << "Error! " << endl;
}
}
return 1;
}
--------
Thanks in advance,
George
|
|
|
|
|
George2 wrote:
I want to know why
the last character can not be read.
Try this, I am not sure what your problem is, however if there isn't a space between the 10 and 100 the int a will store the whole value of 10100 as one value:
#include <fstream.h>
void main()
{
int a, b;
ifstream infile("C:\\test.txt");
if(infile)
{
while(!infile.eof())
{
infile >> a;
infile >> b;
cout << "A: " << a << endl;
cout << "B: " << b << endl;
}
}
}
-Nick Parker
|
|
|
|
|
Thanks, Nick buddy!
I have tried your sample code and it works correct.
But I think my sample code is the same as yours. Why
my sample code is not working? I simply want to use
exception handle machanism in my case.
Can you help?
regards,
George
|
|
|
|
|
Hi, everyone!
When using vector.push_back method, we just copy an object
an not a reference. I think sometimes it is a waste. Am I
correct? I want to know how to let the vector to store
a reference.
Such is my sample code which can verify vector store copied
object and not reference.
Source Code:
--------
#include <vector>
#include <iostream>
using namespace std;
class A {
public:
int a;
};
int main()
{
A a;
a.a = 10;
vector<A> vc;
vc.push_back (a);
A b;
vector<A>::const_iterator i = vc.begin();
for (; i < vc.end(); i++)
{
b = *i;
b.a = 100;
}
cout << a.a << endl; //output is 10
return 1;
}
--------
So, how to let vector to store reference?
Thanks in advance,
George
|
|
|
|
|
George2 wrote:
So, how to let vector to store reference?
You can just create a vector containing pointers to object A:
A a, b, c;
vector<A*> vect;
vect.push_back(&a);
vect.push_back(&b);
vect.push_back(&c);
-Nick Parker
|
|
|
|
|
Thanks Nick buddy!
Are there some way to store reference directly?
You know, pointers often make troubles.
Thanks in advance,
George
|
|
|
|
|
George2 wrote:
Are there some way to store reference directly?
be careful here George. References can also be translated as an "alias", and may at times (with certain optimization) take up no space at all. What I am saying is there may be times when you use references the wrong way and things work in the debug mode (because the debugger assignes a 0 or NULL to a pointer), but in release mode you start to see troubles. Anyway, I don't want to get into too much detail, just make sure you use them properly.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Thanks, Nitron buddy!
Can you give me some materials to reference?
regards,
George
|
|
|
|
|
You can have a look at my article on pointers[^] for a start. In this article, I try to explain the concept of pointers and references from a physical memory-level standpoint while attempting to cut through all the non-pertinant information.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
I have a problem with Macros in Visual C++.
I want to write a more Detailed ErrorMessage Class, which gives me a part of sourcecode where the Error occurs.
There are some predefined Macros which will help me to that:
Current File: __FILE__
and Current Line: __LINE__
but I did not find a Macro for Current Call. So I want to make it my self.
#define __CALL__ "void myFunction(int value);"
void myFunction(int value)
{
printf("current Call is %s", __CALL__);
}
but problem is that I have to redo this procedure on every Function with additional undef:
#ifdef __CALL__
#undef __CALL__
#endif
#define __CALL__ "void myNextFunction(int value);"
So, I want to reduce manual work by autmating the following code:
#ifdef __CALL__
#undef __CALL__
#endif
#define __CALL__ "void myFunction(int value);"
so i want to do something like this (multiple Preprocessorcalls in one Macro:
#define SETFUNCTION(x) #ifdef __CALL__ #undef __CALL__ #endif #define __CALL__ x
But it all seems not to work or it is a hard handwork to insert this long code before each function.
So here are my Questions:
1. Is there any possibility to get easier more detailed Debug Information? (like current Function call)
2. Is there any way to make a Macro of Macros ? (like #define def(x) #ifndef x #define x #endif)
Thank you ,
Sendel
|
|
|
|
|
Putting the macro before the function definition will not work anyway, because the preprocessor will pass through the file first and keep #defining and #undefining SETFUNCTION, and finally SETFUNTION will only be the last function it processed. I thought of a macro like this:
#define SETFUNCTION(x) TCHAR __CALL__[] = _T(#x)
Put this as the first statement in all your functions, like this for example:
void myFunction(int value)
{
SETFUNCTION(myFunction);
...
}
and now __CALL__ will simply be a string locally declared within each function. Hope that helps.
|
|
|
|
|
Actually, putting the macro before the function may work, I'm not sure. Either way, putting a statement at the start of each function seems like a lot of work to me, but I can't think of a better way.
|
|
|
|
|
I want to display a text file into a view derived from CScrollView
how to display the file?
thanks!
|
|
|
|
|
|
How can I skip from one workspace to another?
For example, <ctrl+tab> for skipping between files, <alt+tab> for skipping between applications (win 98).
|
|
|
|
|
hello my name is Mario Young i'm from Colombia and i like C++
|
|
|
|
|
Welcome!
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
Mario_Young wrote:
hello my name is Mario Young i'm from Colombia and i like C++
Hi Mario,
For non-programming questions you might wanna check out the Lounge :-
The Lounge
Welcome to CP anyway
Nish
"I'm a bit bored at the moment so I'm thinking about writing a new programming language" - Colin Davies
My book :- Summer Love and Some more Cricket [New Win]
Review by Shog9 Click here for review[NW]
|
|
|
|