|
Thanks Chris - it's once again YOU to help me (try to) out of a problem.
OnPaint() is working now as it is supposed to...
Also thanks to all the other Gurus: 'Funky' Erik (Funkenbusch) and Lauren (I like the
colours of your homepage)...
The unhandled exception 0x00000005:Access Violation occurs in a WIN callback-function.
When I open some MIDI-Input with
midiInOpen(&hMidiIn, CurInDevice, (DWORD)MyCallback, NULL, CALLBACK_FUNCTION); The 3rd parameter is the address of a callback-function which is called by the
Midi-Device-Driver everytime a MIDI-Event has arrived its input.
The callback works as follows:
void CALLBACK MyCallback(HMIDIIN hMidiIn, UINT wMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
{
int iResult;
switch(wMsg)
{
case MIM_DATA:
{
iResult = Zones->PostMessage(WM_MIDIEVENT);
ASSERT(iResult);
break;
}
case MIM_MOREDATA: break;
case MIM_OPEN: break;
case MIM_CLOSE: break;
default:
ASSERT(0);
} So the callback only posts a userdefined message
#define WM_MIDIEVENT WM_USER+100 to my Dialog. The MessageMapEntry
ON_MESSAGE(WM_MIDIEVENT, OnMidiEvent) is for now just a stub - doing nothing...
void CZones::OnMidiEvent()
{
} When the first MIDI-Event arrives everything works fine, but as soon as the second
event drops in I may not move the mouse over the System-Menu or click the Dialog or move
over a checkbox in the dialog. As long as I don't move the mouse I can play as many notes
as I want...
BTW: When the Dialog is minimized everything works flawlessly too. But I only have to
right-click into the task-bar.....EHHHHHH
No context-menu for maximizing or closing - just my unhandled exception 0x00000005:ACCESS-VIOLATION
Any Ideas on that ?
The exception appears on two machines exactly at the same address.
In DEBUG-MODE everything works brilliant, no latency (MIDI-delays) no MIDI-drones (sounding
till you shut down your system) - no really professional...
Manfred
---
Programming is knowing...
|
|
|
|
|
I followed your advice, Chris - and went to your CodeGuru link.
http://codeguru.earthweb.com/debug/ReleaseMode.shtml
There was one comment by Kelly Beyer: 'Incorrect Message Map Function Signatures'
which referred to a MSDN-KnowledgeBase article.
http://support.microsoft.com/support/kb/articles/Q195/0/32.ASP
So I changed the handler macro of my User-defined message from
afx_msg void OnMyMessage(void); to
afx_msg LRESULT OnMyMessage(WPARAM, LPARAM);
And my handler-function from
void MyDialog::OnMyMessage(void); to
LRESULT MyDialog::OnMyMessage(WPARAM, LPARAM);
And now it works.
In all my books showing how to write User-defined messages it is done the wrong way.
No explanation that the signatures have to be exactly like the ones above. They all
used 'void' instead - and as, when being a beginner, you seldomly switch to release-mode
you never realize that there is a little bug in your application. And when you do
it once than you'll never find out when this bug silently came into your app.
Though it's hard to put the blame on a User-defined message that worked for months in DEBUG-MODE.
Believe me: You would take everything else under consideration before this...
But at least I think it is a very bad behaviour that the compilor doesn't give you
at least a warning when working in DEBUG-MODE (I'm only working in 'Warning-Level 4').
I would never have found the bug in my app without that articles on the net.
There is one little question still bugging me as I got a little paranoid now.
Do you think that this is the real solution to my problem or is it just a temporary
workaround that is hiding another surprise for me now for the future???
Does it sound like 'there must be something else' to you ???
Thanks again for your help - this time a hit, not only a try...
Manfred
---
Programming is knowing...(and having better friends than the MicroSofties)
|
|
|
|
|
Yes, i believe it. This bug used to catch me all the time. Now i've learned to always do ON_MESSAGE handlers the LRESULT way.
there is a "ON_MESSAGE_VOID" message handler, but i've never used it and i don't know if it will help. (from Afxpriv.h)
#define ON_MESSAGE_VOID(message, memberFxn) \
{ message, 0, 0, 0, AfxSig_vv, \
(AFX_PMSG)(AFX_PMSGW)(void (AFX_MSG_CALL CWnd::*)(void))&memberFxn },
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
hey guys,
Is there a performance issue in using a CStatic::SetBitmap() to display Bitmaps? I mean it is so much easier that messing around with device contexts ans BitBlt's. I suspect there is a penalty because life is never easy. BTW, I am having massive resource issues using this method for displaying a lot of bitmaps. Am i correct in assuming this?
thanx for any input you may have
"DWORD my man!"
|
|
|
|
|
Hi
I'm trying to use the system image list through CImageList::Attach, buth without success. I can see in CImageLists' destructor that the attatched imagelist is destroyed when the CImageList object is destroyed. This isn't very appropriate, since 98 can't handle this. It results in an environment without icons. However, on 2k, everything is fine. Anyone knows how to solve this?
|
|
|
|
|
You're forgetting to detach your CImageList object from the system image list before the object is destroyed.
--Mike--
http://home.inreach.com/mdunn/
All your base are belong to ME~!
|
|
|
|
|
No, I'm not. If you look in ~CImageList, you will see that the imagelist is automatically detached. If you look in CImageList::Detach(), you will also see that the imagelist is destroyed when detaching, conclusion: shouldn't detach.
|
|
|
|
|
If you look in CImageList::Detach(), you will also see that the imagelist is destroyed when detaching
That is incorrect. Here's Detach():
HIMAGELIST CImageList::Detach()
{
HIMAGELIST hImageList = m_hImageList;
if (hImageList != NULL)
{
CHandleMap* pMap = afxMapHIMAGELIST();
if (pMap != NULL)
pMap->RemoveHandle(m_hImageList);
}
m_hImageList = NULL;
return hImageList;
}
There's no call to ImageList_Destroy() there. Compare with CImageList::DeleteImageList(), which is called from the CImageList destructor and does call ImageList_Destroy().
--Mike--
http://home.inreach.com/mdunn/
All your base are belong to ME~!
|
|
|
|
|
now, I can create button at run time, then I have some function for each button when it clicked. How can I get the message ???
I catch it at PreTransletMessage(), like so :
BOOL CTestDlg::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message = BM_CLICK)
{
MessageBox("Y");
}
return CDialog::PreTranslateMessage(pMsg);
}
but, seem not correct ???? plx tell me , thanks ....
Regards
Vistac ...
|
|
|
|
|
Hello, the codegurus around the world.;)
First of all, even though you creates the button at run time,
you can use Message Map to catch the button click message as long as
we know ID of the button, I think.
Second, if we use PreTranslateMessage function, we can check the current input focus
control or which control sends the message to the parent.
That is, if (pMsg->hwnd == GetDlgItem(ID_BUTTON)->GetSafeHwnd( )) works since
the button clicked must send the message to the parent.
or if (pMsg->hwnd == GetDlgItem(ID_BUTTON)->m_hWnd)....
The button clicked have the current input foucs.
so, if (GetFocus() == GetDlgItem (ID_BUTTON))....
However, I didn't check my old code, so...?
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Hello, the codegurus around the world.;)
I make a simple test.
BOOL CButtonDlg::PreTranslateMessage(MSG* pMsg)
{
if ((pMsg->message == WM_LBUTTONDOWN && pMsg->hwnd == GetDlgItem(IDC_BUTTON1)->GetSafeHwnd())
|| pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN &&
pMsg->hwnd == GetDlgItem(IDC_BUTTON1)->GetSafeHwnd())
TRACE ("Click or push the button");
return CDialog::PreTranslateMessage(pMsg);
}
</br>
These codes pick up the message if we click the button by PreTranslateMessage.
However, if we use MessageBox rather than TRACE, I got the strange behavior.
Window message stream is more difficult than I expect..
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
I would override OnCommand virtual function
CTestDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
if (HIWORD(wParam) == BN_CLICKED)
{
if (LOWORD(wParam) == myButtonID)
{
MessageBox("Y");
return TRUE;
}
}
return CDialog::OnCommand(wParam, lParam);
}
---
Multitasking: Screwing up several things at once.
|
|
|
|
|
Does anyone know where I can find GOOD DirectX 8 (C++) information, books, tutorials, etc. that go beyond spinning a cube in space ?
Thanks,
Thierry
|
|
|
|
|
Hi Guys !
I'm a newbie
i'm using Visual C++ 6.0 Prof.
i had to load a Word Document to edit some Data Fields.
After edtiting i'll print the Document.
Now my problem:
How can i load a Word Document into a buufer or something els to edit the text ???
THX for your suggestions
Joachim
|
|
|
|
|
Hello, the codegurus around the world.;)
If you print out Word doucemnt, you had better use Word Automation.
You find several sample codes for Automation in MSDN library.
However, Visaul Basic is easier tool to do this than Visual C++.
If you aren't familiar with COM by VC++, VB COM may be easy.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Thx for the help but i didn't have Visual Basic and COM isn't familiar.
But i had to realise this problem with VC++
|
|
|
|
|
Hello!
The question is :
There is computer with 2 network cards. Is it possible that this computer has two different hostnames? If yes, wich of them does the "gethostname" API function return? How can i retreive the second one ?
Thanks a lot.
Best regards,
Furer Alexander
Sentry-Com
alex_f@sentry-com.co.il
When a password just isn't secure enough,
and email confirmations don't quite cut it,
You need Voice authentication.
You need Sentry-Com.
|
|
|
|
|
A Windows computer can only have one name.
Of course it can have different names (records) in a DNS-Server, but it can only have one "real" Windows name.
- Anders
|
|
|
|
|
Hello, can anyone help find a resource site where I can pick up old C++ exams, and possibly notes. I want to test my knowledge. Thank you
|
|
|
|
|
Hi
I wan't to be able to get a filetypes icon, preferably the position in the system image list, and the description string. Is there any API for this?
OBS! I know that I can use SHGetFileInfo, but then I must supply filename. I need it on extension basis.
I prefer to be anonymous.
|
|
|
|
|
I think you can still use the SHGetFileInfo, but you have to specify the GFI_USEFILEATTRIBUTES flag in the uFlags argument, this way the function does not access the specified file, so you can pass a bogus file name with the extension you want.
If this does not work, you can still look for all the informations you want in the registry......
Good luck!
Rui Lopes
|
|
|
|
|
Thanks a lot! It worked perfectly except for the icons for directories!
|
|
|
|
|
My app uses Shlwapi.dll which I would like to include with my installer.
I understand this is part of IE.
Is there a redistributable IE I can include with my installer incase the user does not have this DLL?
--
The Obliterator
|
|
|
|
|
I think with things like this, you must redistribute IE.
Yes, you are groaning with the displeasure of it all.
Seems that that is the way MS like it. A damn good way of
ensuring that everyong has IE on their machine
Stephen Kellett
|
|
|
|
|
Thought as much
So, where do I get hold of a redistributable IE setup file for inclusion on my CD?
I cannot find a full version for download anymore - only a setup which downloads components from the net.
I need a full self contained setup for IE.
Also, anybody know of any legal issues which apply inorder to redist IE?
--
The Obliterator
|
|
|
|