|
Declare ThreadFunc() as static .
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Do you know of any way to get around the static function requirement? It's kind of a pain, because now I can't access other data members that aren't static.
Mike Ellertson
|
|
|
|
|
Mike Ellertson wrote:
Do you know of any way to get around the static function requirement?
No, not for threads.
Mike Ellertson wrote:
I can't access other data members that aren't static.
The CreateThread() accepts an lParam value that is passed to the ThreadProc() function. Pass a pointer to the thread object, and then you can access the non-static members through this pointer. You can simply call a non-static function to do all the work if you want to:
class ThreadClass
{
public:
static LRESULT CALLBACK ThreadProc(LPARAM lParam)
{
ThreadClass *pThread = (ThreadClass*)lParam;
return pThread->NonStaticThreadProc();
}
LRESULT NonStaticThreadProc()
{
return 0;
}
};
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Wow.. Thank you very much
Kuniva
--------------------------------------------
|
|
|
|
|
You're welcome
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
|
void Bla(Foo foo) ->
You cannot modify the parameter foo directly, only a copy of its value will be passed.
void Bla(Foo *foo) ->
You can modify the address pointed to by foo with foo = 0x045345 or change the value with *foo = 123 .
Make sure foo does not point to a NULL reference.
void Bla(Foo& foo) ->
Value passed by reference, you can change the value simply with foo = 123
regards
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanx
Greg S. wrote:
You can modify the address pointed to by foo with
I tend to differ... EG
void Bla(Foo* foo)<br />
{<br />
foo->a = 99;<br />
foo = NULL;<br />
}
foo.a == 99 after method, not NULL.
Greg S. wrote:
void Bla(Foo& foo)
->
Value passed by reference, you can change the value simply with foo = 123
The compiler wont even let me define the method. Is this a C++ specific operator? BTW I'm only (allowed to) use C, not C++.
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
|
void BlaP(Foo *foo);
void BlaR(Foo& foo);
Is the difference merely "syntax" or are references somehow better than pointers? (I mean if you are dealing with one object, not an array of course!)
<marquee behavior="alternate">Hosam Aly Mahmoud
|
|
|
|
|
References are not nessecairily better then pointers, it just depends on what you want to do! Using a pointer gives you the option to pass NULL (or use it as a default parameter)! On the other hand, when you don't want to change the contents of the object (making it constant) it's a lot easier with a reference!
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Thanks for your reply. I agree with you in that its use is much more obvious. Also, the ability to pass NULL in pointers would have uses somewhere.
I have heard one of my friends saying that references take two bytes in memory, whereas pointers take four. Is this true? And if it is, would this allow for faster processing?
Thank you for your time.
Hosam Aly Mahmoud
|
|
|
|
|
Hosam Aly Mahmoud wrote:
I have heard one of my friends saying that references take two bytes in memory, whereas pointers take four. Is this true?
No. References take the same amount of memory as pointers.
References are generally safer than pointers because they are gauranteed to point to something, and they are type-safe (they can't be cast to references of incompatible types).
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
What can I say? Thank you again Ryan!
Hosam Aly Mahmoud
|
|
|
|
|
You're welcome
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Your welcome
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
I have a report (and a partial fix) from one of the guys who helps out on my VCF project, that when using EM_SETSEL/EM_GETSEL message, multiple lines broken by \r\n do not get handled correctly. Apparently the \r characters are not taken into consideration and the selection is screwed up. Has anyone else run into this? Is there a simple solution to handling this?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|
|
I met this problem, and my solution is that I assumed there is no \r in the string, when processing EM_GETSEL message, but if I need \r, I can get string by invoking CEdit::GetWindowText(CString).
|
|
|
|
|
Jim Crafton wrote:
...multiple lines broken by \r\n do not get handled correctly. Apparently the \r characters are not taken into consideration and the selection is screwed up.
Which means what exactly? I've not yet seen the \r\n pair cause unknown problems.
|
|
|
|
|
Hi everyone. I have a problem concerning vectors. I have a function in which I fill a vector of an object with data. This object consists of char*, long etc variables and a number of set and get methods for setting and retrieving the data. The function returns the vector. Inside the vector I see the data correctly by printing them, but with the returning vector I cannot see them correctly.
As parameters to the object (the set methods) I pass CString objects which I convert to char* with (char*)(LPCTSTR)variable.
Does anyone know what is wrong?
When I call the method I assign the returning vector into a new one which I construct at the time of the function call as: vector<object> e = class_object.method(); and then navigate through the vector.
|
|
|
|
|
i know that question was posted some weeks ago or so... but i didn't find it anymore
i want to code a module, which is able to load a dll with a exported c++ class!
how to do that?
GetProcAddress wouldn't make any sense, because of the c++ names, and how do i set the addresses of class member functions?
any suggestions?
thx
Don't try it, just do it!
|
|
|
|
|
|
i dont want to export function... i want to import them... like the half-life engine does it with the mod dlls!
Don't try it, just do it!
|
|
|
|
|
How would I get the F-lock to show in the status bar.
I have a microsoft keyboard so it has one of those F-lock keys.
Any help please, I use Visual C++ 6.
[It is possible to represent everything in this universe by using 0 and 1]
I'm going to live forever or die trying.
|
|
|
|
|
Hi,
I have asked questions related to this problem before, but as I may be approaching the whole problem from the wrong direction, I am hoping that I might be able to get some suggestions that will shed a new light upon it.
I am writing a file protection program (third-party) for a hobbyist game engine (though in theory it could protect any program with a number of external files). A game consists of an executable, model files, bitmap files and even script files, without protection all of which can be opened up by anyone who has the game. I would like to protect these files in such a way that nobody can access them. Currently I pack the game files in a protected ZLIB archive (using the ZipArchive library from www.artpol-software.com, and use a launcher to extract the files to a temporary folder whenever the game is started and delete them when it ends. This, of course, is hardly a solution, as all somebody has to do to access the files is alt-tab during gameplay and search for them.
Incidentally, please don't tell me not to protect the files at all. I know that there are arguments for not protecting the files - however, the versions of the engine I am writing this for have no modding capabilities, so there's no reason for a player to have access to them. More importantly, the chief concern of the hobbyist developers who will hopefully use my app is to protect their hard work from each other, as it's an unfortunate fact of life that in an online hobbyist community where many demos are posted, there will always be leeches who steal work and present it as their own if it's made easy for them...
So my question is: does anybody have any killer suggestions on how I can effectively protect these files?
My app uses the Windows API with *no* MFC, btw.
Any help/suggestions would be really appreciated.
Many thanks,
KB
|
|
|
|