c++ - Create borderless DirectShow Window -


i referring simple video player using directshow example provided here.

the code runs , builds need make video player window borderless.

i not find parameter set in cocreateinstance function or coinitialize function can set make window borderless.

here complete code reference:

#include <dshow.h> #pragma comment (lib, "strmiids.lib") void main(void) {     igraphbuilder *pgraph = null;     imediacontrol *pcontrol = null;     imediaevent   *pevent = null;      // initialize com library.     hresult hr = coinitialize(null);     if (failed(hr))     {         printf("error - not initialize com library");         return;     }      // create filter graph manager , query interfaces.     hr = cocreateinstance(clsid_filtergraph, null, clsctx_inproc_server,         iid_igraphbuilder, (void **)&pgraph);     if (failed(hr))     {         printf("error - not create filter graph manager.");         return;     }      hr = pgraph->queryinterface(iid_imediacontrol, (void **)&pcontrol);     hr = pgraph->queryinterface(iid_imediaevent, (void **)&pevent);      // build graph. important: change string file on system.     hr = pgraph->renderfile(l"d:\\dfs.avi", null);     if (succeeded(hr))     {         // run graph.         hr = pcontrol->run();         if (succeeded(hr))         {             // wait completion.             long evcode;             pevent->waitforcompletion(infinite, &evcode);              // note: not use infinite in real application, because             // can block indefinitely.         }     }     pcontrol->release();     pevent->release();     pgraph->release();     couninitialize(); } 

what additional piece of code need add in order achieve this?

i found code here job!

#pragma comment(lib, "strmiids.lib") #pragma comment(lib, "quartz.lib")  #include <string> #include <dshow.h>   int playvideo(const std::string& pfile) {     igraphbuilder* pgraph = null;     ivideowindow* pwin = null;     imediacontrol* pcontrol = null;     imediaevent* pevent = null;      // initialize com library.     hresult hr = coinitialize(null);     if (failed(hr)) return 1;      // create filter graph manager , query interfaces.     hr = cocreateinstance(clsid_filtergraph, null, clsctx_inproc_server, iid_igraphbuilder, (void **)&pgraph);     if (failed(hr)) return 1;      // interfaces     hr = pgraph->queryinterface(iid_imediacontrol, (void **)&pcontrol);     hr = pgraph->queryinterface(iid_imediaevent, (void **)&pevent);     hr = pgraph->queryinterface(iid_ivideowindow, (void **)&pwin);      // build graph (convert unicode filename)     size_t _size = mbstowcs(null,pfile.c_str(),2); // add 2 zt     wchar_t* _wfile = new wchar_t[_size + 2];     _size = mbstowcs(_wfile, pfile.c_str(), pfile.length() + 1); // add 1 zt     hr = pgraph->renderfile(_wfile, null);     delete[] _wfile;      // uncomment next line borderless window display     pwin->put_windowstyle(ws_child | ws_clipsiblings);      // fullscreen play, windows screen parameters , replace     pwin->setwindowposition(0, 0, 800, 600);      if (succeeded(hr))     {         hr = pcontrol->run();         if (succeeded(hr))         {             long evcode;             pevent->waitforcompletion(infinite, &evcode);         }     }      pcontrol->release();     pevent->release();     pwin->release();     pgraph->release();     couninitialize();      return 0; }   int main() {     playvideo("d:\\dfs.avi"); // play format windows can handle, avi/mpg etc.     return 0; } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -