|
I'm trying to use Video for Windows to capture images from a webcam on a timed interval (using a WM_TIMER message). To try and capture the image I'm basically using:
capFileSaveDIB(hWndC,"filename.bmp");
This works perfectly well if the application (MFC dialog) is active when the message is fired, but if the window is not active or minized, the image is not capture. I've looked through the VFW documentation on MSDN, but I can't find any mention of this problem.
Any ideas how I can capture the image while the application is minimized?
Thanks
modified 12-Jul-20 21:01pm.
|
|
|
|
|
This is what I'm getting. The code works fine when I create a seperate Windows application, but when I bring the file into my other project I get this weird error. Also it's just a .c file so how can I include it? Do I just #include <waveply1.cpp> so I can use the functions?
--------------------Configuration: 3daudio - Win32 Debug--------------------
Compiling...
WavePly1.cpp
c:\program files\microsoft visual studio\myprojects\3daudio\waveply1.cpp(328) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.
WavePly1.obj - 1 error(s), 0 warning(s)
|
|
|
|
|
Try putting a #include "stdafx.h" at top. What is happening is that you project (as all default VC++ projects) is set to use precompiled headers. "stdafx.h" is your master precompiled header.
|
|
|
|
|
Okay that worked thanks. Now that I have a free-floating .c file, I thought I could just change main() to a regular function. This is what's happening now is that easy to figure out?
--------------------Configuration: 3daudio - Win32 Debug--------------------
Compiling...
3daudioDlg.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\3daudio\3daudioDlg.cpp(222) : error C2065: 'playmain' : undeclared identifier
Error executing cl.exe.
3daudio.exe - 1 error(s), 0 warning(s)
|
|
|
|
|
You are using "playmain" which has not been previously defined. You can't do that.
|
|
|
|
|
Hi,
I new to programming...Pls bare with me for this is really a basic question in pointers..
In my program I have a global variable
char *gz_Nos[10];
I need to assign some strings(like '000001','000002'...) to this array in one of my function and check the values in other function..
so I did as follows..ie my .cpp
char *gz_Nos[10];
mycalss::myclass(){}
mycalss::~myclass(){}
int myclass::func1()
{
char t_str[MAX_STRLEN];
for(i=0;i<2;i++)
{
wsprintf(t_str,"00000%d",i+1);
gz_Nos[i]=t_str;
}
return 1;
}
int myclass::func2()
{
char *sz_no;
int i=0;
.....
sz_no = "000001"
for(i=0;i<2;i++)
{
if(sz_no == gz_Nos[i])
{
MessageBox(0,"Error","Error",MB_OK) ;
return 0;
}
}
}
But here I couldnt see the value of gz_Nos[i] in func2..I am calling func1 first and then func2.And also in func1 if I display the value of gz_Nos[0] it displays '000002'. Where am I going wrong...
Thanks a lot.
|
|
|
|
|
Well for starters you are assigning a local variable (t_str) to your array of strings (gz_Nos), as soon as you exit the function, the compiler unwinds the stack and your left with a corrupt string. Try using something like char* t_str = new char[MAX_STRLEN], and make sure to call delete[] t_str when you no longer need it. Strings, memory and pointers are complicated beasts. Check out some good books, like Stroustrup's novel.
|
|
|
|
|
Hi everybody, i need your help. Im trying to change the desktop wallpaper, but i must use the IActiveDesktop interface, and i dont know what files i must include in the header, in the msdn help, they tell me, that i must include shlobj.h but with that it doesnt work. If some body can help me i will be gratefull.
|
|
|
|
|
|
|
|
Hi,
I'm sharing an object between 2 threads and I need to synchronize it. The following is a model of my code:
<br />
class SynchronizedObject<br />
{<br />
<pre>SynchronizedObject()
{<br />
InitializeCriticalSection(&m_ThreadSynch);<br />
}<br />
<br />
CRITICAL_SECTION m_ThreadSynch;<br />
void Lock()<br />
{<br />
::EnterCriticalSection(&m_ThreadSynch);<br />
}<br />
void Unlock()<br />
{<br />
::LeaveCriticalSection(&m_ThreadSynch);<br />
}</pre><br />
<br />
void A()<br />
{<br />
Lock();<br />
B();<br />
Unlock();<br />
}<br />
<br />
void B()<br />
{<br />
Lock();<br />
Unlock();<br />
}<br />
};<br />
For some reason when I call A() my code doesn't lock up. Am I using the Critical Section incorrectly? Or does it check which thread is trying to enter the critical section and allows the same thread to enter it multiple times (which I thought wasn't the case). What about Mutexes? Aside from synchronizing accross processes do they behave differently? What about Semaphores?
Note: I've also tried to just put a member object CCriticalSection synch; and call synch.Lock()/Unlock() where appropriate. Same result.
|
|
|
|
|
Critical sections block separate threads from entering the critical section, not the same thread.
None of the synchronization objects, near as I ever read, will block the same thread from entering them.
Mutexes behave differently because they can be 'abandoned'.
If the process owning a mutex exits before releasing the mutex, another process waiting for it will be rleased with the result WAIT_ABANDONED.
Semaphores are for controlling 'metered access' to an object.
Now, in your instance, if Thread 2 called B(), then Thread1 would not be able to enter A() until Thread2 was done processing B(). Likewise, if Thread1 entered A() first, then thread2 could not enter A() or B() until Thread1 was done with A().
|
|
|
|
|
|
If you want your thread to lock up, use a semaphore object and the WairFor... functions. They don't allow a thread to enter the critical section twice when the state of the Semaphore is non-signaled.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Thanks for your replies. I didn't want the thread to lock up so this is perfect, but I wanted to confirm that that's how it worked and I'm not missing some small part of code.
|
|
|
|
|
Hi,
How can I show hidden folders when calling SHBrowseForFolder function?
Thanks.
Lynsen
|
|
|
|
|
|
I need to create a source to the <targetdir>data.mdb in Installshield.
I'm thinking either a function call, or directly adding Registry entries(yuck)
Can anyone help?
|
|
|
|
|
You need to call the SQLConfigDataSource function:
BOOL bStat = SQLConfigDataSource(NULL,
ODBC_ADD_DSN,
"Microsoft Access Driver (*.mdb)",
szDSNName);
|
|
|
|
|
Thanks for the function, but I was hoping to do this in Installshield (I'm using version 6 for C++).
The users won't have Admin access, so it has to be setup when I install it.
The registry screen in IS only allows 1 key below HKLM. There's a bunch of Reg functions in the help I can try.
|
|
|
|
|
Hi All,
there's anybody who knows if there is a way to set the font style (size, stuff like that) in a CListCtrl item?
Thanks a lot!
cheers!
|
|
|
|
|
Use .SetFont() on the control. It is going to want a CFont, you can call CFont's CreatePointFont(), or if your feeling picky call CreateFont() with 14 arguments of font flexibility.
|
|
|
|
|
Thanks Mark!
works good!
cheers!
|
|
|
|
|
I'm trying to load up a GDI+ bitmap using a pathname, and it does not work.
Here is what I try to do:
Bitmap bitmap(L"Images\\picture.bmp");
What DOES work is:
Bitmap bitmap(L"picture.bmp");
i.e., if the bitmap is in the same directory as the program
Bitmap bitmap(L"C:\\Images\\picture.bmp");
i.e., providing the full path name from the C drive
However, I cannot load it up from the base directory of the program for some reason. The picture is, of course, in the folder, and it works if I specify the entire path name starting from C drive, but not if I attempt to start from the program's directory.
Help ??
Thanks
|
|
|
|