|
Looks like it's based on the project that I found. Look at the edited post above this one for comments. As I mentioned earlier look at EnumCapDrv, it calls capGetDriverDescription() to get devices.
From looking at the API again though, my initial idea is wrong. Looks like you specify the device from the index.
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);
}
}
}
Anyway i think the code is a bit buggy.
SendMessage( hwndSelCapDrvDlg_LBox, LB_GETSELITEMS, 1, sel);
Shouldn't it be
SendMessage( hwndSelCapDrvDlg_LBox, LB_GETSELITEMS, 1, &sel);
Actually I think he should have just used a single selection listbox and use the LB_GETCURSEL message to get the current selection. Anyway, if it happens that your problem was that you couldn't select anything other than the first device, then this might be the reason.
-- modified at 5:26 Thursday 4th May, 2006
|
|
|
|
|
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 .
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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()
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.
|
|
|
|
|
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 .
|
|
|
|
|
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?
|
|
|
|
|
when I put camIndex , nonzero , it doesn't work , but windows recognizes
both of webcams .
|
|
|
|
|
Um. Windows recognizes both webcams as in... they both have VFW drivers? Did you see the webcams listed in the listbox of this application?
|
|
|
|
|
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.
|
|
|
|
|
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?
|
|
|
|
|
it reaches the breakpoint when i=0 and it doesn't reach in i=1
|
|
|
|
|
And there we have it. One of your webcams only has a WDM driver. You would have to write a DirectShow application.
|
|
|
|
|
how can I write a DirectShow program , If you have time , please tell me .
thank you
|
|
|
|
|
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.
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
i need help on chngin for loop in this file to while loop..plz solve this for me as soon as possible...i trien in many ways but cant...
#include <ctime> <br />
#include <iostream><br />
#include <string><br />
#include <algorithm><br />
#include <fstream><br />
using namespace std;<br />
<br />
time_t tmStart, tmEnd;<br />
<br />
<br />
<br />
void DoStuff()<br />
{<br />
tmStart = time(0);<br />
ifstream fin;<br />
fin.open("data.txt",ios::in);<br />
<br />
ofstream File("MyFile.txt",ios::out);<br />
<br />
<br />
char str[14];<br />
<br />
fin.getline(str,sizeof(str),'\n');<br />
<br />
<br />
string line(str);<br />
cout << str<<endl;<br />
<br />
<br />
<br />
for (int i=0; i<5000; ++i)<br />
{<br />
random_shuffle(line.begin(), line.end());<br />
File << "Randomised: " << line << endl;<br />
File << " : " << line << endl;<br />
File << " : " << line << endl;<br />
File << " : " << line << endl;<br />
File << " "<< endl;<br />
<br />
File << " "<< endl;<br />
<br />
<br />
<br />
tmEnd = time(0);<br />
cout << tmEnd-tmStart << " seconds (that was fast!)" << endl;<br />
<br />
} <br />
File.close ();<br />
fin.close ();<br />
<br />
}<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
DoStuff();<br />
<br />
return 0;<br />
<br />
}<br />
<br />
<br />
|
|
|
|
|
Mmmmh... At first glance, this is not even easy, it is trivial... smells like homework ... please post your code that does not work with your while attempt, and we will help you.
~RaGE();
|
|
|
|
|
i know its sumthing about this but i dont knw how to implement it..
{<br />
char str[2000];<br />
fstream file_op("c:\\test_file.txt",ios::in);<br />
while(!file_op.eof()) <br />
{<br />
file_op.getline(str,2000);<br />
cout <<str;<br />
} file_op.close();<br />
cout <<endl;<br />
<br />
|
|
|
|
|
Please, stop asking things you don't even understand. Take a C++ book and start reading it.
How will you learn if people make the complete program for you (this is what is happening right now, looking at the number of questions you already asked for such a trivial code snippet).
|
|
|
|
|
i am learning...give me any hint on this...
|
|
|
|