kishan66
asked on
can i do C++ windows application programming in VC++ 2008
I am trying to devlelop an win32 application which captures my Image(continuous) using webcam and shows on my screen using C++.
So, do you suggest me to Use C++ in VC++2008 or directly do it in VC++2008?
if i use former case, will there be any compatibility issues?
So, do you suggest me to Use C++ in VC++2008 or directly do it in VC++2008?
if i use former case, will there be any compatibility issues?
ASKER
i am new to this C++ world.
i have VC++2008 in my system. and as i menstioned above i have make that application.(using webcam)
So if i search online i could able to find some examples in c++ and im not sure i can use those examples directly in VC++ (with out any comaptability issues).
i have VC++2008 in my system. and as i menstioned above i have make that application.(using webcam)
So if i search online i could able to find some examples in c++ and im not sure i can use those examples directly in VC++ (with out any comaptability issues).
Well, any code you have which doesn't use any OS-specific (except Windows) or IDE-specific (except VS 2008) or compiler specific (except MS Compiler) functions, headers, libraries or keywords should be usable without problems.
Even for the things I mentioned as 'except' can be incompatible with the code you gonna write, i.e. if you don't use UNICODE but the foreign code you want to use or if you don't build for 64-bit support but the foreign code is designed especially for 64-bit support.
Anyway, a lot of very useful code which can be found in the Internet is either platform independant or is already VS 2008 conform or can be adopted to VS 2008 without too much trouble.
As long as you want to write an application for Win32 and it seems you already have a VS 2008 I would suggest to use it. Some more specific decisions may be whether to use i.e. Managed C++ (for use with .NET) or MFC or ATL or some other VS 2008 specific stuff. So, i.e. if you don't want to use MFC you for sure can't use any code which uses MFC directly ...
Hope that helps,
ZOPPO
Even for the things I mentioned as 'except' can be incompatible with the code you gonna write, i.e. if you don't use UNICODE but the foreign code you want to use or if you don't build for 64-bit support but the foreign code is designed especially for 64-bit support.
Anyway, a lot of very useful code which can be found in the Internet is either platform independant or is already VS 2008 conform or can be adopted to VS 2008 without too much trouble.
As long as you want to write an application for Win32 and it seems you already have a VS 2008 I would suggest to use it. Some more specific decisions may be whether to use i.e. Managed C++ (for use with .NET) or MFC or ATL or some other VS 2008 specific stuff. So, i.e. if you don't want to use MFC you for sure can't use any code which uses MFC directly ...
Hope that helps,
ZOPPO
The MS Visual Studio 2008 contains the Visual C++ version 9. It implements the C++ standard very well. If you do not have any special objections, you should use the IDE (the editor from Visual Studio).
If you never developed an application for Windows, you may find some problems with the basics. Anyway, when you get some C++ sources for Windows, it is likely that you will be able to compile it using VC++ 9.
Do not forget to install the Visual Studio 2008 service pack 1.
If you never developed an application for Windows, you may find some problems with the basics. Anyway, when you get some C++ sources for Windows, it is likely that you will be able to compile it using VC++ 9.
Do not forget to install the Visual Studio 2008 service pack 1.
ASKER
Thanks for the suggestion.
let me start working on it and will get back to you if i have any doubts.
Thank you once again.
let me start working on it and will get back to you if i have any doubts.
Thank you once again.
>>>> i could able to find some examples in c++ and im not sure i can use those examples directly in VC++
You rarely will find VC9 samples on the net. Most samples are VC6 (released 1998) where you'll get some compatibility issues, e. g. if you used a for loop like
for (int i = 0; i < 10; ++i)
the 'i' was only valid for the for loop in VC9 while it was valid beyond for loop in VC6. Then, the STL (Standard Template Library) changed pretty much from VC6 to VC8 what might give some tricky issues most of them when compiling (thank heavens).
If you got samples from non-MS compilers you have bad cards if they use a own windows library. If the author of the code doesn't provide a VC project file with the sample you most probably have lost. Nevertheless you could use the code to learn how to implement but rarely have a chance to get it built (with reasonable efforts).
Samples from VC7 (VS2003) or VC8 (VS2005) should have less to no compatibility issues if they were 'unmanaged' (normal) C++. When using managed C++ (what actually is a different language with some similarities in syntax) the differences are bigger.
You rarely will find VC9 samples on the net. Most samples are VC6 (released 1998) where you'll get some compatibility issues, e. g. if you used a for loop like
for (int i = 0; i < 10; ++i)
the 'i' was only valid for the for loop in VC9 while it was valid beyond for loop in VC6. Then, the STL (Standard Template Library) changed pretty much from VC6 to VC8 what might give some tricky issues most of them when compiling (thank heavens).
If you got samples from non-MS compilers you have bad cards if they use a own windows library. If the author of the code doesn't provide a VC project file with the sample you most probably have lost. Nevertheless you could use the code to learn how to implement but rarely have a chance to get it built (with reasonable efforts).
Samples from VC7 (VS2003) or VC8 (VS2005) should have less to no compatibility issues if they were 'unmanaged' (normal) C++. When using managed C++ (what actually is a different language with some similarities in syntax) the differences are bigger.
ASKER
How should i load list of the Web cam(s) available in a system into ComboBox suing VC++
ASKER
Is there a way we can do that. or its not possible?
You can get a list of these by enumerating the capture drivers (which stand for their respective cameras), e.g.
#include <vfw.h>
#prahma comment(lib,"vfw32.lib")
#define MAXCAPDRIVERS 10 // maximum drivers list size
int j;
char szName[80];
char szVer[80];
for (j =0; j < MAXCAPDRIVERS; j++)
if (capGetDriverDescription (j,
szName, sizeof (szName),
szVer, sizeof (szVer)))
{
SendMessage(hMyComboBox,CB_ADDSTRING,0,szName);
}
ASKER
cannot convert parameter 5 from 'TCHAR [2048]' to 'LPSTR'
WideCharToMultiByte(CP_ACP ,0,var.bst rVal, -1, str, 2048, NULL, NULL);
im getting while building video application through webcam using DirectShow
WideCharToMultiByte(CP_ACP
im getting while building video application through webcam using DirectShow
Can you show more of your code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi itsmeandnobodyelse,
Thanks for the prompt reply.
but things you mentioned are not clear.....
i am using Vs 2008. I even tried to change the Project Properties to "Character set = Multi byte Char Set" but no use.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----------
Error "cannot convert parameter 5 from 'TCHAR [2048]' to 'LPSTR' ".
-------------------------- ---------- ---------- ---------- ---------- ---------- ----------
Thanks for the prompt reply.
but things you mentioned are not clear.....
i am using Vs 2008. I even tried to change the Project Properties to "Character set = Multi byte Char Set" but no use.
--------------------------
Error "cannot convert parameter 5 from 'TCHAR [2048]' to 'LPSTR' ".
--------------------------
#include <atlbase.h>
#include <dshow.h>
#include <d3d9.h>
#include <vmr9.h>
....
....
...
int CVMR_Capture::EnumDevices(HWND hList)
{
if (!hList)
return -1;
int id = 0;
// enumerate all video capture devices
CComPtr<ICreateDevEnum> pCreateDevEnum;
// ICreateDevEnum *pCreateDevEnum;
HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
IID_ICreateDevEnum, (void**)&pCreateDevEnum);
if (hr != NOERROR)
{
return -1;
}
CComPtr<IEnumMoniker> pEm;
hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,
&pEm, 0);
if (hr != NOERROR)
{
return -1 ;
}
pEm->Reset();
ULONG cFetched;
IMoniker *pM;
while(hr = pEm->Next(1, &pM, &cFetched), hr==S_OK)
{
IPropertyBag *pBag;
hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);
if(SUCCEEDED(hr))
{
VARIANT var;
var.vt = VT_BSTR;
hr = pBag->Read(L"FriendlyName", &var, NULL);
if (hr == NOERROR)
{
TCHAR str[2048];
id++;
WideCharToMultiByte(CP_ACP,0,var.bstrVal, -1, str, 2048, NULL, NULL);
(long)SendMessage(hList, CB_ADDSTRING, 0,(LPARAM)str);
SysFreeString(var.bstrVal);
}
pBag->Release();
}
pM->Release();
}
return id;
}
ASKER
Hi ,
in the code when i tried to change TCHAR str[2048] to char str[2048](line 53) my errors have increased.
these are the errors ----
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _IID_IMediaEventEx
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _IID_IMediaControl
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _CLSID_FilterGraph
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _IID_IGraphBuilder
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _IID_IVMRWindowlessControl
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _IID_IVMRFilterConfig
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _CLSID_VideoMixingRenderer
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _IID_IBaseFilter
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _CLSID_VideoInputDeviceCat egory
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _CLSID_SystemDeviceEnum
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _IID_ICreateDevEnum
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _IID_IAMStreamConfig
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _FORMAT_VideoInfo
1>C:\Documents and Settings\Ratan\My Documents\Visual Studio 2008\Projects\Dialog\Debug \Dialog.ex e : fatal error LNK1120: 13 unresolved externals
in the code when i tried to change TCHAR str[2048] to char str[2048](line 53) my errors have increased.
these are the errors ----
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _IID_IMediaEventEx
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _IID_IMediaControl
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _CLSID_FilterGraph
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _IID_IGraphBuilder
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _IID_IVMRWindowlessControl
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _IID_IVMRFilterConfig
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _CLSID_VideoMixingRenderer
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _IID_IBaseFilter
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _CLSID_VideoInputDeviceCat
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _CLSID_SystemDeviceEnum
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _IID_ICreateDevEnum
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _IID_IAMStreamConfig
1>VMR_Capture.obj : error LNK2001: unresolved external symbol _FORMAT_VideoInfo
1>C:\Documents and Settings\Ratan\My Documents\Visual Studio 2008\Projects\Dialog\Debug
To get rid of these, be sure to add
#include <initguid.h>
tp the top of your main source file and link with 'dxguid.lib', e.g.
#pragma comment(lib,"dxguid.lib")
(or add that lib to your project)
#include <initguid.h>
tp the top of your main source file and link with 'dxguid.lib', e.g.
#pragma comment(lib,"dxguid.lib")
(or add that lib to your project)
ASKER
changes made::::
- changed TCHAR str[] to char str[];
-i have added the #include <initguid.h> to the source file
-and linked "dxguid.lib" in the additional dependencies and given its location in the additional Library Directories of the Project Properties.
but still the same errors
- changed TCHAR str[] to char str[];
-i have added the #include <initguid.h> to the source file
-and linked "dxguid.lib" in the additional dependencies and given its location in the additional Library Directories of the Project Properties.
but still the same errors
Sorry, forgot one detail, add #define INITGUID before the #include directive, e.g.
#define INITGUID
#include <initguid.h>
ASKER
No use. same errors
is that trying to passing a UNICODE string to a function expecting an ANSI string.
i mean does LPSTR expects an ANSI string.
can you plz explain me the cause of the error too.
is that trying to passing a UNICODE string to a function expecting an ANSI string.
i mean does LPSTR expects an ANSI string.
can you plz explain me the cause of the error too.
ASKER
whtzup guys!!!!!!!!!!!!
Is there a way we can get rid of this error.
please let em know ..im just hanging in here
Is there a way we can get rid of this error.
please let em know ..im just hanging in here
ASKER
Solved it.
I could able to get it from some other site.
Though we include <dshow.h> in the header file we have to explicitly tell the compiler about the IID's by specifying the .lib file
#pragma comment(lib,"Strmiids.lib" )
though no errors...Devices are not loaded into my combobox. i mean some weird charecters are loaded .
but i webcam i able to capture my image live.
any info regarding this.
I could able to get it from some other site.
Though we include <dshow.h> in the header file we have to explicitly tell the compiler about the IID's by specifying the .lib file
#pragma comment(lib,"Strmiids.lib"
though no errors...Devices are not loaded into my combobox. i mean some weird charecters are loaded .
but i webcam i able to capture my image live.
any info regarding this.
In this case (regarding the "weird characters", I assume mixing charsets incorrectly) try
VARIANT var;
var.vt = VT_BSTR;
hr = pBag->Read(L"FriendlyName", &var, NULL);
if (hr == NOERROR)
{
id++;
(long)SendMessage(hList, CB_ADDSTRING, 0,(LPARAM)var.bstrVal);
SysFreeString(var.bstrVal);
}
pBag->Release();
ASKER
why do we have to add "L" before a string for LPCWSTR (ex- L"Friendly name")
That is because when UNICODE string literals are required, they are prefixed by that 'L' to indicate that they are UNICODE and not ASCII.
ASKER
Thanks for the suggestion. it solved part of the problem...
fyi, along with changing TCHAR to char also chage the Charecter set to MultiByte and also add #pragma comment(lib,"Strmiids.lib" ) to the header file.
fyi, along with changing TCHAR to char also chage the Charecter set to MultiByte and also add #pragma comment(lib,"Strmiids.lib"
????
You had serveral questions here, and several people contributed.
You had serveral questions here, and several people contributed.
ASKER
Hi jkr,
thanks for helping .!!
but i was not aware that i only can accept one solution.
thanks for helping .!!
but i was not aware that i only can accept one solution.
You can accept more than one, see https://www.experts-exchange.com/Community_Support/help.jsp
please clearify what you mean - I don't understand the difference between 'Use C++ in VC++2008' and 'directly do it in VC++2008' ...
ZOPPO