|
|
baerten wrote:
[...]
Now, i need to send a message from the Grid to the View with a parameter.
I think you can send simple parameters using the third and fourth parameters of PostMessage function. For example:
GetParent()-> PostMessage(WM_COMMAND, WM_GRID_DOWN, (WPARAM)1234, (LPARAM)5678);
In case of longer data, try dynamic allocation:
MyData * data = new MyData(. . .);
GetParent()-> PostMessage(WM_COMMAND, WM_GRID_DOWN, 0, (LPARAM)data);
In this case the receiver should delete the data using delete . Alternatively use SendMessage :
MyData data(. . .);
GetParent()->SendMessage(WM_COMMAND, WM_GRID_DOWN, 0, (LPARAM)&data);
I hope this helps.
|
|
|
|
|
It works already,
thanks nevertheless
|
|
|
|
|
As Roger indicated, you should read the article by Joseph M. Newcomer. By relying on WM_APP or WM_USER, you run the risk of clashing (trust me when I say it happens all too easy when you start using a number of user defined messages )
Message Management[^]
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
Hi,
I have four threads in my application and want to show some log messages from each of them into a common list box owned by application.
I want that
Thread#1 always show its log message into row #1 of listbox
Thread#2 always show its log message into row #2 of listbox
Thread#3 always show its log message into row #3 of listbox
and so on ...
Is it possible, if yes then how, and if no then what could be the alternate way.
Waiting for your replies.
Best regards.
Cyber Friend
|
|
|
|
|
Cyber Friend wrote: Is it possible
Yes.
Cyber Friend wrote: if yes then how
Not that easy. Better would be to have one list box for each thread, living near each other. That way you do not have to mess up with columns.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
Rage wrote: Not that easy. Better would be to have one list box for each thread, living near each other. That way you do not have to mess up with columns.
Not that easy neither: you cannot update the listbox from another thread. You better send a message to the GUI thread with the string in it. Otherwise, you'll have problems.
|
|
|
|
|
Cedric Moonen wrote: you cannot update the listbox from another thread
Never said you can ! I just realized that he was actually asking for synchronization help rather than simply listbox handling.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
Have each thread Post a WM_USER* message to the main thread. Trap this message and update the list accordingly.
|
|
|
|
|
Hi,
Thanx for reply.
I will try this method.
Best regards.
Cyber Friend
|
|
|
|
|
Have each secondary thread post a message to the primary thread. In that message, set WPARAM to a value indicating which thread the message is from. That way, you can call InsertString() with an appropriate index value.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
« Programm3r » wrote: char strDest[100];
Try a ZeroMemory on strDest before using it.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
Thank you Rage, It seems to have done the job...
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Pasted from MSDN:
"The strncpy function copies the initial count characters of strSource to strDest and returns strDest. If count is less than or equal to the length of strSource, a null character is not appended automatically to the copied string."
You have to terminate the string yourself.
Rage suggested one way to it to be absolutely sure. Another way is to place a '\0' at the correct position, i.e. at the end of the string if you know where that is.
--
Roger
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"No one remembers a coward!" - Jan Elfström 1998 "...but everyone remembers an idiot!" - my lawyer 2005 when heard of Jan's saying above
|
|
|
|
|
Thank you Roger, the qoute form MSDN makes perferct sense now
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Take the function void foo(unsigned char * param) . It does not change the value of the string (it's a Win32 API function, don't ask me why it's not const). Now i'd like to pass it the value of std::string MyString . I do this liek that
foo(reinterpret_cast<unsigned char *>(MyString.c_str()));
but this can hardly be the recommended way (it works, but it's bad). Any suggestions anyone ?
|
|
|
|
|
why not the simple static_cast ?
i can't see anything wrong otherwise...
|
|
|
|
|
static_cast gives a compiler error:
error C2440: 'static_cast' : cannot convert from 'const char *' to 'unsigned char *'
|
|
|
|
|
hum, yes, that's right (i have no compiler with me at the moment...).
does it work without any explicit cast ?
|
|
|
|
|
You cannot cast a 'const' value to a 'non-const' because that's the whole point of the 'const' keyword.
In this case you have to make a copy of the string and provide the second function with the copy.
--
Roger
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"No one remembers a coward!" - Jan Elfström 1998 "...but everyone remembers an idiot!" - my lawyer 2005 when heard of Jan's saying above
|
|
|
|
|
You want const_cast.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Dear All,
How can i read a binary data from the registry ?
Thanks.
|
|
|
|
|
There's articles and classes on this site, and all over the web, which answer this question.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|