|
hello
how can i read a stream from the sound card?
|
|
|
|
|
A couple popular ways are:
Windows Multimedia Waveform Audio[^]
DirectSound[^]
There's no performance advantage using DirectX (DirectSound) over windows multimedia for audio.
If you've done any DirectX coding, or already use DirectX in your code, then you may find
DirectSound easier.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Search CodeProject for "audio".
If you are doing this at a Windows multimedia level (not DirectX), search for WaveIn. There are a few projects to start you on the way.
|
|
|
|
|
Hello,
I want to call a function in the application class from the CMainframe class.
Is it possible since CMainframe is created in the InitInstance() function of the application class.
And in general what is the relation between a CMainframe and the application class.
Prithaa
|
|
|
|
|
prithaa wrote: Is it possible...
Yes.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
To expand on DavidCrow's excellent reply...
prithaa wrote: in general what is the relation between a CMainframe and the application class.
They are both in the same application(?). It's up to you to provide the relationship if you need
it. Typically, the CWinThread::m_pMainWnd is set to point to your app's main window. If this
is done then the application will terminate when the main window closes.
Also, the application class is typically the thread that provides the message loop which
dispatches messages to the main window.
Unless you've passed a pointer/reference to your app class to the main window class (in which
case you could use that to call a method of the app class) then you can use AfxGetApp() to get
a pointer to the one and only app class object, something like:
CMyWinApp *pMyWinApp = DYNAMIC_DOWNCAST(CMyWinApp, AfxGetApp());
pMyWinApp->MyAppMethod(...);
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
it is possible to use:
To access the main frame:
CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
To access the CWinApp derived:
extern CMyApp theApp;
This "theApp" is usually declared in the CMyApp.cpp by default if you use assistant in VC++
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?
|
|
|
|
|
I'm currently trying to get our code to link using VS8 or 2005. We are currently using VS7 or 2003.
When I link I get a collection of the following messages.
LIBCMT.lib(printf.obj) : error LNK2005: _printf already defined in libredir.obw
LIBCMT.lib(calloc.obj) : error LNK2005: _calloc already defined in liballoc.obw
LIBCMT.lib(realloc.obj) : error LNK2005: _realloc already defined in liballoc.obw
LIBCMT.lib(vprintf.obj) : error LNK2005: _vprintf already defined in libredir.obw
After these errors obviously the linking fails.
The code I am linking is a collection of C and C++ code producing DLLs and EXEs. Bits of the system were written in the very early days of windows. So there we have our own code to do malloc, calloc, printf, etc.
What I understand after spending hours reading Microsoft and this site is that prior to VS8 we were linking using the single threaded library libc.lib. Now this is no more and thus we have to use the multi-threaded libcmt.lib. This is the cause of the bother.
The questions Now we are being forced to use the multi-threaded library libcmt.lib how do I stop it complaining about our own defined functions and let our software compile?
The answer isn't obviously to get rid of our versions because our huge code base uses these functions instead of microsoft and in the case of printf does something special to the output.
One oddity is that we have defined our own malloc and it doesn't whinge about that.
Any help would be gratefully received.
steven
-- modified at 13:00 Thursday 24th May, 2007
|
|
|
|
|
Hi,
My application crashes when i do a Drag and Drop on the Browse window, it does not happen often. I happens only when we do a improper drag and drop, meaning if the selection is not made and still we manage to Drag. Windows thinks that there is an object attached to Drag but has a null pointer and crashes in the
DataSource.DoDragDrop(m_dropEffectAllowed)
function,
void OnBegindrag(NMHDR* /*pNMHDR*/, LRESULT* pResult)
{
//NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
*pResult = 0;
// If no drop effects are allowed then just exit.
if (0 == m_dropEffectAllowed) return;
// Create an item list for all of the selected objects.
CPyrItemList* ppil = CreateSelectedItemList (m_fIgnoreClassFoldersInLists);
if (NULL == ppil) return;
// If we drag the data to another process and it takes a long time
// to complete the drop, it's possible for us to get "server busy"
// dialogs while we're waiting for the other process. So we want
// to turn off those dialogs now.
// Create a data source to do the drag-drop and then do the
// drag-drop.
CPyrItemListDataSource DataSource;
DataSource.Create (*ppil);
/*DROPEFFECT dropEffect = */ DataSource.DoDragDrop (m_dropEffectAllowed);
delete ppil;
}
Can someone pls suggest?
|
|
|
|
|
Hello everybody!
I´m having some kind of weird problem with my program.
I´m developing my app in Visual C++, MFC.
It has many Dialogs, but doesn´t matter. When the OnInitDialog of the main Dialog starts, I call a thread. The problem I have is that that thread must call another Dialog I have made for errors (like a personal MessageBox), but it can´t.
Then I tried calling any of the other dialogs from the thread and it seems that i´ts impossible.
Is there any way to do it, or not? Thanks!!

|
|
|
|
|
Do you have the dialog handles retained as global variables? If so, you should have no problem accessing them with a separate thread. Just be aware that you're using shared memory when you do this; I'd recommend posting a user-defined windows message back to your main thread for any shared memory processing.
KR
|
|
|
|
|
Im sorry, I dont understand what you say about "dialog handles retained as global variables". What I do to call the dialogs is just this:
CErrorDlg a;
a.DoModal();
In the rest of the program I do that to call different dialogs...
PS: It may be something stupid that I can´t see, but you should know that I´m new programming at Visual C++...
|
|
|
|
|
garfield185 wrote:
CErrorDlg a;
a.DoModal();
In the rest of the program I do that to call different dialogs...
Ok...
Calling DoModal() will prevent the calling thread from running until the dialog is dismissed.
Is this really what you want?
You said in your first post that you have multiple dialogs.
Are they all modal dialogs and only one is shown at any given time, or are they modal and created from different threads, or are they modeless and all created from the main thread?
Describe the behaviour of your application a little more and how you want it to work.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi, I'm having an odd problem with bitmaps and I was hoping someone might have some idea of what to look for.
I'm using only VC++ and the Windows API, not MFC.
The basic goal I want to accomplish is to have one array of bitmaps, and a corresponding array of masks for these bitmaps so that I can easily draw the bitmaps transparently.
The problem is that one of the bit masks is not being created properly for some reason, even though all of the others work just fine using the same function.
So here's what I'm doing: I first create an array of bitmap handles using LoadBitmap, with MAKEINTRESOURCE called on a resource id. This works fine. Then I attempt to create a bit mask for each of these bitmaps.
The bitmap mask created, basically, as follows:
Into the function, I pass the HBITMAP to create the mask for, as variable Hbm, and I pass
the COLORREF of the color to be transparent, as Trans.
<br />
HBITMAP CreateMask(HBITMAP Hbm, COLORREF Trans)<br />
{<br />
HBITMAP Mask, o1, o2; <br />
HDC hd1, hdc2;<br />
<br />
Mask = CreateBitmap(10, 10, 1, 1, NULL);<br />
<br />
hdc1 = CreateCompatibleDC(main_HDC);<br />
hdc2 = CreateCompatibleDC(main_HDC);<br />
o1 = (HBITMAP)SelectObject(hdc1, Hbm);<br />
o2 = (HBITMAP)SelectObject(hdc2, Mask);<br />
SetBkColor(hdc1, Trans);<br />
<br />
BitBlt(hdc2, 0, 0, 10, 10, hdc1, 0, 0, SRCCOPY);<br />
<br />
BitBlt(hdc1, 0, 0, 10, 10, hdc2, 0, 0, SRCINVERT);<br />
<br />
Hbm = (HBITMAP)SelectObject(hdc1, o1);<br />
Mask = (HBITMAP)SelectObject(hdc2, o2);<br />
<br />
DeleteDC(hdc1);<br />
DeleteDC(hdc2);<br />
<br />
return Mask;<br />
}<br />
I use this function to create 6 masks, and it works fine for most of them, but for some reason the 3rd mask does not seem to be created properly. Even if I only try to create that one mask and not the other 5, it doesn't work. The mask handle is returned, and it has the correct size (10, 10), but when I try to blit it to the screen, either it doesn't show up, or it's in some weird shape that isn't correct. Even if I use the SAME bitmap to create all 6 of the masks, 5 of them come out correctly and that one, the 3rd one, is still messed up.
Here's the function I use to blit to my double-buffered HDC:
<br />
void DrawTransparentBitmap(HBITMAP bitmap, HBITMAP mask, int x, int y, int wid, int hgt)<br />
{<br />
HBITMAP orig;<br />
<br />
orig = (HBITMAP)SelectObject(DrawDC, mask);<br />
BitBlt(wobj.getBackHDC(), x, y, wid, hgt, DrawDC,0,0,SRCAND);
<br />
mask = (HBITMAP)SelectObject(DrawDC, orig);<br />
<br />
orig = (HBITMAP)SelectObject(DrawDC, bitmap);<br />
BitBlt(wobj.getBackHDC(), x, y, wid, hgt, DrawDC,0,0,SRCPAINT);
<br />
bitmap = (HBITMAP)SelectObject(DrawDC, orig);<br />
}<br />
I've tried creating the global DrawDC as variable local to the DrawTransparentBitmap function; this has no effect.
The problem is almost certainly that the mask is somehow being screwed up in its creation.
Does anyone have any ideas about what might be wrong? Am I missing some bitmap "best practice" or something (like selecting the original bitmap handles back into the HDCs, etc)?
KR
|
|
|
|
|
Hi there,
I am working on an application that checks the task manager process list and if more than one copy of an .exe file is running, it could close them all and restart it again so that just one copy be running. I could do the part that if one specified application is closing, my program can restart it but I have problem when multiple (the same application) .exe file run sometimes and makes trouble for me.
Any help would be appreciated,
Regards,
Nahitan
|
|
|
|
|
So why not be proactive rather than reactive? In other words, why not just disallow multiple instance to begin with?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
And if an application closes all other instances of itself, how could there ever be multiple
instances of itself?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
the problem is that when customer in some circomstances closes the application by clicking on x, the application looks like to be oppened but it is still running in process list and when they attempt to reopen the appplication, two would be running and so on. the problem is that this just happen sometimes and not all the time. I could not be able to duplicate the problem in my work station and can not understand what really happens.
Regards,
|
|
|
|
|
see ma frnd there are many ways to do that, but what is ur req, one way u can query the process list of system to find the instance, 2nd u can setup a hook to taskman or read the taskman list get the pid and kill it, let me knw, i wil give u the code, i will try not promise
|
|
|
|
|
thanks for the help I think it is good to check the task manager's process list and if multiple copy of the program are running kill it and reopen it.
regards,
|
|
|
|
|
You said you check for does your program is exist or no
I think some days ago I saw a thread on the codeproject about this search on the comments for see this thread.
|
|
|
|
|
in the thread ...
CString ThreadStr ;
ThreadStr = "hiya" ;
PostMessage((HWND)lParam,WM_USER_MYTHREAD_MESSAGE,NULL,(LPARAM)new CString(ThreadStr)) ;
in the dialog ...
LRESULT MyAppDlg::OnMyThreadMessage(WPARAM wParam, LPARAM lParam)
{
CString* cs = (CString*)lParam;
How do I delete the new CString() ?
|
|
|
|
|
daveyerwin wrote: LRESULT MyAppDlg::OnMyThreadMessage(WPARAM wParam, LPARAM lParam)
{
CString* cs = (CString*)lParam;
delete cs;
codito ergo sum
|
|
|
|
|
5!
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hello,
I have an application built with Framework1.1.
1. Will my application work in a machine where only 2.0 is present?
2. what are the steps i must do in order to make my 1.1 application work
with 2.0?
Thanks!
|
|
|
|
|