|
|
Hi,
Why dont you try to check value of the "kon" after the
IplImage* kon=mycam->capture(); //it would return a IplImage*
line. If every thing is fine the the value of kon should be not null.
Otherwise you need to check the capture function for creating the image successfully.
Manoj
Never Gives up
|
|
|
|
|
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
I saw an interest thing on the C++/CLI forum,I saw some C++ questions on that fourm and some CLI questions on the C++ forum.
|
|
|
|
|
Not sure of understanding but, anyway,...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
C++ questions on the CLI forum and CLI questions on C++ forum
|
|
|
|
|
OK it is called (managed)C++/CLI forum. Isn't (managed) C++ representative of C++ ? Or do you wish to separate (managed) C++ forum off CLI one?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Yeah I know,and no I dont.
|
|
|
|
|
I've written an activex control using MFC in VC6. Its based on a dropdown combo box, but I subclass the edit control (and listbox). As you type in the edit box, it goes out to the database and fills the dropdown. The "leave" event is triggered by killing focus in the edit box. I check to see if the entry is legal, and if its not, I put up an error message
I'm trying to test it in a simple dialog.
Here's the problem. If I type in (or select) something "legal" and then hit tab, I go to the next control in the tab order just fine. But if the user types in something illegal and I put up the message box, I seem to lose my place in the tab order and go back to the first control in the dialog.
Oddly enough it works fine in a VB dialog (the opposite of the problem I've had in the past.)
I've set the WS_EX_CONTROLPARENT style in Precreatewindow for the main control.
Any help would be appreciated!
|
|
|
|
|
hi all,
I am not much familiar with COM and COM dlls, Neway i am trying to use a COM dll (that is written in Vb) in a VC++ win32 application. I used the functions CoInitialize(), CoCreateInstance() etc.
Now in order to invoke a member function of the class, what should i do? suppose the method has 2 params ,one a string value and the other an integer.
Sample code is here, pls suggest the corrections:
//*************start*************************
if(CoInitialize(NULL)==S_OK)
{
HRESULT hr;
IDispatch* pIUk;
CLSID clsid;
CLSIDFromProgID(L"MyDll.MyClass", &clsid);
hr=CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IDispatch, (void**) &pIUk);
if(SUCCEEDED ( hr ))
{
DISPID dispid;
DISPPARAMS dispparameters;
//invoke method "MyMethod"
char filename[]="D:\\FrameWork.xls";
int count=1;
char FAR* szMember = "MyMethod";
hr = pIUk->GetIDsOfNames(IID_NULL,(unsigned short **)&szMember, 1, LOCALE_SYSTEM_DEFAULT, &dispid);
pIUk->Invoke(dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dispparameters, NULL, NULL, NULL);
pIUk->Release();
}
CoUninitialize();
}
//*************end****************************
I am confused about filling the DISPPARAMS structure and lot more doubts ...
Thanks in advance
SYAMLAL
|
|
|
|
|
Actually, COM is very hard though not impossible to learn and use.
About the DISPPARAMS structure [about what are your concerns]. The declaration of DISPPARAMS looks like this;
struct DISPPARAMS {
VARIANTARG* rgvarg;
DISPID* rgdispidNamedArgs;
unsigned int cArgs;
unsigned int cNamedArgs;
};
Let's exclude the second and forth fields; we do assign NULL and 0 to them respectfully. These are to support so called named parameters that are applicatble in VB. In C++ rarely can they be useful so let's do not bother with them [in C++ - I mean when calling via IDispath].
The first field is an array of VARIANTS [VARIANARG is the same as VARIANT]. Here we should put our real arguments. A VARIANT is a union of several types such BSTR, int, float, DATE. You are restricted with those types only; no type outside of VARIANT could be applied.
Suppose your function takes a single argument of type string. So first you prepare the VARIANT object like so;
BSTR bstrMyArg = L"some text";
VARIANT var;
::VariantInit(&var);
var.vt = VT_BSTR;
var.bstrVal = bstrMyArg;
Now it's time to initialize DISPPARAMS;
DISPPARAMS dispparameters;
dispparameters.cArgs = 1;
dispparameters.rgvarg = &var;
dispparameters.cNamedArgs = 0;
dispparameters.rgdispidNamedArgs = NULL;
Then invoke your pIUk->Invoke.
And a minor note. No need for FAR; you are not in Win16.
char FAR* szMember = "MyMethod";
--
=====
Arman
|
|
|
|
|
Do you really need to pass through IDispatch::Invoke ?
Usually COM objects expose the so called dual interface . that allows automation client to use IDispatch . On the other hand, C++ clients can take advantage from VTBL binding. I suggest to you to use VTBL binding (is simpler and more efficient).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Pls explain ur solution.
SYAMLAL
|
|
|
|
|
Usually a COM component exposes its functionalities not only with IDispatch interface but with other ones, oriented towards VTBL binding.
Your client can ask such an Interface (via QueryInterface method of IUnknown interface) and call directly its exposed methods (this way is simpler and more efficient).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
hi all,
i want write into the file wchar_t* and want to save it as UNICODE. tmp is wchar_t* and is a xml file.
my code is:
FILE* f = _wfopen(m_sFilespecW.c_str(),L"w");
size_t no = fwrite(tmp,sizeof(wchar_t),size,f);
fclose(f);
but it shows garbage.
when i change the code to:
FILE* f = _wfopen(m_sFilespecW.c_str(),L"w");
while(*tmp)
{
fputwc(*tmp,f);
tmp++;
}
fclose(f);
it saves the file but in ANSI format. it then fails to load in other function as that function only loads unicode files.
help me i want to save it in UNICODE.
|
|
|
|
|
sandeepkavade wrote: size_t no = fwrite(tmp,sizeof(wchar_t),size,f);
What is tmp and size ?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi
In the code bottom I want to create a new dialog box when a condition is provided.But it failed because all threads deadlocked.How can I create a new dialog box in a worker thread?
Thanks for your help.
UINT threading(LPVOID p)
{
CMyClass * me = (CMyClass *)p;
if(something happen)
me->threading();
return 0;
}
void CMyClass::threading()
{
CDlg *dlg = new CDlg;
dlg->Create(IDD_DIALOG2,this);
dlg->ShowWindow(SW_SHOW);
}
|
|
|
|
|
But it failed because all threads deadlocked
Why so? It is too bad. I guess your UI threrad is locked ..? So try to redesign the app logic. Never do make the UI thread wait [IOW minimize it as much as possible]. Instead, for waiting purposes do create a working thread.
It is possible to create and show a dialog from a worker thread, I do not encourage such a thing though. Put the following inside the worker thread;
CMyDlg dlg;
dlg.DoModal();
Again, try to redesign the things. You should not have the UI thread blocked.
--
=====
Arman
|
|
|
|
|
iayd wrote: How can I create a new dialog box in a worker thread?
As Arman suggested you should re-evaluate your design.
What problem are you trying to solve by creating a secondary thread, i.e. why do you think you need it?
Could the dialog box be modeless and created from the main thread instead?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
It is not possible to create the dialog box from main thread for my project.I should add a worker thread and wait for a situation will be occur.I think there should be a way to do this in this way.(?)
|
|
|
|
|
Hi,
You create the dialox box from main thread and set this dialog as hidden. Now create a worker thread and wait for the situation. When the situation occures you just set the dialog visible.
Manoj
Never Gives up
|
|
|
|
|
iayd wrote: I think there should be a way to do this in this wa
Well, you cannot create windows in threads that don't process messages.
This means that if you create a worker thread, you cannot create a modeless dialog in that thread. You could however create a modal dialog because it will pump messages inside an internal message pump until the dialog is closed. But the call to DoModal() won't return until the dialog is dismissed. This means that your worker thread cannot do anything else but showing that dialog.
If you want to create a modeless dialog, or any window, from another thread than your main thread, it will have to be a UI-thread.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
how to add gif image in a button control in mfc. pls help me
|
|
|
|
|
|
You can read your file(gif) with CImage class and use of SetBitmap of CButton for set this file
|
|
|
|