CListBox
-
By the way, two remarks: 1) How does this code even compile ? How can you access your m_listba variable from your thread ? Is it a global variable X| ? 2) What's the purpose of doing that in a thread if you call WaitForSingleObject just afterwards anyway ? :doh:
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++ -
The simple answer is: you don't. You should never access UI elements from a different thread than the UI thread. If you have to do such a thing, rethink your design. A better option would be to "generate" your data in the thread and then send a user defined message to your window telling it to refresh itself. When receiving the message, your window will then fetch the data and add it to the list control. I think this article[^] will help you a lot for threading.
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++Cedric Moonen is right,it's better that UI put in the UI thread.generate data in other thread. :-D
-
(I'm gonna reply to your original message that you deleted)
MsmVc wrote:
Plz help me
Help yourself and read the article I linked to you. Threading is not a simple subject that can be explained in 3 lines. If you want to use multithreading and understand what you are doing, then you'll need to spend a bit more time than asking a question on a forum.
MsmVc wrote
Yes m_listba is global variable.
That's really ugly, you should make it a member of your dialog class. You can't access it from your thread so why making it a global varialbe ? And by the way, the "m_" suffix is usually applied to class member variables (m for member). If you use it on a global variable, it is totally confusing.
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++ -
Davitor wrote:
yaa m_listba is global
To fool the enemy? :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
(I'm gonna reply to your original message that you deleted)
MsmVc wrote:
Plz help me
Help yourself and read the article I linked to you. Threading is not a simple subject that can be explained in 3 lines. If you want to use multithreading and understand what you are doing, then you'll need to spend a bit more time than asking a question on a forum.
MsmVc wrote
Yes m_listba is global variable.
That's really ugly, you should make it a member of your dialog class. You can't access it from your thread so why making it a global varialbe ? And by the way, the "m_" suffix is usually applied to class member variables (m for member). If you use it on a global variable, it is totally confusing.
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++ -
Then your code cannot compile (unless I missed something or you didn't post everything). Anyway, we can discuss the whole day about minor details as this, it still won't make your code work because you can't access UI elements (like the list box) from a separate thread. Serioulsy, I have the impression to talk to a wall here :sigh: ... Did you read that damn article finally ?
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++ -
Then your code cannot compile (unless I missed something or you didn't post everything). Anyway, we can discuss the whole day about minor details as this, it still won't make your code work because you can't access UI elements (like the list box) from a separate thread. Serioulsy, I have the impression to talk to a wall here :sigh: ... Did you read that damn article finally ?
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++yaa i read it.My problem is that i have a file which have a somany data and i want to insertdata into ListBox through thread.I am useing thread becouse without thread my Dialog is showing Not responding. I read article which is given by you.But i need some example to do that.Plz help me
modified on Friday, March 27, 2009 5:28 AM
-
yaa i read it.My problem is that i have a file which have a somany data and i want to insertdata into ListBox through thread.I am useing thread becouse without thread my Dialog is showing Not responding. I read article which is given by you.But i need some example to do that.Plz help me
modified on Friday, March 27, 2009 5:28 AM
The worker thread shouldn't directly manipulate the
GUI
. It should instead post a message to theGUI
thread, with in turns updates theGUI
. It's not difficult, instead of callingInsertString
from within the thread, callPostMessage
with appropriate data. On receiving the message, theGUI
thread will callInsertString
. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
yaa i read it.My problem is that i have a file which have a somany data and i want to insertdata into ListBox through thread.I am useing thread becouse without thread my Dialog is showing Not responding. I read article which is given by you.But i need some example to do that.Plz help me
modified on Friday, March 27, 2009 5:28 AM
The basic issue is that you're a retard. You've had explained to you why you can't do it, the framework it throwing exceptions, because you can't do it, and you're still trying to do it. Perhaps you should learn VB, or even Logo ?
Christian Graus Driven to the arms of OSX by Vista.
-
The worker thread shouldn't directly manipulate the
GUI
. It should instead post a message to theGUI
thread, with in turns updates theGUI
. It's not difficult, instead of callingInsertString
from within the thread, callPostMessage
with appropriate data. On receiving the message, theGUI
thread will callInsertString
. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]The point is that everything is explained in the article, with an example and everything. And the example is about a list box being "populated" from a worker thread (through a message sent to the UI). So, I think this is a lost cause :sigh:
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++ -
The basic issue is that you're a retard. You've had explained to you why you can't do it, the framework it throwing exceptions, because you can't do it, and you're still trying to do it. Perhaps you should learn VB, or even Logo ?
Christian Graus Driven to the arms of OSX by Vista.
Christian Graus wrote:
Perhaps you should learn VB
I supposed it was already in the '
Retard's Toolbox
'. :-DIf the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
The point is that everything is explained in the article, with an example and everything. And the example is about a list box being "populated" from a worker thread (through a message sent to the UI). So, I think this is a lost cause :sigh:
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++