|
Thank you very much for your answers. But I have some questions again :
1. I can succesfully get AM_MEDIA_TYPE from output pin of my source filter (I use audio files as sources
in my case ) But unfotunately I cannot get pbFormat even formattype of AM_MEDIA_TYPE
(pbFormat -> bad pointer, formattype-> GUID_NULL )
I use the code below to get AM_MEDIA_TYPE , I can get other parameters succesfully
BOOL MyClass::GetMediaTypeOfConnectedPin (IBaseFilter* pFilter,PIN_DIRECTION pDir,AM_MEDIA_TYPE* pMediaType,int index)
{
HRESULT hr ;
IPin* fPin ;
hr = this->GetPin(pFilter,pDir,index,&fPin);
if(hr != S_OK ) return FALSE ;
if ( (fPin->ConnectionMediaType(pMediaType)) != S_OK) return FALSE ;
if ( pMediaType->formattype == FORMAT_WaveFormatEx)
{
WAVEFORMATEX* temp = (WAVEFORMATEX*) malloc(sizeof(WAVEFORMATEX));
temp = ( WAVEFORMATEX *)pMediaType->pbFormat;
...
free(temp);
}
return TRUE ;
}
2. What is the order of samples if there are 2 channels. For example is it something like :
Left Channel -> pBuffer[0] ... pBuffer[n/2]
Right Channel -> pBuffer[n/2+1] .... pBuffer[n]
or
Left Channel-> pBuffer[even_indexes]
Right Channel -> pBuffer[odd_indexes]
3. After I get my samples as WORDs(unsigned shorts) , what should I do to get floats from them ?
Thank you very much
Regards
|
|
|
|
|
Hi together,
i coded a project (SDI) with an editbox in the toolbar.
By pressing enter the value in the edit will be shown in a msgbox(with a lot of help of Mr. Salesbery ).
In my project the document will hande the datas an the view will show them !
Now i have to pass the value in the editbox to the view.cpp in order to show them !
But this won't work
Here are some codes;
#pragma once
class CMyEdit : public CEdit
{
public:
CMyEdit();
~CMyEdit();
BOOL PreTranslateMessage(MSG* pMsg);
CString m_MyEditAusgabe;
protected:
DECLARE_MESSAGE_MAP()
};
#include "stdafx.h"
#include "MyEdit.h"
#include "Test.h"
#include "NEW_cLoadFile.h"
CMyEdit::CMyEdit()
{
}
CMyEdit::~CMyEdit()
{
}
BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
END_MESSAGE_MAP()
BOOL CMyEdit::PreTranslateMessage(MSG* pMsg)
{
NEW_cLoadFile mlf;
cTest test;
if (pMsg->message == WM_KEYDOWN && VK_RETURN == pMsg->wParam)
{
return TRUE;
}
else if (pMsg->message == WM_KEYUP && VK_RETURN == pMsg->wParam)
{
CString cstrNumber;
GetWindowText(cstrNumber);
test.testFunktion(cstrNumber);
return TRUE;
}
return CEdit::PreTranslateMessage(pMsg);
}
The view.cpp:
#include "stdafx.h"
#include "NonButton Ctrl in ToolBar 1.h"
#include "MyEdit.h"
#include "NonButton Ctrl in ToolBar 1Doc.h"
#include "NonButton Ctrl in ToolBar 1View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CNonButtonCtrlinToolBar1View, CView)
BEGIN_MESSAGE_MAP(CNonButtonCtrlinToolBar1View, CView)
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
CNonButtonCtrlinToolBar1View::CNonButtonCtrlinToolBar1View()
{
}
CNonButtonCtrlinToolBar1View::~CNonButtonCtrlinToolBar1View()
{
}
BOOL CNonButtonCtrlinToolBar1View::PreCreateWindow(CREATESTRUCT& cs)
{
return CView::PreCreateWindow(cs);
}
void CNonButtonCtrlinToolBar1View::OnDraw(CDC* pDC)
{
CNonButtonCtrlinToolBar1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
}
BOOL CNonButtonCtrlinToolBar1View::OnPreparePrinting(CPrintInfo* pInfo)
{
return DoPreparePrinting(pInfo);
}
void CNonButtonCtrlinToolBar1View::OnBeginPrinting(CDC* , CPrintInfo* )
{
}
void CNonButtonCtrlinToolBar1View::OnEndPrinting(CDC* , CPrintInfo* )
{
}
#ifdef _DEBUG
void CNonButtonCtrlinToolBar1View::AssertValid() const
{
CView::AssertValid();
}
void CNonButtonCtrlinToolBar1View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CNonButtonCtrlinToolBar1Doc* CNonButtonCtrlinToolBar1View::GetDocument()
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CNonButtonCtrlinToolBar1Doc)));
return (CNonButtonCtrlinToolBar1Doc*)m_pDocument;
}
#endif //_DEBUG
void CNonButtonCtrlinToolBar1View::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
}
If you need more i attached a small codesnippet !
http://www.filehosting.at/files/download.php?file=611b6c1fd8ef7b65080cbd12624d1421
I really hope you can help me
Many thanx fo yor help
Best regards
Croc
|
|
|
|
|
CrocodileBuck wrote: test.testFunktion(cstrNumber);
What is this?
I'm not seeing any code that attempts to notify the view of
the enter key being pressed in the edit control.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mr.Salsbery,
i tried to include the view in the MyEdit.cpp and then to pass the value to the OnUpdate
I tried different possibilities but no one worked, so i cleaned up the functions !
I know that i have to notify the view, i've read it in the book from swanke but i don't know how to do that ?
Thanx for your help
best regards
Croc
|
|
|
|
|
P.S.:
I also tried this
void CNonButtonCtrlinToolBar1View::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (VK_RETURN)
{
MessageBox("test","test",MB_OK);
}
CView::OnChar(nChar, nRepCnt, nFlags);
}
I think that thie code will work but there is still don't know how to notify the view in the right way
Thanx for your help
hopefully
croc
|
|
|
|
|
OK,
OnChar is the wrong way !
Could anybody help me ???
Thanx for your help
Best regards
Croc
|
|
|
|
|
Hi,
is my question too stupid, too difficult or have i made mistakes in my posting ?
Thanx for your help
Best regards
Croc
|
|
|
|
|
There are another options as different time zones, people works or sleeps and so on. Be patient. Somebody will help you
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Plus if you reply to your own posts, I never get an email notifying me that you posted
You have the enter key event at the edit control class.
Now you need to somehow relay that info to the view.
There's an infinite amount of ways to do that.
The easiest thing to do would be to post a user-defined message to the parent of the edit control's parent.
You could also post the message to the app's main window - depends on your window hierarchy.
Let's say your window hierarchy is like this:
FrameWindow
ToolBar
Edit Control
View
To get a message to the view from the edit control, post the message to the parent of the edit control's parent,
which is the frame window. Add a handler for the message in the framewindow class. In that handler, GetActiveView()
can be used to get the view window to forward the message on to.
That's one example using window messages.
Another alternative is to pass window object pointers down to the edit control at creation time, and
call methods of the window class directly from the edit control class. This solution is much less elegant
because it binds a bunch of window classes together in a way they can't be reused easily...not a good
object-oriented design.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi. Mr Salsbery ,
thanx for your reply , i will try the first option now !
Thank for your help
Best regards Croc
|
|
|
|
|
Hi Mr. Salsbery,
my new MyEdit.cpp :
BOOL CMyEdit::PreTranslateMessage(MSG* pMsg)
{
NEW_cLoadFile mlf;
cTest test;
if (pMsg->message == WM_KEYDOWN && VK_RETURN == pMsg->wParam)
{
return TRUE;
}
else if (pMsg->message == WM_KEYUP && VK_RETURN == pMsg->wParam)
{
CView* pView = (((CMainFrame*)AfxGetMainWnd())->GetActiveView());
pView->SendMessage(WM_SETTEXT,0,'test');
return TRUE;
}
return CEdit::PreTranslateMessage(pMsg);
}
And here is the View.cpp of the project:
.
.
.
.
.
void CNonButtonCtrlinToolBar1View::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
CString text;
MessageBox(text,text,MB_OK);
}
This won't work
Unfortunately i don't know much about the message handling in the mfc
Could yo perhaps correct the code ???
P.S.:i really forgot the time zone
Thanx for your help
Best regards
Croc
|
|
|
|
|
You should probably be sending a user-defined message.
The receiving window will need to have a handler for that user-defined message.
CrocodileBuck wrote: Unfortunately i don't know much about the message handling in the mfc
It's actually Windows messaging - that's essential knowledge for Windows programming.
I'd definitely recommend studying that and knowing it if you're going to do Windows GUI programming
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
Was wondering when someone gets the THREAD_ATTACH message (sine my app has lots of threads)
Is there anyway of finding out information/identify about this thread.. Thread Name would be nice
I guess I could do GetCurrenThread that gives me the thread name....
|
|
|
|
|
ForNow wrote: I guess I could do GetCurrenThread
Good guess indeed.
ForNow wrote: that gives me the thread name....
Actually it gives you the thread handle.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Anyway to get more info ?? about the the threads Like thread Name ??
If I have a lot of threads and only a few that I really want to Process
I guess I have to Create a Process in Which with only those threads call DLL functions
|
|
|
|
|
I don't see anything documented anywhere about Win32 threads having names.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The Last parm on CreateThread I thought that was a pointer to somehow Identifying the thread ...... (below)
I have a Windows Internals Book I am going to see if with a thread Handel I can somehow Identify the Thread
pThreadId
A pointer to a variable that receives the thread identifier. If this parameter is NULL, the thread identifier is not returned.
Return Value
|
|
|
|
|
ForNow wrote: The Last parm on CreateThread I thought that was a pointer to somehow Identifying the thread
Yes, it is the unique identifier for the thread. You can also get it with GetCurrentThreadId(),
as I mentioned in my first reply.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
So SO Sorry ... You know people tell me this all the time My Boss or When I am dating
I just don't listen or read
Thankx
|
|
|
|
|
ForNow wrote: or When I am dating
Who listens to them anyway hehe
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
GetCurrentThreadId() is useful to get the unique identifier for the thread.
The WMI Win32_Thread class has a little info - not much useful except for thread state.
To set the thread name seen in the debugger: How to: Set a Thread Name in Native Code[^]
I'm not sure how one gets the thread name programatically.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
To set a thread name while debugging, as Mark mentioned:
void utl::SetThreadName( cchar *NAME, DWORD ID )
{
struct {
DWORD Type;
cchar *Name;
DWORD Id;
DWORD Flags;
} info = { 0x1000, NAME, ID, 0 };
__try
{
::RaiseException(0x406D1388, 0, sizeof(info)/sizeof(DWORD), (ULONG_PTR*)&info);
}
__except(EXCEPTION_CONTINUE_EXECUTION)
{
}
}
There is no way to get the name back.
If you really want to associate a name with a thread then use some variant of TLS.
When you get the THREAD_ATTACH is fairly well spelled out in the MSDN docs, what part don't you understand ?
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Hi, and thankx for responding
What my problem is that in my DLL_ATTACH_THREAD I only want to process only certin threads in my app So. I want to have some way of identfying them (the threads)
How about PsGetCurrentThread The seems to return a pointer to a ETHREAD block where I could some how identify from where this thread originated from
even though it was probably itended for device drivers the doc says any IRQL level
Thankx
|
|
|
|
|
Just use the thread handle and thread id from either:
GetThreadId(thread_hnd)
GetCurrentThreadId()
From MSDN:
Until a thread terminates, its thread identifier uniquely identifies it on the system.
This means you must also track when a thread you are interested in dies.
For threads you start you can just catch DLL_THREAD_DETACH.
For others (e.g. started by MS CRT or nVidia OpenGL driver) you won't always get a DLL_THREAD_DETACH.
ForNow wrote: some how identify from where this thread originated from
This is an unrelated issue, if you want to know that use StackWalk64 to trace the call stack.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|