|
Surely there must be a harder way!
Mark
|
|
|
|
|
prithaa wrote: How to send/post a message to the parent view window...
By using SendMessage() or PostMessage() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
Yes I am little bit aware of SendMessage/PostMessage by which I can send a message to the parent window but if I want to find a sum of variables or access a variable of the parent window then Can I do it ? or it is impossible.
I should try some other route.
Any ideas
Prithaa.
|
|
|
|
|
prithaa wrote: ...but if I want to find a sum of variables or access a variable of the parent window then Can I do it ?
Certainly. Prior to calling SendMessage() , allocate memory and pass that address to the parent (as LPARAM ). When the parent responds to the message, it simply assigns the appropriate value.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Certainly. Prior to calling SendMessage(), allocate memory and pass that address to the parent (as LPARAM). When the parent responds to the message, it simply assigns the appropriate value.
Can you please tell me something more about "allocate memory and pass that address to the parent (as LPARAM)".
since I am trying to do it but I not able to do it.
I tried SendMessage(WM_COMMAND,LPARAM,WPARAM);
and the parent window got the message and the control went to ON_Command(WPARAM wParam, LPARAM lParam) function of the parent window which was fine
but memory allocation is what I did not understand.
Prithaa
|
|
|
|
|
int *pValue = new int;
GetParent->SendMessage(MY_MESSAGE, 0, (LPARAM) pValue);
delete pValue; In the handler function for MY_MESSAGE :
LRESULT MyParent::OnMyMessage( WPARAM wParam, LPARAM lParam )
{
*(int *) lParam = 123;
return 0;
}
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
Thanks for the code.It was really useful
But can I make Message map of the form MY_MESSAGE and have a handler function OnMyMessage ?
Since message maps are something that are provided by Windows API and they can be generated through Class Wizard where messages and their corresponding functions are already given. Ex WM_KEYDOWN with function OnKeyDown()
Prithaa
|
|
|
|
|
prithaa wrote: But can I make Message map of the form MY_MESSAGE and have a handler function OnMyMessage ?
Yes, but not with ClassWizard. You need to modify BEGIN_MESSAGE_MAP manually, outside of the //}}AFX_MSG_MAP comment.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
prithaa wrote: How to send/post a message to the parent view window
Views should not know about one another. They should communicate to the "Controller" as in Model-View-Controller
In the MFC Framework you can send messages to Views using CDocument::UpdateAllViews(...). If not using MFC you should have your own MVC design.
led mike
|
|
|
|
|
Hi,
What is MVC design?
Thanks
Prithaa
|
|
|
|
|
|
Hello
I´m trying to do this :
A user starts to write his username in an editcontrol, and as he types
Im searching in a database finding any coincidences with other data I have...
If found one i will show it in other editcontrol else I will disable it.
So at what event from the editcontrol should I put my code?
EN_UPDATE ?
EN_CHANGE ?
or this is not the best way..?
thx in advance...
---------------------------------------------
"Don't panic!. All will become clear in time"
WYS Is Not always WYG
|
|
|
|
|
Hi,
I'm not sure what the appropriate events / method is to use but in JavaScript I use onKeyPress and filtering thought the database.
Can't think of anything else....
Hope this might spark something in your brain .... lol ....
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
|
thx
---------------------------------------------
"Don't panic!. All will become clear in time"
WYS Is Not always WYG
|
|
|
|
|
it will work but might not be practical if the search in the DB takes a long time.
user types "a" waits for a few seconds, user types "c" waits for a few seconds, user types backspace because he wanted to type "v" instead, waits a few seconds, user types "v" ...
|
|
|
|
|
Maximilien wrote: it will work but might not be practical if the search in the DB takes a long time.
I agree. That's why I chose EN_CHANGE - at least the user will see the character typed before
it goes off and searches
|
|
|
|
|
can't you try both and see which one fits you best ?
also, reading the MSDN about those events may help !
|
|
|
|
|
Im on it testing both, just wanted to know a better way.
thx
---------------------------------------------
"Don't panic!. All will become clear in time"
WYS Is Not always WYG
|
|
|
|
|
jarleydg wrote: So at what event from the editcontrol should I put my code?
EN_UPDATE ?
EN_CHANGE ?
The former is sent before the control us updated, whereas the latter is sent after.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
how to write the code,if want to make hourglass cursor during process thread function.
|
|
|
|
|
You obviously know that CWaitCursor exists, so what exactly is the problem?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
If your using VS 2005 I would advise the following:
<br />
Namespace: System.Windows.Forms<br />
Assembly: System.Windows.Forms (in system.windows.forms.dll)<br />
<br />
Cursors::Default;<br />
Cursors::Hand;<br />
Cursors::HourGlass;<br />
else try this:
<br />
<br />
void LengthyFunction( )<br />
{<br />
<br />
CWaitCursor wait;
<br />
<br />
}
<br />
<br />
void ConditionalFunction( )<br />
{<br />
if ( SomeCondition )<br />
{<br />
CWaitCursor wait;
<br />
<br />
}
else<br />
{<br />
}<br />
}<br />
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
I try thease code.
it don't work..
void CThread1Dlg::OnOK()
{
AfxBeginThread(Thread,this);
}
UINT Thread(LPVOID pParam)
{
CWaitCursor wait;
CThread1Dlg *m_dlg = (CThread1Dlg*)pParam;
for (int i=0;i<200;i++)
{
Sleep(20);
}
TRACE("Finish");
return TRUE;
}
|
|
|
|
|
Max++ wrote: it don't work..
Which tells us a whole lot.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|