|
You need to provide more information. What class is m_Child? Where are you creating it?
If this is on a dialog, you may be missing WS_TABSTOP. If you are inheriting from CStatic
then you will also have issues, as that passed focus to its parent.
You should also look up WM_GETDLGCODE.
etc.
Iain.
|
|
|
|
|
m_Child is my custom window and it derive from CWnd, this is SDI project, m_Chils is member of my view.
|
|
|
|
|
I want to make a program that connects to a hardware circuit through either the printer port or a serial port. I am wondering how I could make my application run in the background until the circuit transmits some data through the port, upon which I should receive and manipulate it. Could you please tell me how to do it in MFC or Win32 API? Thank you very much.
Hosam Aly Mahmoud
|
|
|
|
|
I was once told that u couldnt start a thread from a class function like so:
class MyClass
{
public void ThreadFunc();
}
CreateThread(ThreadFunc,blablabla);
Ok this isnt exact but it should tell u what i mean. But if thats the case, then how did they do this in MFC. There is a class CWinThread, and u can use AfxBeginThread to start a thread like that, so apparently it is creating a thread from a class.... So can i make a class that encapsulates my thread? How?
Thanks.
Kuniva
--------------------------------------------
|
|
|
|
|
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!
|
|
|
|