|
errrrr
oooops
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?"
|
|
|
|
|
How do we feel about directly calling framework handlers?
I'm talking about setting up a DC and calling OnPaint(). I'm talking about calling the WM_COMMAND handler for a specific menu item.
Personally, I find this quite lazy. What should be done it to create a routine that does the required action, and then have both the framework handler and the user code call the routine.
Am I psycho?
J
|
|
|
|
|
ummmmm
maybe u should change ur name to jamie bates?
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?"
|
|
|
|
|
lauren wrote:
ummmmm
maybe u should change ur name to jamie bates?
That would be a "yes" then?
J
|
|
|
|
|
Somehow, I find this a little less elegant.
Works nevertheless
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
I think that it is fine, as long as only your class can call the framework handlers directly. The way that I look at it, is you are combining common functionality into one place. That common code needs to be accessed.
Do what makes the most sense for the situation. Whether it is sending a message to the window and letting the message handlers process the message, or calling the framework handler directly.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
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.
|
|
|
|