|
Hi !
In my current MFC source code, I have two classes, the usual "MainDlg" and .. euhm ..let´s say "A", which is not a CDialog based class, but another kind of class running separately (in its own thread). In a function of A, I send a message with PostMessage(MSG_MYMESSAGE,35,47); and I´d like to get it in my MainDlg. A way to do this is to declare :
<br />
BEGIN_MESSAGE_MAP(CMainDlg, CDialog)<br />
ON_MESSAGE(MSG_MYMESSAGE, OnMyMessage)<br />
END_MESSAGE_MAP()<br />
This triggers the OnMyMessage() function, but i do not know where to find my two parameters 35 and 47 (that is, the WPARAM and LPARAM), and I really need them.
So, is there any way to get these parameters ?
Thanks 4 your help.
RaGe
Unfortunately, brute-force solutions tend to be slow
even when performed by modern-day microcomputers,
which are capable of several MIPS except when I'm late
for an appointment and want to finish a compile and
run just one more test before I leave, in which case
the crystal in my computer is apparently designed to
automatically revert to 1 Hz.
-- Michael Abrash
|
|
|
|
|
your header file message map entry should look like:
afx_msg LRESULT OnInitTimer(WPARAM wParam,LPARAM lParam);
your cpp file function dec should look like:
LRESULT C8028CDlg::OnInitTimer(WPARAM wParam,LPARAM lParam)
{
wada wada
}
the lParam and wParam are the numbers you want
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
coming soon: situations to avoid #38: "...and the dog was there too?"
|
|
|
|
|
hi !
Thank you for the tip, lauren, it works fine !
RaGe
|
|
|
|
|
How may I run a javascript code from my MFC application
(which manages XML files) ?
Does-it exist a way to interface 'jscript.dll' ?
|
|
|
|
|
|
How can I change the height of the row in report-mode of the ListView?
The simple way with WM_MEASUREITEM is not working. Or, maybe, there is another way in WinCE to display a list of my own items?
I need something like TODAY screen, but with the same row's height for all rows and with scrolling.
With the best regards, Vitaly.
|
|
|
|
|
i think you have to do owner draw stuff
check out the listview section in the controls here on cp ... theres a awesome article by michael dunn (i think)
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
coming soon: situations to avoid #38: "...and the dog was there too?"
|
|
|
|
|
Hi,
I have small problem. I am implementing exception handling as recommended in MSDN and in the KB articles, thus:
try
{
objConn.Open(...);
}
catch(_com_error &errorConnecting)
{
strError = (char *) errorConnecting.Description();
}
However, if there ever is an error, I get a first-chance exception on the catch line. I have step debugged the code and it is that line. Despite the exception, the code continues and functions correctly.
Is this a problem I should be worried about when I move to release build, and if so how can I prevent it?
Thanks in advance,
Simon
|
|
|
|
|
maybe you have break always on for your exeptions
To check, start the program whith step into(F11) and look under
Debug->Exceptions
You'll get a dialog that allows you to set up the exception handling during debugging. Check the Microsoft C++ Exception, if this says stop always then indeed you will get the first chanche... You can change it to stop if not handled and get notification only if an exception is not handled, but this includes cach all handling from the MFC framework.
(you could also just press ctrl+F5 to start the program outside the vc debugger and see what it does)
good luck
Rutger
|
|
|
|
|
Hi,
I have a string which have a time in format
"HH:MM"
How do i convert it into CTime or time_t
Please help
|
|
|
|
|
The CTime object doesn't have a CString constructor. So you will need to do the following:
<br />
CString strTime = "13:30";
CTime tm = CTime(1970, 1, 1, atoi(strTime.Left(2)), atoi(strTime.Right(2)), 1);<br />
I haven't tested this, so let me know if it works ...
Dylan Kenneally
London, UK
|
|
|
|
|
Thanx for the help..
It worked..
|
|
|
|
|
HI All,
Im using Microsoft SAPI Speech development etc etc...
Having a big prob, im watching for Viseme events,
switch(eventItem.eEventId )
{
case SPEI_VISEME :
What do I put next to identify which viseme it is??
Cheers to you all
ADam
|
|
|
|
|
Hi,
i use Vc++6.0, i have a doc/view project and i have a problem with thread synchronization, here is my code :
void CMyAppView::OnStart()
{
...
HANDLE hThreads[12];
....
for(int i=0;i<=Range;i++)
{
int handl=0;// used to increment Handles table index
if (m_sc.m_b1)
{
m_nThreadsNbr += 2;
m_pThread1 = (CThread1*)AfxBeginThread(RUNTIME_CLASS(CThread1), THREAD_PRIORITY_NORMAL, 0, 0);
m_p31Thread->SetOwner(this);
hThreads[handl++] = m_p31Thread->m_hThread;
m_pThread = (CThread*)AfxBeginThread(RUNTIME_CLASS(CThread), THREAD_PRIORITY_NORMAL, 0, 0);
m_pThread->SetOwner(this);
hThreads[handl++] = m_pThread->m_hThread;
}//if
if (m_sc.m_b2)
{
m_nThreadsNbr += 2;
m_pThread2 = (CThread2*)AfxBeginThread(RUNTIME_CLASS(CThread2), THREAD_PRIORITY_NORMAL, 0, 0);
m_pThread2->SetOwner(this);
hThreads[handl++] = m_pThread2->m_hThread;
m_pThread = (CThread*)AfxBeginThread(RUNTIME_CLASS(CThread), THREAD_PRIORITY_NORMAL, 0, 0);
m_pThread->SetOwner(this);
hThreads[handl++] = m_pThread->m_hThread;
}//if
DWORD dw = WaitForMultipleObjects(m_nThreadsNbr, hThreads, TRUE, 5000);
switch (dw) {
case WAIT_FAILED: // Bad call to function (invalid handle?)
AfxMessageBox("Wait failed");
break;
case WAIT_TIMEOUT: // None of the objects became signaled within 5000 milliseconds.
AfxMessageBox("None of the objects became signaled");
break;
case WAIT_OBJECT_0 + 0: // The process identified by hThread[0] terminated.
AfxMessageBox("thread 1 terminated");
break;
case WAIT_OBJECT_0 + 1: // The process identified by hThread[1]terminated.
AfxMessageBox("thread 2 terminated");
break;
case WAIT_OBJECT_0 + 2: // The process identified by hThread[2] terminated.
AfxMessageBox(" thrread3 terminated");
break;
}//switch
}//for
All my threads are UI threads
thread1 and thread 2 are synchronized by a mutex .i.e :
CThread1::Run()
{
CSingleLock sLock(&(m_pOwner->m_mutex));
sLock.Lock();
......
sLock.Unlock();
}
CThread2::Run()
{
CSingleLock sLock(&(m_pOwner->m_mutex));
sLock.Lock();
......
sLock.Unlock();
}
CThread::Run()
{
CSingleLock sLock(&(m_pOwner->m_mutex2));
//becarefull it is another mutex object m_mutex2
sLock.Lock();
......
sLock.Unlock();
}
The PROBLEM is that WaitForMultipleObject return WAIT_FAILED or WAIT_TIMEOUT, but i am sure that the threads terminate within 5000 ms, if a make an INFINITE timeout my application remain Busy.
Can u help me ?
Thank's.
|
|
|
|
|
Have you checked what GetLastError() returns?
/Magnus
|
|
|
|
|
|
To see what the reason is that it returns WAIT_FAILED.
/Magnus
|
|
|
|
|
kortebi wrote:
The PROBLEM is that WaitForMultipleObject return WAIT_FAILED or WAIT_TIMEOUT, but i am sure that the threads terminate within 5000 ms, if a make an INFINITE timeout my application remain Busy.
They can't have terminated within 5 seconds because if they have then using INFINITE wouldn't hang on WaitForMultipleObjects().
UI threads are a pain the behind in MFC and you can easily get into a deadlock. Have you tried #ifdefing out all of the code inside the thread functions and see if WaitForMultipleObjects() behaves as you expect?
Also add TRACE statements at the end of the thread functions so you can see when they finish.
Threads in MFC are the bain of my life.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Neville Franks wrote:
Also add TRACE statements at the end of the thread functions so you can see when they finish.
I did it.
|
|
|
|
|
m_pThread1 = (CThread1*)AfxBeginThread(RUNTIME_CLASS(CThread1), THREAD_PRIORITY_NORMAL, 0, 0);
m_p31Thread->SetOwner(this);
hThreads[handl++] = m_p31Thread->m_hThread; Seems like you're launching the thread m_pThread1 but yet it is m_p31Thread 's handle that is inserted into hThreads (and possibly this handle is invalid at the time of insertion.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Nicely spotted Joaquín. I must say that I found the reuse of m_pThread confusing. Looks like it should be a class member at all. And he shouldn't be using old style C casts.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Within your for loop you increment the m_nThreadsNbr with two every time
you start two threads. This should work for the first iteration but during your second iteration the value of m_nThreadsNbr is the number of threads started during BOTH iterations but the handle array only contains the thread handles from the last iteration.
Replace the
DWORD dw = WaitForMultipleObjects(m_nThreadsNbr, hThreads, TRUE, 5000);
with
DWORD dw = WaitForMultipleObjects(handl, hThreads, TRUE, 5000);
or reset the m_nThreadsNbr to zero in the begining of the for iteration.
In your switch you test the return value from WaitForMultipleObjects against
WAIT_OBJECT_0 + 0, WAIT_OBJECT_0 + 1 and WAIT_OBJECT_0 + 2 in order to see which thread that has terminated BUT when you call the WaitForMultipleObjects you set the bWaitForAll parameter to TRUE which will result in that when WaitForMultipleObjects returns WAIT_OBJECT_0 this means that all threads are terminated. WAIT_OBJECT_0 + 1 and WAIT_OBJECT_0 + 2 will never be returned from WaitForMultipleObjects as long as bWaitForAll is TRUE.
|
|
|
|
|
I want to know what's the type of a MSOffice file (Word, Excel, Access, PowerPoint, ...). How can i do ?
Thanks.
Aziz Rajim
|
|
|
|
|
They have their own file formats, different from one another. There is some stuff on CP, I know Excel exposes it's via COM to allow some work with it, I believe it includes loading & saving.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
you'll need to get at the underlying com objects
which one ar eyou wanting to get at?
bryce
|
|
|
|
|