|
Thats because one time before one application,for example when visual studio compile it does not release it after compile and register it.If you restart your computer may be it works.(or you test it in ActiveX Test container and did not close it)
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
I am attempting to use the MSCEGrid.dll control for WinCE (Pocket PC 2002).
After a little information gathering, I discovered I needed to create an IDL file, create a type library and create the header files.
I did this. I even changed one of the datatypes from "single" to float.
Now when I include my newly created header file (mscegrid.h), I get the following errors:
error C2501: 'MIDL_INTERFACE' : missing storage-class or type specifiers
error C2440: 'initializing' : cannot convert from 'char [37]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
...
yada yada yada...
Anyone know how to fix this?
|
|
|
|
|
|
I'm a little confused... What and where would I use the #import directive? The problem that I was running into was that MIDL_INTERFACE was not defined anywhere. When I looked at
#include "rpcndr.h"
in VS 6.0 it contained this
#define MIDL_INTERFACE(x) struct __declspec(uuid(x)) __declspec(novtable)
however in WinCE 300 SDK it did not. To fix this, I just defined MIDL_INTERFACE in my IDL generated header file.
However, I can't imagine this is what I should really be doing just to add a control to my WinCE application.
|
|
|
|
|
Who has used the regexp object in system32\vbscipt.dll to parse the text string. I have tried it and make it work!
But i don't know why i can get only one match(that is the matches.GetCount()==1), even there are many exist. The next is my code:
void CInetSessionDlg::ParsePage(CString szPattern, CString szContent){ //m_regExp's declaration is on other place link this: IRegExp m_regExp; //The class IMatchCollection and IMatch are both got from the tlb //m_regExp = regExp; try{ if(m_regExp.CreateDispatch(__uuidof(RegExp)) == FALSE) { AfxMessageBox("CreateDispatch Failed!"); return; } //IMatchCollection2 * temp; m_regExp.SetIgnoreCase(TRUE); m_regExp.SetPattern(LPCTSTR(szPattern)); if(m_regExp.Test(LPCSTR(szContent))) { //IMatchCollection2 matches=m_regExp.Execute(szContent); ISubMatches matches = m_regExp.Execute(szContent); for(long i = 0; i < matches.GetCount(); i++) { IMatch2 match = matches.GetItem(i); //IMatch2 match = temp->GetItem(i); CString strLink = match.GetValue(); m_cbHref.AddString(strLink); } } } catch(_com_error& e) { AfxMessageBox("Com Error occurred!" + e.Description()); return; }}
in this implementation file's header file:
i defined the RegExp(copied from the file RegExp.tlh got from vbscript.dll)
struct __declspec(uuid("3f4daca4-160d-11d2-a8e9-00104b365c9f"))RegExp; // [ default ] interface IRegExp2
Why? Who can tell me how to use vbscript.dll in VC++ 6.0
thanks a lot!
Sincerely, Davidlou
davidlou68@hotmail.com
|
|
|
|
|
Help!
I'm a experienced VB/junior C++ developer and I'm starting to play a little with ATL. I'm having tons of trouble working with MSXML 4 even though I'm doing some pretty simple stuff. Perhaps somebody can spot something that I'm doing wrong.
The code I'm trying to run is in an ATL DLL project and belongs to a COM object called CBuilder. It's extremely simple since I'm just experimenting. Here's the code I'm trying to run:
#import "C:\Winnt\System32\msxml4.dll"
using namespace MSXML2;
STDMETHODIMP CBuilder::InitDocument()
{
IXMLDOMDocumentPtr doc;
HRESULT hr = doc.CreateInstance("Msxml2.DOMDocument.4.0");
if(FAILED(hr))
return hr;
hr = doc->loadXML("<customer><first_name>Joe<last_name>Smith");
if(SUCCEEDED(hr))
return S_OK;
else
return hr;
}
This seems about at simple as it gets. The trouble is, whenever I call this method from either a VB or C++ exe, the doc->loadXML() call returns a -1 (E_FAIL, I believe?). I can't figure out why. I can load up a DOMDocument from VB6 just fine using this same XML string. Why can't I do it in VC++?
Any input is really appreciated. This is getting frustrating!
Thanks!
|
|
|
|
|
You're supposed to pass a well-formed fragment , like <name>JoeSmith ( the parser will try to validate the buffer).
|
|
|
|
|
I just noticed that the angle brackets in my XML string were stripped out by the browser, so the string I'm using as an argument for my doc->loadXML() function isn't displaying correctly.
The "real" string is:
<customer><first_name>Joe</first_name><last_name>Smith</last_name></customer>
Which is well formed XML and should parse fine. As I said, the VB version of loadXML() takes the string and loads it. It's just when I call loadXML() from my C++ ATL project that it bails.
|
|
|
|
|
Sorry for the previous reply - I have noticed that the browser stripped my tags too. The definition of loadXML method in the DOMDocument intereface is " HRESULT loadXML ( BSTR xml, VARIANT* vSucceeded)". You use smart pointers and the _com_ptr_t will wrap your method call and will return vSucceeded instead of the HRESULT.VARIANT_TRUE value is -1 and VARIANT_FALSE is 0, so the buffer is loaded by the parser just fine ( you can check by testing doc->xml property : "MessageBoxW( NULL, doc->xml, L"XML", MB_OK);
|
|
|
|
|
MSXML2::IXMLDOMDocumentPtr doc;
hr = doc.CreateInstance("Msxml2.DOMDocument.4.0");
if(FAILED(hr)) return hr;
VARIANT_BOOL vb = doc->loadXML("<customer><first_name>Joe</first_name> <last_name>Smith</last_name></customer>");
if(vb == VARIANT_FALSE) return E_FAIL;
::MessageBox(NULL, doc->xml, NULL, 0);
|
|
|
|
|
Arrgh! Of course! In the back of my head I knew that it returned a VARIANT_BOOL, but I guess I'd just been banging my head against a wall for so long that I couldn't see the problem any more.
Thanks for the help.
|
|
|
|
|
Hi,
I have done an activeX control. I have several problems:
1. At design time in Visual C++ 6, I paste the control in a dialog box and it is filled blank although it should be custom painted. If I launch the dialog under Visual it is properly painted (minus the next problem).
2. At design-time, if changing a custom property value, it is not shown at run-time.
When trying my control in the microsoft test container, all is fine, I have not these problems. I'm a beginner with activex, it maybe explains that.
An idea ?
Nicolas
|
|
|
|
|
If I have the following code on VB:
Dim myObj as Object
Set myObj = CreateObject("MyDCOMServer.MyClass", "ServerName")
How do I do it on Visual C++?
Thanks a lot,
Julian
|
|
|
|
|
Use this.
HRESULT CoCreateInstanceEx(
REFCLSID rclsid, //CLSID of the object to be created
IUnknown *punkOuter, //the controlling IUnknown
DWORD dwClsCtx, //CLSCTX values
COSERVERINFO *pServerInfo,//Machine on which the object is to be instantiated
ULONG cmq, //Number of MULTI_QI structures in pResults
MULTI_QI *pResults //Array of MULTI_QI structures
);
Cheers,
Anand
|
|
|
|
|
Hi !
I'm still beginning with COM ! I'd like to do a very simple ATL component with Visual C++.
The interface of this component would implement only one method, which would return a boolean value.
This value would be read from a Visual Basic app.
The problem is when I use the 'boolean' type for my interface, VB doesn't recognize it. I tried to use the 'short' type, but VB recognize it as an Integer.
What type should I use in my ATL interface so that VB receives a 'Boolean' type ?
Thank you for your help,
Jerome
|
|
|
|
|
Pass a VARIANT structure with VT_BOOL type. For example :
HRESULT Object::Test( /*[out,retval]*/VARIANT* pOut)
{
*pOut = NULL;
CComVariant vRet( true);
vRet.Detach( pOut);
return S_OK;
}
|
|
|
|
|
Just more Info for you.
In C++, TRUE is +1, but VB and automation clients use TRUE as -1 and FALSE as +1.
If you use BOOL, all you can see is clouds of confusion over your application.
so use VARIANT_BOOL(boolean type), VARIANT_TRUE(true),VARINAT_FALSE(false)
Whenever you are using C++(COM), you should avoid using bool, BOOL in your application.
Cheers,
Anand
|
|
|
|
|
I have problem implementing my onIdle function. I have TRACE messages in my onIdle function to see if it is called for but I can't see these TRACE messages and I don't know what I have done wrong.
I have one CWinApp class and one CDialog class and I wan't my onIdle to update my user_interface e.g. dialog_window. I've tried to implement a onIdle function in both the CWinApp class and the CDialog class but I can't see any of my TRACE messages.
Do I have to edit anything in the ON_MESSAGE list or anything like that???
Please, help me..
|
|
|
|
|
Hi,
The foll. is an extract from Paul DiLascia's C++ Q&A column in MSJ-July'97
Unfortunately, this wonderful UI update mechanism doesn't work for dialogs—at least not automatically. You have to hook the pieces up yourself. Fortunately, it's easy. All you have to do is handle WM_KICKIDLE, a private MFC message that MFC sends whenever the dialog is idle (analogous to the app's OnIdle handler) to call UpdateDialogControls yourself.
Look into the article.
Hope this Helps
|
|
|
|
|
Hi !
I'm beginning with COM, and I'd like to do a very simple ATL component with Visual C++.
The interface of this component would implement only one method, which would return a string.
Then, I want to use this component from Visual Basic, and read the string.
The problem I'm having is I don't know how to pass to VB a BSTR. what would be the definition of my Method of the interface ? Can I do this :
HRESULT GetString([out, retval] BSTR str);
In C++, how can I create this BSTR ? Do I have to build the BSTR structure myself from a normal C++ array of chars ?
Thank you for your help,
Jerome
|
|
|
|
|
Jerome C wrote:
what would be the definition of my Method of the interface ?
When you implement method no difference betwenn VB and VC.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Jerome, the GetString should be defined like this :
HRESULT GetString([out, retval] BSTR* str);
In the cpp file:
STDMETHODIMP GetString(BSTR* str)
{
//you must allocate space, vb will call SysFreeString Automatically
*str = SysAllocString("xpto");
return S_OK;
}
If it was a [in] method the str didn't need a pointer.
Cheers,
Joao Vaz
|
|
|
|
|
Thank you both for your help ! It works !!!!
Jerome
|
|
|
|
|
I extracted the system32\vbscript.dll to get the type library(named RegExp.tlb). Then I add the new classes from this tlb to my project! Then I want to new one class of them named IRegExp(derived from COleDispatchDriver), but i don't know whether i need to attach the LPDISPATCH to this instance and how can i do! When i didn't attached it, that is called its default constructor, and run it, I can't not execute it normally! This program is too emengent, so i need ur warmhearted help in time!
[ccode]
void CInetSessionDlg::ParsePage(CString szPattern, CString szContent)
{
//m_regExp's declaration is on other place link this: IRegExp m_regExp;
//The class IMatchCollection and IMatch are both got from the tlb
IMatchCollection * temp;
m_regExp.SetIgnoreCase(TRUE);
m_regExp.SetPattern(szPattern);
if(m_regExp.Test(szContent))
{
temp=new IMatchCollection(m_regExp.Execute(szContent));
for(long i = 0; i < 3/*matches.GetCount()*/; i++)
{
//IMatch match = matches.GetItem(i);
IMatch match = temp->GetItem(i);
CString strLink = match.GetValue();
m_cbHref.AddString(strLink);
}
}
}
[/ccode]
Thanks u very much!
Sincerely, Davidlou
davidlou68@hotmail.com
|
|
|
|
|
Can someone please help me out!!!
I just don't know how to pass/receive binary data between a VB6 client application and an ATL COM Server (EXE).
How can I transform this into COM?
HRESULT MyFunc( unsigned short* pbIn, long cbIn, unsigned short** ppbOut );
Where pbIn is of cbIn-size. The output shall be a size-dynamic buffer holding the result.
Can I use VB6 to call this method using Byte arrays?
Need help
|
|
|
|