Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. selecting a device without UI

selecting a device without UI

Scheduled Pinned Locked Moved C / C++ / MFC
designhelpquestion
29 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V V_shr

    I looked my code , it was the correct one . and my problem isn't that I change the default device but it doesn't change , my problem is that I dont know how to change that .

    J Offline
    J Offline
    Justin Tay
    wrote on last edited by
    #12

    Reread my previous posts (I might have modified them after you read them) and tell me which part you don't understand. What do you mean by "your code was the correct one"? Setting the device just involves setting the index 'i' in the WM_CAP_DRIVE_CONNECT message.

    SendMessage( hwndVideo, WM_CAP_DRIVER_CONNECT, i, 0L);

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_wm_cap_driver_connect.asp[^] As I said before use capGetDriverDescription() to figure out which index your device corresponds to. -- modified at 6:21 Thursday 4th May, 2006

    V 1 Reply Last reply
    0
    • J Justin Tay

      Reread my previous posts (I might have modified them after you read them) and tell me which part you don't understand. What do you mean by "your code was the correct one"? Setting the device just involves setting the index 'i' in the WM_CAP_DRIVE_CONNECT message.

      SendMessage( hwndVideo, WM_CAP_DRIVER_CONNECT, i, 0L);

      http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_wm_cap_driver_connect.asp[^] As I said before use capGetDriverDescription() to figure out which index your device corresponds to. -- modified at 6:21 Thursday 4th May, 2006

      V Offline
      V Offline
      V_shr
      wrote on last edited by
      #13

      I cant find similarity of our sources , and when you refer to somthing in code I cant find where you are saying . and because I didn't work on devices befor this I cant guess what are you saying. can you say it simpler ? thank you

      J 1 Reply Last reply
      0
      • V V_shr

        I cant find similarity of our sources , and when you refer to somthing in code I cant find where you are saying . and because I didn't work on devices befor this I cant guess what are you saying. can you say it simpler ? thank you

        J Offline
        J Offline
        Justin Tay
        wrote on last edited by
        #14

        More like working with Video For Windows API in this case. Devices is too generic a term. In fact most people do this using DirectShow instead of VFW these days. My suggestion to how to get the device index that you want.

        for (i=0; i<10; i++)
        {
        if(capGetDriverDescription(i, szDeviceName, sizeof(szDeviceName), szDeviceVersion, sizeof(szDeviceVersion)) )
        {
        if(strcmp(szDeviceName, "MyDeviceName") == 0)
        {
        SendMessage( hwndVideo, WM_CAP_DRIVER_CONNECT, i, 0L);
        break;
        }
        }
        }

        Look at this to see how he enumerates the Video For Windows devices main.cpp: Line 185

        int TForm1::EnumCapDrv() // enumerate the installed capture drivers

        main.cpp: Line 118

        SendMessage( hwndVideo, WM_CAP_DRIVER_CONNECT, sel, 0L);

        main.cpp: Line 115

        SendMessage( hwndSelCapDrvDlg_LBox, LB_GETSELITEMS, 1, sel);

        Should be

        SendMessage( hwndSelCapDrvDlg_LBox, LB_GETSELITEMS, 1, &sel);

        Or it will only set the device to index 0, as sel was initialised to 0.

        V 1 Reply Last reply
        0
        • J Justin Tay

          More like working with Video For Windows API in this case. Devices is too generic a term. In fact most people do this using DirectShow instead of VFW these days. My suggestion to how to get the device index that you want.

          for (i=0; i<10; i++)
          {
          if(capGetDriverDescription(i, szDeviceName, sizeof(szDeviceName), szDeviceVersion, sizeof(szDeviceVersion)) )
          {
          if(strcmp(szDeviceName, "MyDeviceName") == 0)
          {
          SendMessage( hwndVideo, WM_CAP_DRIVER_CONNECT, i, 0L);
          break;
          }
          }
          }

          Look at this to see how he enumerates the Video For Windows devices main.cpp: Line 185

          int TForm1::EnumCapDrv() // enumerate the installed capture drivers

          main.cpp: Line 118

          SendMessage( hwndVideo, WM_CAP_DRIVER_CONNECT, sel, 0L);

          main.cpp: Line 115

          SendMessage( hwndSelCapDrvDlg_LBox, LB_GETSELITEMS, 1, sel);

          Should be

          SendMessage( hwndSelCapDrvDlg_LBox, LB_GETSELITEMS, 1, &sel);

          Or it will only set the device to index 0, as sel was initialised to 0.

          V Offline
          V Offline
          V_shr
          wrote on last edited by
          #15

          I use two webcams in my project and want to switch between them without oppenning UI window . kindly ask to send the code for switching between two cameras .

          J 1 Reply Last reply
          0
          • V V_shr

            I use two webcams in my project and want to switch between them without oppenning UI window . kindly ask to send the code for switching between two cameras .

            J Offline
            J Offline
            Justin Tay
            wrote on last edited by
            #16

            Does sending the WM_CAP_DRIVER_CONNECT message not work?

            SendMessage(hwndVideo, WM_CAP_DRIVER_CONNECT, camIndex, 0L);

            or the macro

            capDriverConnect(hwndVideo, camIndex);

            What problems are you facing?

            V 1 Reply Last reply
            0
            • J Justin Tay

              Does sending the WM_CAP_DRIVER_CONNECT message not work?

              SendMessage(hwndVideo, WM_CAP_DRIVER_CONNECT, camIndex, 0L);

              or the macro

              capDriverConnect(hwndVideo, camIndex);

              What problems are you facing?

              V Offline
              V Offline
              V_shr
              wrote on last edited by
              #17

              when I put camIndex , nonzero , it doesn't work , but windows recognizes both of webcams .

              J 1 Reply Last reply
              0
              • V V_shr

                when I put camIndex , nonzero , it doesn't work , but windows recognizes both of webcams .

                J Offline
                J Offline
                Justin Tay
                wrote on last edited by
                #18

                Um. Windows recognizes both webcams as in... they both have VFW drivers? Did you see the webcams listed in the listbox of this application?

                V 1 Reply Last reply
                0
                • J Justin Tay

                  Um. Windows recognizes both webcams as in... they both have VFW drivers? Did you see the webcams listed in the listbox of this application?

                  V Offline
                  V Offline
                  V_shr
                  wrote on last edited by
                  #19

                  Yes I can choose between two webcams in windows UI dialog . but as mentioned above when I put the camIndex=1 it doesn't recognize it.

                  J 1 Reply Last reply
                  0
                  • V V_shr

                    Yes I can choose between two webcams in windows UI dialog . but as mentioned above when I put the camIndex=1 it doesn't recognize it.

                    J Offline
                    J Offline
                    Justin Tay
                    wrote on last edited by
                    #20

                    What windows UI dialog? Is it present in the SelCapDrvDlg in this application? Set a breakpoint in main.cpp line 199. What are the indexes of the 2 webcams you are interested in?

                    V 1 Reply Last reply
                    0
                    • J Justin Tay

                      What windows UI dialog? Is it present in the SelCapDrvDlg in this application? Set a breakpoint in main.cpp line 199. What are the indexes of the 2 webcams you are interested in?

                      V Offline
                      V Offline
                      V_shr
                      wrote on last edited by
                      #21

                      it reaches the breakpoint when i=0 and it doesn't reach in i=1

                      J 1 Reply Last reply
                      0
                      • V V_shr

                        it reaches the breakpoint when i=0 and it doesn't reach in i=1

                        J Offline
                        J Offline
                        Justin Tay
                        wrote on last edited by
                        #22

                        And there we have it. One of your webcams only has a WDM driver. You would have to write a DirectShow application.

                        V 1 Reply Last reply
                        0
                        • J Justin Tay

                          And there we have it. One of your webcams only has a WDM driver. You would have to write a DirectShow application.

                          V Offline
                          V Offline
                          V_shr
                          wrote on last edited by
                          #23

                          how can I write a DirectShow program , If you have time , please tell me . thank you

                          J 3 Replies Last reply
                          0
                          • V V_shr

                            how can I write a DirectShow program , If you have time , please tell me . thank you

                            J Offline
                            J Offline
                            Justin Tay
                            wrote on last edited by
                            #24

                            If you have VC7+, download and install the latest Platform SDK. Go to http://tmhare.mvps.org/downloads.htm[^] to get the project files for the samples since Microsoft has for some reason stripped it out. Then go have a look at the PlayCap sample application in "..\Program Files\Microsoft Platform SDK\Samples\Multimedia\DirectShow\Capture\PlayCap" If you have VC6 though, you would have to grab an old DirectX SDK, maybe 2003 or 2004.

                            V 1 Reply Last reply
                            0
                            • J Justin Tay

                              If you have VC7+, download and install the latest Platform SDK. Go to http://tmhare.mvps.org/downloads.htm[^] to get the project files for the samples since Microsoft has for some reason stripped it out. Then go have a look at the PlayCap sample application in "..\Program Files\Microsoft Platform SDK\Samples\Multimedia\DirectShow\Capture\PlayCap" If you have VC6 though, you would have to grab an old DirectX SDK, maybe 2003 or 2004.

                              V Offline
                              V Offline
                              V_shr
                              wrote on last edited by
                              #25

                              what is VC7+ and SDK

                              1 Reply Last reply
                              0
                              • V V_shr

                                how can I write a DirectShow program , If you have time , please tell me . thank you

                                J Offline
                                J Offline
                                Justin Tay
                                wrote on last edited by
                                #26

                                VC7+: Microsoft Visual C++ 2002/2003/2005 SDK: Software Development Kit http://www.microsoft.com/downloads/details.aspx?FamilyId=484269E2-3B89-47E3-8EB7-1F2BE6D7123A&displaylang=en[^]

                                V 1 Reply Last reply
                                0
                                • J Justin Tay

                                  VC7+: Microsoft Visual C++ 2002/2003/2005 SDK: Software Development Kit http://www.microsoft.com/downloads/details.aspx?FamilyId=484269E2-3B89-47E3-8EB7-1F2BE6D7123A&displaylang=en[^]

                                  V Offline
                                  V Offline
                                  V_shr
                                  wrote on last edited by
                                  #27

                                  I dont Have visual C++ , I just have visual studio .NET and CBuilder And I prefer to write this program in CBuilder . -- modified at 10:09 Thursday 4th May, 2006

                                  1 Reply Last reply
                                  0
                                  • V V_shr

                                    how can I write a DirectShow program , If you have time , please tell me . thank you

                                    J Offline
                                    J Offline
                                    Justin Tay
                                    wrote on last edited by
                                    #28

                                    Your copy of Visual Studio .NET doesn't come with the C++ compiler? I never used CBuilder before so I guess you're on your own in building/getting compatible libs. Here's a link to get you started. http://www.geocities.com/foetsch/borlibs/[^] http://clootie.narod.ru/cbuilder/index.html[^]

                                    V 1 Reply Last reply
                                    0
                                    • J Justin Tay

                                      Your copy of Visual Studio .NET doesn't come with the C++ compiler? I never used CBuilder before so I guess you're on your own in building/getting compatible libs. Here's a link to get you started. http://www.geocities.com/foetsch/borlibs/[^] http://clootie.narod.ru/cbuilder/index.html[^]

                                      V Offline
                                      V Offline
                                      V_shr
                                      wrote on last edited by
                                      #29

                                      thanks a lot

                                      1 Reply Last reply
                                      0
                                      Reply
                                      • Reply as topic
                                      Log in to reply
                                      • Oldest to Newest
                                      • Newest to Oldest
                                      • Most Votes


                                      • Login

                                      • Don't have an account? Register

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • World
                                      • Users
                                      • Groups