Windows Media Foundation recording audio

I apologize for the late response, and I hope you can still find this valuable. I recently completed a project similar to yours (recording webcam video along with a selected microphone to a single video file with audio). The key is to creating an aggregate media source. // http://msdn.microsoft.com/en-us/library/windows/desktop/dd388085(v=vs.85).aspx HRESULT CreateAggregateMediaSource(IMFMediaSource *videoSource, IMFMediaSource *audioSource, IMFMediaSource … Read more

How can we vertically align text in edit box?

I don’t have enough reputation to make a comment, so here’s a possibly useful snippet to a very old question! If you supply the WS_BORDER style then the text gets automatically vertically centred, as requested. Since the OP is using WS_EX_CLIENTEDGE, a border is drawn anyway, so adding in this style shouldn’t be a problem. … Read more

How to Run Only One Instance of Application

You may used named mutex. Code sample from the article: WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int) { try { // Try to open the mutex. HANDLE hMutex = OpenMutex( MUTEX_ALL_ACCESS, 0, “MyApp1.0”); if (!hMutex) // Mutex doesn’t exist. This is // the first instance so create // the mutex. hMutex = CreateMutex(0, 0, “MyApp1.0”); else … Read more

Dynamic menu using mfc

You can create a CMenu object dynamically like this: CMenu *menu = new CMenu; menu->CreatePopupMenu(); // Add items to the menu menu->AppendMenu(MF_STRING, menuItemID, “Text”); … Then add this sub-menu to your main menu: wnd->GetMenu()->AppendMenu(MF_POPUP, (UINT_PTR)menu->m_hMenu, “Menu Name”); As for the message map, assuming all your menu item IDs are within a certain range, you can … Read more

Difference between a C++ exception and Structured Exception

You actually have three mechanisms: C++ exceptions, implemented by the compiler (try/catch) Structured Exception Handling (SEH), provided by Windows (__try / __except) MFC exception macros (TRY, CATCH – built on top of SEH / C++ exceptions – see also TheUndeadFish’s comment) C++ exceptions usually guarantee automatic cleanup during stack unwinding (i.e. destructors of local objects … Read more

Convert String^ in c# to CString in c++/CLI

Got My answer. Thanks for your support @Elliot Tereschuk. I have gone through some references like How to: Extend the Marshaling Library Overview of Marshaling in C++ For CString.Format() and include header files #include <msclr/marshal_windows.h> #include <msclr/marshal.h> using Library using namespace msclr::interop; And finally My source code is. String^ csPass = gcnew String(strPassword.GetBuffer()); array<Byte>^ Value … Read more

Using a Qt-based DLL in a non-Qt application

Studying the Qt code it seems QCoreApplication is needed to dispatch system-wide messages such as timer events. Things like signal/slots and even QThreads do not depend on it unless they are related to those system-wide messages. Here is how I do this in a shared library (in a cross platform way using Qt itself) and … Read more