|
hi friends!
how to trap notifications set with IDirectSoundNotify8::SetNotificationPositions method in a separate thread, in MFC application?
|
|
|
|
|
Hello,
I nend to be able to detect the event fired when the user leaves the press operation over a button:
I'm trying to activate a process while the button is pressed and deactivate it as soon as the button is left.
As always thank you very much.
|
|
|
|
|
Do you mean when they let go of the mouse button on your control? If so, WM_LBUTTONUP
Or do you mean when they move the pointer outside your button? Then use TrackMouseEvent & WM_MOUSELEAVE
Or do you mean when the user moves the mouseout of your control while the mouse button is down?
If so then set a flag when you get WM_LBUTTONDOWN and clear it when you get WM_LBUTTONUP, and also use TrackMouseEvent() and WM_MOUSELEAVE.
Signature space for rent. Apply by email to....
|
|
|
|
|
Hello,
I've spent all night working and I can't think clearly, could you help me again?
Where should I place those message filters? in PreTranslateMessage? and what about TrackMouseEvent? (I've tried to find information of that function in msdn and only one article appears, and I've not understood where to place anything...)
Thank you in advance...
|
|
|
|
|
Can you clarify which of the 3 scenarios you are trying to capture?
quicker for me to explain then
Signature space for rent. Apply by email to....
|
|
|
|
|
I must say that I didn't thought of those three detection modes, but I need all of them, due to the fact that I need to stop the process activated by clicking that button when any of that events happens...
Could you explian me this scenario?
Or do you mean when the user moves the mouseout of your control while the mouse button is down?
If so then set a flag when you get WM_LBUTTONDOWN and clear it when you get WM_LBUTTONUP, and also use TrackMouseEvent() and WM_MOUSELEAVE.
Thank you very much for your time and help.
|
|
|
|
|
Check TrackMouseEvent API.
Tomasz Sowinski -- http://www.shooltz.com
*** Purgamentum init, exit purgamentum ***
|
|
|
|
|
I developed an Activex Control with events that I'm using in Vb. Now I'd like to use this Activex in a VC++ project. Importing activex I can see only method but no events. How can I import this events and manage its?
Thanks you
Bye
|
|
|
|
|
If you have placed an activex control on a dialog or form, you can map the events using class wizard. Start classwizard Ctrl+W and goto the "ActiveX events" tab. From there you should be able to choose which you want to map.
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
When use CInternetSession::OpenURL in a seperate thread,for example:
CStdioFile* pFile=CInternetSession::OpenURL(...)
If this thread for some reason is terminated suddenly,VC will detedct a memory leak:
Detected memory leaks!<br />
Dumping objects -><br />
{202} normal block at 0x003478D8, 30 bytes long.<br />
Data: < /] > B0 00 2F 5D 0D 00 00 00 0D 00 00 00 01 00 00 00
and because OpenURL have not finished properly,so pFile is still NULL,so we cannot manage to dealocate the memeory by delete pFile.
What should I do? Is it a bug in MFC?
|
|
|
|
|
my guess is that the leak is because of
If this thread for some reason is terminated suddenly,VC will detedct a memory leak
Are u calling TerminateProcess or one of the family??
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thanks for response.
OpenURL will wait until received the response from server or time out.In a narrow band and slow connection,this may take some time.If the user is weary of waiting and click "Stop" button,I don't want to say "Hi! I'm waiting something from server,don't bother me! I'll stop until I can stop",I just want to stop the thread immediately.But in this way I don't know how to avoid the memory leak.
|
|
|
|
|
You have a couple of options for handling this correctly.
1. Let the thread finish it's work and clean up but make the application ignore the results and pretend like the thread is not running.
2. Use an asynchronous connection to the server which involves a bit more than a simple call to OpenURL, but will get you what you want. You can use this link to read more on ansync connections using CInternetSession[^]
--
If it starts to make sense, you're in a cult.
|
|
|
|
|
Hello,
I need to be able to control the limits that are allowed to type in a CEdit control (ie: if the max number must be smaller than 2000, I need not to be able to type 3000).
OK I know that I can tell the CEdit to be limited by the use of this DDX call:
DDV_MinMaxInt(pDX, m_vediVelocitat, 0, 3000);
OK, I need to be able to modify this limit at runtime, is there an easy way?
All that I've tried gives me an artificial behaviour.
As always, thank you in advance.
|
|
|
|
|
Have you try removing the DDV_MinMaxInt intrcution from the AFX_DATA_MAP section, and replace "3000" by a variable ?
void CMyDialog::DoDataExchange(CDataExchange* pDX)<br />
{<br />
CDialog::DoDataExchange(pDX);<br />
DDX_Text(pDX, IDC_MY_EDIT, m_iPos);<br />
DDV_MinMaxInt(pDX, m_iPos, 0, m_iRangeMax);<br />
}
Some of those that work forces
Are the same that burn crosses !
Killing In The Name/Rage Against The Machine
|
|
|
|
|
Do you need that 'on the fly', meaning you want to stop the user from entering eg. one '0' too much, or are you satisfied with the (IMHO stupid, confusing and unsatisfactory)MFC approach of testing after the user has clicked OK?
|
|
|
|
|
MFC tests when you type, that is why it is stupid. If you have a number, highlight it and hit delete, you'll get a validation error. I ALWAYS roll my own validation, so as not to drive my users insane.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Christian Graus wrote:
MFC tests when you type
Really? Not only in UpdateData()? This was new to me, it must be limited to CEdit, as all other validations are triggered by UpdateData().
|
|
|
|
|
MFC *doesn't* test until DoDataExchange is called from UpdateData.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Hmmm.... I remember spending ages trying to stop it from popping up all the time, but when I did a quick test, it was not the case. I'm confused now, I wonder what I was doing at the time.....
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
what can I do? I have no time and this will semi-solve my problem, when I'd have finished this machine, I'll try to find out another way...
|
|
|
|
|
I found this
DDX_Check(pDX, IDC_SEX, m_bFemale);
DDX_Text(pDX, IDC_EDIT1, m_age);
if (m_bFemale)
DDV_MinMax(pDX, age, 0, m_maxFemaleAge);
else
DDV_MinMax(pDX, age, 0, m_maxMaleAge);
in the MSDN under "TN026: DDX and DDV Routines".
Seems you can easily use variables.
|
|
|
|
|
Hi Joan,
One way would be to derive your own class from CEdit. Add a member variable that holds the maximum value (which you can then dynamically change in your program) and handle the EN_CHANGE or WM_CHAR messages to check whether the modified string is out of range.
I have an example of this but it is at home (it only allows you to type in floating point numbers only). I can send it to you if you wish but I can only do this tonight.
Cheers
Adam.
www.beachwizard.com/travelogue[^]
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
As I have no time, it would be great for me to receive that sample, all of you in codeproject are helping me a lot!
thank you very much!
|
|
|
|
|
Hi Joan,
Pop the following .h and .cpp files in your code. It should work (does for me anyway). You might have to play around with the checking of string lengths and conversions to make it more robust but the idea is there.
In class wizard, set the member variable of your edit box as a Control of type CIntEdit (call it m_wndEditBox or something) and then call m_wndEditBox.SetMaxInt(nMax) on the fly whenver you want (pref. initialise it in OnInitDialog in your dialog box, for example as the default is zero).
Note, the minimum acceptable integer value is zero but I am sure you could change the code as you see fit.
Any probs, givvus a shout
Best regards and good luck ,
Adam.
IntEdit.h
class CIntEdit : public CEdit<br />
{<br />
public:<br />
CIntEdit();<br />
<br />
public:<br />
<br />
public:<br />
<br />
<br />
public:<br />
void SetMaxInt(int nMax);<br />
int GetMaxInt();<br />
virtual ~CIntEdit();<br />
<br />
protected:<br />
int m_nMaxInt;<br />
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);<br />
<br />
DECLARE_MESSAGE_MAP()<br />
};
IntEdit.cpp
<br />
#include "stdafx.h"<br />
#include "IntEdit.h"<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif<br />
<br />
<br />
CIntEdit::CIntEdit()<br />
{<br />
m_nMaxInt=0;<br />
}<br />
<br />
CIntEdit::~CIntEdit()<br />
{<br />
}<br />
<br />
<br />
BEGIN_MESSAGE_MAP(CIntEdit, CEdit)<br />
ON_WM_CHAR()<br />
END_MESSAGE_MAP()<br />
<br />
<br />
void CIntEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) <br />
{<br />
const int DEL=8;<br />
if((nChar<'0' || nChar>'9') && nChar!=DEL) return;<br />
CString strWndTxt="", strTemp="",strChar="";<br />
strChar=(TCHAR)nChar;<br />
<br />
int nStartChar=0, nEndChar=0, nLen=0, nVal=0;<br />
GetWindowText(strWndTxt);<br />
nLen=strWndTxt.GetLength()/sizeof(TCHAR);<br />
GetSel(nStartChar,nEndChar);<br />
strTemp=strWndTxt.Left(nStartChar)+strChar+strWndTxt.Right(nLen-nEndChar);<br />
TRACE(strTemp);<br />
<br />
nVal=_ttoi(strTemp);<br />
if(nVal<=m_nMaxInt)<br />
{<br />
CEdit::OnChar(nChar, nRepCnt, nFlags);<br />
}<br />
}<br />
<br />
int CIntEdit::GetMaxInt()<br />
{<br />
return m_nMaxInt;<br />
}<br />
<br />
void CIntEdit::SetMaxInt(int nMax)<br />
{<br />
m_nMaxInt=nMax;<br />
}
www.beachwizard.com/travelogue[^]
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|