|
i am using the microsoft directX 9.0 for my video capture. Now my problem is i want to detect single face on the webcam (suppose using square size line) and i dont know how to program it in visual C++. Anyone can help me or tell me about related sources~ Thank you very much and God bless...
love-peace-joy
|
|
|
|
|
It will be very difficult to detect a face on the webcam, perhaps it would be better for you to detect movement instead.
|
|
|
|
|
I am working on Dialog based application using MFC in VC++.
In that i have handled Row change message of Grid (GRID_WMUSER_ROWCHANGE) its user defined message and I have written handler :
for example
**CDlg.cpp**
ON_MESSAGE( GRID_WMUSER_ROWCHANGE, fun)
void Cdlg::fun(int n)
{
MessageBox(.....
}
**Cdlg.h**
void fun(int n=0)
now in the Debug build of the Program this works fine. But when i run the application in the Release build the Program crashes as soon as row change of event of Grid occurs.
Now if I correct the above code as
**CDlg.cpp**
ON_MESSAGE( GRID_WMUSER_ROWCHANGE, OnRowChangeGrdLoad)
void Cdlg::fun(int n)
{
MessageBox(.....
}
LRESULT CDlg2701::OnRowChangeGrdLoad( WPARAM wParam, LPARAM lParam )
{
fun();
}
**Cdlg.h file**
afx_msg LRESULT OnRowChangeGrdLoad( WPARAM wParam, LPARAM lParam );
After doing this my application works fine in both Debug and Release build.
I want to know what is the reason behind this?? why such difference in Debug and Release build ??
|
|
|
|
|
|
FWIW, I love the "Ask a friend" link...
The easter egg section also has some interesting content.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
If you are too lazy to even write your own name into account, then I ( and I am sure many others ) will not even bother to read your posts. PLEASE FIX IT!!!
|
|
|
|
|
wrote: I want to know what is the reason behind this?? why such difference in Debug and Release build ??
Stack corruption causes the crash. The correct signature of a message handler, the function takes a WPARAM and an LPARAM (which are pushed onto the stack when the function is called) and returns an LRESULT (which is popped from the stack when the function returns). In the incorrect version of your code, the fun() function is being called as if it had this signature, even though the fun() function does not, and as a result there is stack corruption.
The fact that it works in debug mode is a coincidence, possibly due to padding added by the compiler in debug compilations.
Incidentally, are you still using VC 6.0? The error in signatures for message handlers is flagged as a compiler error in newer versions of Visual Studio.
Mike
|
|
|
|
|
Hi,
I do not really understand the intricacies of MFC messages , especially with Dialog boxes and their controls.
Could you please explain me what does not work with the following example?
I use a Dialog box containing a ListCtrl control.
I derived MYDlgClass class from CDialog.
At first I overloaded OnLButtonDown function because I would like to intercept Mouse events from within the ListCtrl.
I realized that mouse events are captured only when the mouse is outside the controls.
Then I tried to derive a new Class from CListCtrl. Before doing so I removed OnLButtonDown from MYDlgClass.
The first issue is that no ClistCtrl class was available for derivation therefore I derived from CDialog and mofified code within the new class that I Call MyListCtrl.
Finally I overloaded OnLButtonDown but the message is not captured.
Please could you tell me what should I do?
Many thanks for your help.
|
|
|
|
|
Arris7 wrote: I realized that mouse events are captured only when the mouse is outside the controls
You need to see OnNotify handler of parent(dilaog in this case) class.
Arris7 wrote: The first issue is that no ClistCtrl class was available for derivation
What ? Strange !
Which version of VS you are using ?
|
|
|
|
|
What ? Strange !
Which version of VS you are using ?
I use VS2003. Actually When I right click the ListCtrl control and I select Add Class, There are only 3 or classes available ( CDialog, Cpropertypage etc..) but no CListCtrl.
|
|
|
|
|
Use class view to add class, instead.
|
|
|
|
|
That's ok. I've got the solution.
thanks anyway.
|
|
|
|
|
You have derived from CDialog, but the trouble is mouse messages are sent to the controls ( your list control ) not the dialog itself. You need to derive a class from the list control and handle the messages from there.
Another way you could handle this is checking the message paramater of the MSG struct after each call to GetMessage(). Though I'm not exactly sure how you adjust the message loop in MFC.
|
|
|
|
|
You have derived from CDialog, but the trouble is mouse messages are sent to the controls
Actually, the messages are correctly routed to the CDialog. But when the mouse is within the control, I do not know where the messages are routed.
You need to derive a class from the list control and handle the messages from there
I derived a class from CListCtrl but no messages are routed to this class.
Though I'm not exactly sure how you adjust the message loop in MFC.
What is the procedure to do this? What is entry point in VC++ to setup this?
|
|
|
|
|
Hi..
I am having trouble passing a string of a file name (from VB to my c++ DLL)
the function StgOpenStorage requires a "const WCHAR*" for the filename. so what type should i pass to it. I would prefer to pass a VB string and let the DLL do the relevant transulation of types (i don't want to use strPtr(filename) in VB
many thanks
sample code
//-------------------------------------------------------------
SSFILEDLL_API bool __stdcall OpenEmail(fileName)
{
if (bIsopen == false)
{
HRESULT hr;
hr = MAPIInitialize(NULL);
if (FAILED(hr))
return false;
hr = OleInitialize(NULL);
if (FAILED(hr))
return false;
//get storage from msg file
//here is the bit where the filename is used
//hr = StgOpenStorage(L"C:\\Email.msg" works but i want to pass it from vb
hr = StgOpenStorage(filename ,
NULL,
STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE,
NULL,
0,
&pStorage);
if (FAILED(hr))
return false;
//open a IMessage session
hr = OpenIMsgSession (pMalloc, 0 , &pMsgSession);
if (FAILED(hr))
return false;
//open an IMessage on the IStorage object
hr = OpenIMsgOnIStg(pMsgSession,
MAPIAllocateBuffer,
MAPIAllocateMore,
MAPIFreeBuffer,
pMalloc,
NULL,
pStorage,
NULL,
0,0,&pSourceMsg);
if (FAILED(hr))
{
return false;
}
else
{
bIsopen = true;
return true;
}
}
else
{
return false;
}
}
|
|
|
|
|
read the posting guidelines[^], especially when you post huge code blocks.
Calvin Streeting wrote: Pass a sting
wow, that'll be hard
|
|
|
|
|
I was under the impression that VB strings were wide/Unicode by default, and would be in the form of a BSTR (BSTR == B ASIC Str ing, IIRC), which is already a wide string.
You can pass a BSTR in place of a const wchar_t* or const WCHAR* just fine. As far as how to get that BSTR directly to the function in the DLL, I cannot help you there - I do not do VB, nor am I 100% certain that the internal format of the BSTR is exactly the same as its external/COM format.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
I thought so but if I...
SSFILEDLL_API bool __stdcall OpenEmail(BSTR FileName)
then the StgOpenStorage fails but if i hard code in the filename L"c:\\email.msg" it works...
am i missing some thing
|
|
|
|
|
StgOpenStorage(...) fails when? At compile time, at run time, and with what error? Oh, and that should be a const BSTR parameter - you are not going to modify it so it can be constant.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
if i use "const BSTR filename" it compiles ok but fails at run time (StgOpenStorage(..) returns -2147287038) when called. it also sometimes crashes the vb app.
Many thanks for your help
|
|
|
|
|
Examine the string in the debugger (run the DLL under the debugger by specifying the VB application as the executing application), and see if the string looks valid or not.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
ok now you are hitting the limit of my c++ (this is my first c++ program ).. i feel i might need to read the section on debuging... but for you info it shows
szString = 0x0013c884
|__ 12849
which i take it is ram address?... is there any way to get it to print out the BSTR or msgbox it....
calvin
|
|
|
|
|
You need your debugger configured to show Unicode strings, and that will allow you to see if the value you are seeing can be treated as a BSTR or not.
You can use MessageBoxW(...) to see the value by doing something like this:
::MessageBox<code>W</code>( szString, L"The String", MB_OK ); Pay attention to the "W" in ::MessageBoxW(...) . The call to MessageBoxW will either show the contents of the string (if the string pointer is valid), or will likely crash or show garbage if not.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hi.. I found out that bit about setting debuger options and have done it (thanks for the clue) and i have found that
szString = 0x0013D374 ??????g
so i used the memory tool (learning how to debug, this is simular to pic asm) and found the memory and it says
0013D374 43 3A 5C 5C 65 6D 61 69 6C 2E 6D 73 67 00 00 00 0D C:\\email.msg....
so am i right in thinking it is not getting through... so back to google
Many thanks for you help i will "Please rate this message - let me know if I helped or not!" once i have this working, infact even if i don't as you have been very helpfull
|
|
|
|
|
Ok finaly got it....
convert
1. Pass Char * from vb to C++
2. covnvert to BSTR
3. Pass to StgOpenStorage(...)
reason vb passed a "8 bit ANSI string" function wanted a "Wide UNICODE string"
see below
SSFILEDLL_API bool __stdcall OpenEmail(char *FileName)
{
if (bIsopen == false)
{
HRESULT hr;
hr = MAPIInitialize(NULL);
if (FAILED(hr))
return false;
hr = OleInitialize(NULL);
if (FAILED(hr))
return false;
//convert Char * to BSTR
BSTR bFileName;
int count = 0;
count = MultiByteToWideChar(CP_ACP, 0, szString , strlen(szString), NULL , 0);
if(count > 0) {
bFileName = SysAllocStringLen(0, count);
MultiByteToWideChar(CP_ACP, 0, szString , strlen(szString), bFileName , count);
}
//get storage from msg file
hr = StgOpenStorage(bFileName ,
NULL,
STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE,
NULL,
0,
&pStorage);
if (FAILED(hr))
{
return false;
}
else
{
return true;
}
}
else
{
return false;
}
}
once again many thanks, it works, it works
err ok what was next
for your information this code is for http://ssfiledll.sourceforge.net/
-- modified at 19:52 Monday 22nd January, 2007
|
|
|
|