|
I'm guessing that you selected the project type as Windows Application and wrote a main function.
Windows applications expect to find WinMain instead of main .
You can either create a project of type Console Application or change main to WinMain .
|
|
|
|
|
Start here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
|
In case I have asked this before, but OF does not remember, accept my apology.
I believe this is pretty generic situation so I ll try to explain it without code.
I have VFW capAPI which registers a callback function and than initializes the callback rate.
The callback function allows me to modify the data before it is displayed.
I have not figured out how this display really works, but it does, non issue for now.
The callback rate is adjustable in milliseconds, and if I set it to 20 and let the callback function just return, without modifying the data, in debug mode, the display goes from good bitmap to blank pretty rapidly.
If I set the rate to 2 seconds there still are occasional blank screens.
I was under the impression that callbacks are executed by the system when data became available, but it seem that in VFW API the rate executes the callback even with no or bad data.
I did check that and one of the parameters in the callback – number of bytes actually used _ is “a lot less” than when true number of bytes used.
So even if I check for “blanks / invalid “ data I will still have problem unless I can keep track of good data and substitute them for bad ones.
I am just posting this in case someone has an experience with this behavior.
This seems to be a major issue in VFW , but replacing VFW with DirectX is not an option.
I would also like to know how to access the callback function return value.
The function is defined as global. Do I need to make it static class function to be able to use the return value?
Is it also possible that I am missing some “buffers”? I recall having a great time using another AVI. Maybe I need to shrink my bitmap.
Thanks for your time, appreciate it.
Cheers Vaclav
|
|
|
|
|
CTempLock (&(this->m_Lock));
m_Lock a CCriticalSection.
There is a variable without name? what is it?
|
|
|
|
|
yu-jian wrote: There is a variable without name? What exactly are you referring to?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
That code creates (and destroys) a temporary CTempLock object. The net effect is the call of the class constructor and destructor. Try the following code:
#include <iostream>
using std::cout;
using std::endl;
class A
{
public:
A(){cout << "ctor" << endl;}
~A(){cout << "dtor" << endl;}
};
int main()
{
A();
}
Veni, vidi, vici.
|
|
|
|
|
It's the same with my code. But i am silly why the c plus plus allow defining a variable without name?
|
|
|
|
|
For instance, this allows you writing:
vector <A> v;
v.push_back(A());
Veni, vidi, vici.
|
|
|
|
|
Do you think that it's right? ~A() will be called after A() immediately.
|
|
|
|
|
yu-jian wrote: why the c plus plus allow defining a variable without name?
It isn't doing that.
You are confusing 'variable' with 'expession'.
In the following the left 'x' is a varible while the right side is an expression. The execution of the expression is not dependent upon the variable. The variable is just where the result of the expression is stored.
x = doSomething();
|
|
|
|
|
Your line with "CTempLock (&(this->m_Lock));" will create an unnamed variable of type CTempLock, call the destructor specified, and then call the destructor and destroy the object.
As another poster pointed out, using a constructor reference in this way, is supported as a means to pass temporary objects to a function.
The temporary object only exists on the stack, long enough to make a function call, that is intended to use the temporary object as a reference.
modified 16-Jan-13 17:28pm.
|
|
|
|
|
Right. Perhaps, it can use this way to do something in the constructor function of CTempLock.
|
|
|
|
|
Yes.
1. The object is created on the stack.
2. The constructor is called.
3. The destructor is called.
4. The object is then forgotten.
The example you provided is a good demo of how you can introduce locking bugs. Because the object goes out of scope right away, it doesn't really do anything useful.
The proper way to do it is:
CTempLock Lock(&(this->m_Lock));
If you do something like this...
void ProcessLock(const CTempLock & TempLock)
{
}
ProcessLock(CTempLock(&(this->m_Lock)));
Then the temporary object will exist for the lifetime of the call.
|
|
|
|
|
{
CTempLock tempLock(&m_FrameListLock);
if (m_FrameQueue.size() == 0) return 0L;
pFrameData = m_FrameQueue.front();
m_FrameQueue.pop_front();
}
if (WaitForSingleObject(this->m_hCloseEvent, 0) == WAIT_OBJECT_0)
{
return ZMD_OK;
}
try
{
if (pFrameData != NULL)
{
if (pFrameData->lpData != NULL)
{
try
{
this->DistributeFrame(pFrameData->lpData, pFrameData->iSize);
byte* pBuf = reinterpret_cast<byte*>(pFrameData->lpData);
delete[] pBuf;
}
catch (CException* e)
{
e->Delete();
}
}
delete pFrameData;
pFrameData = NULL;
}
}
catch (CException* e)
{
e->Delete();
}
}
There is a error that happens in the following code.
byte* pBuf = reinterpret_cast<byte*>(pFrameData->lpData);
<b>delete[] pBuf;</b>
Just as the image, here.
https://www.dropbox.com/s/ckqkz88qnifus4g/Error.png
I find that the pFrameData->lpData is a wild buffer point. I do not know when the buffer is released? Or this deque has some problem?
The class is here.
class CStreamProcess
{
HRESULT ProcessFrames();
void DistributeFrame(const LPVOID const lpBuf, int dwSize);
HANDLE m_hCloseEvent;
HANDLE m_hFrameProcessEvent;
std::deque<SZMDFrameData> m_FrameQueue;
CCriticalSection m_FrameListLock;
};
--------------------
I have resolved this problem. Its a mistake of using CCriticalSection.
modified 15-Jan-13 3:35am.
|
|
|
|
|
|
Hi CPallini,
Thank you very much. You help me greatly.
|
|
|
|
|
Not this problem, I made a test that has a temporary class. CMyClass. When pop_front() the desconstructor function of class CMyClass will not be called.
|
|
|
|
|
Hello,
I need to add a string on top / on bottom of a few drown GDI objects on printing. So far i override the OnPrint function.The problem i am facing is to decide where the text should be added in the CDC (i cant find the coordinates needed for TextOut)
I tried with CDC::GetBoundsRect(&dcRect, 0); but in dcRect i get nothing but zeros and the function returns 1. I think its returning DCB_RESET but i am not sure.
I tried with GetCurrentBitmap and GetBitmapDimension but still i get CSize variable with nothing but zeros.
All help is welcome 
|
|
|
|
|
The best thing i found is in the Microsoft Superpad example on the next link
Superpad
You can see how to put Header / Footer in it.
|
|
|
|
|
Using API In MFC OnDraw
TextOut(pDC->GetSafeHdc(),1, 20, "HELLO HELLO", 11);
I am not sure if that will print alligned properly.
|
|
|
|
|
My problem is finding the right coordinates for the TextOut function but after a talk with my Team manager we decided its better to be done as a header / footer.
Before that i just wanted to get the BoundRectangle with the hopes that it will be describing only the part in the page where the elements will be drown not the whole page itself.
I was wondering if there is a way to get out of the CDC member information about the position of the elements or something like that but i couldn't find any.
|
|
|
|
|
I want to use the function DhcpRequestParams() to get some information from the DHCP Server,but failes.
Any can help me?
Examples are best.
|
|
|
|
|
|
<pre lang="text">Found this very useful piece of code to get bitmap info from handle and would like to know HOW it works.
I think if I get how the LPBITAMPINFO gets filled I probably will also understand why using global handle is necessary. Or maybe not.</pre>
// a DIB is in the clipboard, draw it out
GLOBALHANDLE hGMem ;
LPBITMAPINFO lpBI ;
void* pDIBBits;
OpenClipboard() ;
hGMem = GetClipboardData(CF_DIB) ;
ASSERT(hGMem);
TRACE("\nfills LPBITMAPINFO");
lpBI = (LPBITMAPINFO)GlobalLock(hGMem) ;
Appreciate any help.
CHeers Vaclav
-- modified 15-Jan-13 15:54pm.
|
|
|
|