|
:I want to Create a Frame/view/doc structure On a ActiveX Control,but It will be Found Memory leak! And I Found that the reasons is :
CDocManager* CDocManager::pStaticDocManager;
CPtrList* CDocManager::pStaticList;
How Can I avoid Memroy leak?
the Following is My Code :
BOOL Create()
{
if( m_pFrameWnd )
{
if( IsWindow(m_pFrameWnd->m_hWnd) ) return TRUE;
}
CSingleDocTemplate * pDocTemplate;
pDocTemplate = new CSingleDocTemplate(IDR_MAPTYPE,
RUNTIME_CLASS(CMapDoc),
RUNTIME_CLASS(CMapFrame),
RUNTIME_CLASS(CMapView));
CMapDoc * pDoc = new CMapDoc;
CCreateContext Context;
Context.m_pCurrentDoc = pDoc;
Context.m_pNewDocTemplate = pDocTemplate;
Context.m_pNewViewClass = RUNTIME_CLASS(CMapView);
Context.m_pLastView = NULL;
Context.m_pCurrentFrame = NULL;
CMapFrame * pFrameWnd = new CMapFrame;
m_pDoc = pDoc;
m_pFrameWnd = pFrameWnd;
m_pDocTemplate = pDocTemplate;
CRect rcMap;
GetClientRect(&rcMap);
BOOL ret = m_pFrameWnd->Create(AfxRegisterWndClass(CS_DBLCLKS), NULL, WS_CHILD|WS_VISIBLE, rcMap,this,NULL,&Context);
m_pFrameWnd->ShowWindow(SW_SHOW);
return ret;
}
ZHANGYIFEI
|
|
|
|
|
MFC only deletes the CDocManager class if it(MFC) created it. It looks like you are creating your own doc manager and therefore need to delete on exit.
|
|
|
|
|
I have not created CDocManager ,I don't want MFC create it too!but In fact ,MFC Create it,and leak happened! the reason is two CDocManager's static
data member!
ZHANGYIFEI
|
|
|
|
|
How to hooking api calls before the window receive a message?
I have install a CBT before creating a new process and change the child process' import table for hooking some APIs when it attached to my dll, but it doesn't work before InitInstance() completed its works.
CreateRemoteThread() maybe could help me for saving my job, but Richter said that's not implemented CreateRemoteThread() under Win98...
Thanks a lot for any suggestion.
|
|
|
|
|
There are several articles about API hooking on this page. I personally use Microsoft's "Detours" library to hook API codes other apps call.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thank you very much for your information.
I am tried to search about "detours" and "api hook" in both codeproject and MSDN site, but found nothing could help me.
May I get the link or a copy of the "detours" library from you, please? I'd like to read the source for finding out how it hooks the api before receives a message and then attach to the dll.
|
|
|
|
|
Hi,
this is the official site:
http://research.microsoft.com/sn/detours/
you can download the package from there, I just tried it
There's a PDF-File and lots of tutorials inside the package to start with.
regards
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks a lot, I got the great "Detours" library last night and now reading tutorials.
I am not tried to link with "Detours" library, but I thing all will be well because the implement way of "Detours" is introduce by some articles but I have weakness knowledge about that...
Thanks again, you really saved me from troubles.
|
|
|
|
|
I want to Create a Frame/view/doc structure On a ActiveX Control,but It will be Found Memory leak! And I Found that the reasons is :
CDocManager* CDocManager::pStaticDocManager;
CPtrList* CDocManager::pStaticList;
How Can I avoid Memroy leak?
the Following is My Code :
BOOL Create()
{
if( m_pFrameWnd )
{
if( IsWindow(m_pFrameWnd->m_hWnd) ) return TRUE;
}
CSingleDocTemplate * pDocTemplate;
pDocTemplate = new CSingleDocTemplate(IDR_MAPTYPE,
RUNTIME_CLASS(CMapDoc),
RUNTIME_CLASS(CMapFrame),
RUNTIME_CLASS(CMapView));
CMapDoc * pDoc = new CMapDoc;
CCreateContext Context;
Context.m_pCurrentDoc = pDoc;
Context.m_pNewDocTemplate = pDocTemplate;
Context.m_pNewViewClass = RUNTIME_CLASS(CMapView);
Context.m_pLastView = NULL;
Context.m_pCurrentFrame = NULL;
CMapFrame * pFrameWnd = new CMapFrame;
m_pDoc = pDoc;
m_pFrameWnd = pFrameWnd;
m_pDocTemplate = pDocTemplate;
CRect rcMap;
GetClientRect(&rcMap);
BOOL ret = m_pFrameWnd->Create(AfxRegisterWndClass(CS_DBLCLKS), NULL, WS_CHILD|WS_VISIBLE, rcMap,this,NULL,&Context);
m_pFrameWnd->ShowWindow(SW_SHOW);
return ret;
}
ZHANGYIFEI
|
|
|
|
|
Hi,
I am building a wind synth that uses the API midi functions of
a soundcard. m_Note2 is an int value according to the keys pressed
and m_PBAD_2 is an int value ranging from 0-127 according to the airflow
thru the synth, updated according to the timer set at 250 millisec.
When I blow into the synth a note is played every 25msec but does not
stop, because the m_note in stopnote() outdated.
I have no idea what to add to the playnote() function. Any suggestions appreciated,
my knowledge of VC++ is very limited.
Cheers,
Rob
robert.harrington2@mail.dcu.ie
void CAD_mouthDlg::PlayNote()
{
UpdateData(TRUE);
MidiOutMessage (hMidiOut, 0x00, 0x90, m_Note2,m_PBAD_2) ;
}
void CAD_mouthDlg::StopNote()
{
if(m_Key_Press == FALSE)
{
MidiOutMessage (hMidiOut, 0x00, 0x90, m_Note2,0) ;
}
else
{
}
}
void CAD_mouthDlg::OnTimer(UINT nIDEvent)
{
CAD_mouthDlg::read_analog();
CAD_mouthDlg::SetPortChigh();
CAD_mouthDlg::OnButtonReadPort();
CAD_mouthDlg::PlayNote();
CAD_mouthDlg::StopNote();
CDialog::OnTimer(nIDEvent);
}
|
|
|
|
|
bob_000 wrote:
void CAD_mouthDlg::StopNote()
{
if(m_Key_Press == FALSE)
{
MidiOutMessage (hMidiOut, 0x00, 0x90, m_Note2,0) ;
}
else
{
}
}
Well, one of your problems is that the MIDI note off message code is 0x80 (to 0x8F for different channels), not 0x90 (0x90 - 0x9F are note-on messages for channels 0-15)). As you probably know, MIDI uses a Note On message to start a note and a Note Off message to stop it.
[Edit] Oops - I just checked a MIDI spec, and a Note On message with velocity zero, which is what you're doing, should also work as a Note Off. Sorry![/Edit]
However, you're still going to run into problems. Calling StopNote() immediately after PlayNote() (assuming m_Key_Press == FALSE) will result in a note too short for you to hear. But if m_Key_Press is TRUE (so the stop message doesn't get sent), the next time your timer triggers another note on will be sent (maybe with the same pitch) without you having sent a stop message. You might get the same note played again, which will sound wierd, or the previous note might stop - it kinda depends on the synth you're sending the MIDI messages to. Anyway, wind instruments are normally monophonic so you'd want to stop the previous note before starting the new one. But that's more an app-logic problem, and that all depends on what you're trying to do!
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
I´m trying to get the Image attributes (width,height and dpi)
from cgm and eps files. I use the GDI+ to get it from jpg,tif
and wmf like this:
Image image(L"D:\\Code\\testbilder\\jpg1.jpg");
UINT imageHeight = image.GetHeight();
UINT imageWidth = image.GetWidth();
REAL horizResDpi = image.GetHorizontalResolution();
REAL vertiResDpi = image.GetVerticalResolution();
But I cant open eps or cgm images.
Can anybody please help me?
Vandaley
|
|
|
|
|
|
|
How to create a directory using WinApi or MFC?
|
|
|
|
|
refer to MSDN:
::CreateDirectory(path,NULL);
hope this helps...
|
|
|
|
|
::CreateDirectory will do the work if you already have a parent directory. If you want to create a directory "sequence" (e.g. parent doesn't have to exist), here is an example of such function:
bool CreateDirectorySeq(IN LPCTSTR lpszDirPath)
{
TCHAR szShorterPath[MAX_PATH];
TCHAR szDirectory[MAX_PATH];
if(!CreateDirectory(lpszDirPath, NULL)){
_tcscpy(szDirectory, lpszDirPath);
if(szDirectory[_tcslen(szDirectory) - 1] == TCHAR('\\'))
szDirectory[_tcslen(szDirectory) - 1] = TCHAR('\0');
LPSTR lpszLastDir = _tcsrchr(szDirectory, TCHAR('\\'));
if(lpszLastDir == NULL)
return true;
ZeroMemory(szShorterPath, MAX_PATH);
_tcsncpy(szShorterPath, szDirectory, _tcslen(szDirectory) - _tcslen(lpszLastDir));
}else
return true;
if(CreateDirectorySeq(szShorterPath))
return (CreateDirectory(szDirectory, NULL) == TRUE);
return false;
}
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
Excellent function that helped out a lot, thanks for posting it!
Mike Ellertson
|
|
|
|
|
Hi, everyone!
I want to know where can I find a software that can do
PtoP video and audio interactions between two ends of users,
just like netmeeting.
Additional requisite is:
1. it runs on windows platform;
2. it is open source project.
Thanks in advance,
George
|
|
|
|
|
Hey pal,
sorrie I am not able to offer any help, but jus wanna tell you that I am in the same boat. Trying to find something along that line, cos needed to tweak something when doing conferencing.
Just to let you know that somewhere out there, there is another fella that is desperately doing so as well, hope that eases your woes of sort. FYI, I have not managed to find any.
Trying my best to write one myself one, though I am a complete newbie. Will keep you posted if i find any. Or if i successfully write out something. Hope you will do the same too.
Cheers
extremalis
<extremalis@catcha.com>
|
|
|
|
|
Thanks, extremalis buddie!
I am waiting for you ... hurryyyyyy~~
regards,
George
|
|
|
|
|
hey, jus an update,
I am able to locally display my video after grabbing it from the camera.
Basically, whatever I am doing is definitely not efficient, but I suppose I wanna get something going first, my deadline is getting near, so no point harping on how I can do better. Enuff of crap...this is basically how i did it, I dun have my exact codes now, its in office, kinda hard to get it out too...basically copy it to DIB format, den display a single bitmap, den use a timer to repeat the grab frame and display fast, at about 15fps.
I used the following from VFW:
capGrabFrame: to get a frame from the capture window
capCopyEdit: to copy the stuff to a clipboard i think...
den do the usual stuff for a clipboard, like opening one and closing one..
all these will be copied to a char buffer. I then used these data over at my other dialog box meant to display this to show lor.
used <capstretchblt> coz somehow I could not managed to use <drawdibdraw> which is supposed to be the right command.
It works now, am trying to figure out how best to transfer all these via socket to the other end. Hope that you are making good progress as well.
Regards
|
|
|
|
|
Hi, extremalis buddy!
Maybe our purpose is different. I think I need to transfer
the media stream through network. But is that your purpose?
regards,
George
|
|
|
|
|
Media stream? Meaning you open an 'avi' file and then you transfer over the network?
My purpose is to capture via the webcam and transfer this thing over the network real time. So I suppose you go find the functions to open an avi file or something into DIB format, you can achieve something similar to mine.
I gotta work on my stuff first, such that it can transfer across the network on Sockets.
Keep me posted on what you are doing, we can exchange views on whatever we are doing, and hopefully we can gain some inspirations from it.
Cheers.
|
|
|
|
|
Hi, extremalis buddy!
Try this,
http://www.banasoft.net/avphone3/demos/sourcedemo.htm
regards,
George
|
|
|
|
|