|
So I understand...
However, we're pretty much stuck with VS2003 (not that I mind too much - I did when we were stuck with VS6!), although I may well sneak a crafty VS2005 onto my PC here We only do native code development here, as I work for a large company, which has a tightly controlled standard Windows build, which doesn't yet include any version of .NET framework. Fortunately, I'm quite happy doing C++.
|
|
|
|
|
We have an ATL object with dual interface type.The interface definition fron the IDL file:
interface IEventSink : IDispatch{
[id(1), helpstring("method testmethod")] HRESULT testmethod(void);
[propput, id(2), helpstring("property ondataavailable")] HRESULT ondataavailable([in] IDispatch* newVal);
};
We invoke the object from javascript as follows:
var esink=new ActiveXObject("IEBrowserSink.EventSink");
esink.testmethod();
esink.ondataavailable=invokecallback;
It works fine;
Now i oveeride the Invoke method in the header file:
STDMETHOD(Invoke)(DISPID dispidMember,REFIID riid, LCID lcid, WORD wFlags,DISPPARAMS * pdispparams, VARIANT * pvarResult,EXCEPINFO * pexcepinfo, UINT * puArgErr)
{
......
return S_OK;
}
After this the calls to the 'testmethod' and 'ondataavilable' from javascript do not go through?
There are no exceptions but the scripts seems to skip these methods.What is wrong?
Are any changes requied in the idl?
|
|
|
|
|
I'm not sure though. Try increasing major/minor version(at all occurances in your project) of your object. I found similar problem with newly added function to interface. And changing minor version does trick.
|
|
|
|
|
Hi everyone!
I've got a dialog based app which contains a toolbar with a dropdown button (which displays a popup menu with a few options).
Now I'd like to add some icons to the toolbar's dropdown button. For that, I have created a CommandbarCtrl m_cmdBar member variable to be able to load images on it and then show them on dropdown's button.
Either the Compiler and the Linker go well but at Run-Time I got a crash at the constructor of the CommandbarCtrl. It says that it crashes when EnterCriticalSection(&m_sec) from the CComCriticalSection class at the atlcore.h file.
I don't know what is happening but I have tryed to create the commandbarctrl in different places (inside the member function I need it or as a global reference variable) thinking that it could be caused by an stack overflow but it always crashes at the constructor and gives the same error "entercriticalsection"
Do anyone konw what I'm doing wrong ??? Do I have to do any kinda initialization before using CCommandbarCtrls??
Cheers in advance
Dani.
|
|
|
|
|
I've got myself into a bit of a pickle.
Visual Studio 6, I have an ATL DLL that uses dialogs (ATL Dialog object). On one dialog, I have a combo box I'm trying to populate using AddString.
In InitDialog I attempt to get a pointer to the combo box:
CComboBox* pComboBox = (CComboBox*)(GetDlgItem(IDC_COMBO1));
This returns a valid pointer from what I can tell.
Then, calling pComboBox->AddString("Test"); throws a debug assertion failure, I beleive GetDlgItem is returning an invalid window handle (the assertion line failure is ASSERT(::IsWindow(m_hWnd));
I'm relatively new to ATL, so I'm sure it's my lack of understanding. Can anyone point me in the right direction please?
|
|
|
|
|
The cast to CComboBox* is MFC, that won't work in an ATL project. You can use WTL to get control wrappers that are similar to the MFC ones.
|
|
|
|
|
Thanks Mike...
So I need to upgrade to Visual Studio 2005??? I'm on 6.0 now and see no reference to WTL...
|
|
|
|
|
|
You can go for WTL as Michael has said.
You can use following code , as quick correction to your problem.
HWND hWnd = GetDlgItem(IDC_COMBO1);
char *pTest = new char[10];
strcpy(pTest,"prasad");
SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)(pTest));
delete []pTest;
|
|
|
|
|
But why do it like that?
What's wrong with
SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("prasad"));
I see no point in allocating a temporary anywhere you don't need to...
[fx: grumpy old man mode *off*]
Steve S
Developer for hire
|
|
|
|
|
Steve S wrote: What's wrong with
SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("prasad"));
Nothing wrong. But, my point was not what you raised.
Steve S wrote: I see no point in allocating a temporary anywhere you don't need to...
Agree.
|
|
|
|
|
Michael, Prasad, & Steve:
Thank you all very much. Prasad & Steve, the short work around worked great.
Michael, thanks for the links to your articles and the info on the new SDK + WTL. I've installed both and began researching/learning.
|
|
|
|
|
I think you dont't choose support MFC option
|
|
|
|
|
We have written a windows ATL server application which runs as a windows service(system account).
Since the system account does not have file-write prmissions,we are searching for a way how to introduce logging mechanism into this application(either to file or event log).
Any help on this will be appreciated.
FYI, this program launces a browser to perform certain actions and so the servicei s configured with 'Interact with desktop' permission.
|
|
|
|
|
I have never had difficulty writing to the event log from a service running in system account. Are you getting an error or what?
led mike
|
|
|
|
|
hi al, if any body has a huffman code and a zig zag scanning code written in C please forward it to me.
thank you
|
|
|
|
|
Any luck with googling?
"I'd like to help but I don't feel like Googling it for you."
|
|
|
|
|
Hi everyone,
I'm working on an IE toolbar.Everything went fine until i had to add a dialog box of some kind of user setting.Dialog opens,does its work and closes just fine on my development computer,but on other computers it does not.The button which is supposed to open the dialog does nothing.After some try-and-error experience,I found out that the problem was Runtime Library setting under Code Generation section of the project properties dialog.
Whenever i select a Non-Debug runtime library,the dll built does not work on other systems.When I select a Debug runtime library (like Multi-threaded Debug (/MTD) or Multi-threaded Debug DLL (/MDd)) it builds and works out fine.But it also doubles the dll file size and much likely with debug information which is unnecessary in the release build.
Has anyone any idea what the case might be?
|
|
|
|
|
I always use the multithreaded CRT, which is staticly linked into the DLL. That way it will (or should) work on any machine regardless of what CRT DLLs are installed.
|
|
|
|
|
Thanks for the response,
I digged up the code a little bit further and found out the problem was an uninitialized HWND value.
something like;
HWND hwndWB2; // the "guilt"
m_spWebBrowser2->get_HWND((SHANDLE_PTR *)&hwndWB2));
...
...
MyDialog dialog = MyDialog();
dialog.DoModal(hwndWB2);
When the guilt line is modified as: HWND hwndWB2 = NULL; everything's OK.
but the reason why it works with Debug CRT is still a curiosity.
|
|
|
|
|
It's probably more that it's compiled with run-time checks on (/RTC1 flag) - the compiler can put in extra code when compiling to help find problems like overwriting bits of the stack or heap you shouldn't do. This requires stack/heap to be initialised to known values, which it does (it actually sets them to 0xcccccccc). These values are probably recognisable as invalid by DoModal (or IsWindow, or something), so it just rejects them. In Release, the HWND isn't initialised at all, so may contain a value that *could* be a valid HWND, causing the crash?
|
|
|
|
|
Hi All,
I want to use MSHTML as a parser from a Console Application.
hr = Location.CoCreateInstance(CLSID_HTMLLocation);
is returning 'COM Error: 0x80040154 (Win32: 340)'
Any ideas? The Document creation returns S_OK .
Jeff
#define _WIN32_IE 0x0550 // IHTMLDocument2
#define _WIN32_DCOM // CoInitializeEx(...)
#pragma warning( disable: 4146 )
#pragma warning( disable: 4192 )
# import "mshtml.tlb"
#pragma warning( default: 4146 )
#pragma warning( default: 4192 )
#include <windows.h>
#include <atlbase.h>
#include <mshtml.h>
#include <assert.h>
#include <iostream>
int main(int argc, char* argv[])
{
HRESULT hr = S_OK;
CComPtr< MSHTML::IHTMLDocument2 > Document = NULL;
CComPtr< MSHTML::IHTMLLocation > Location = NULL;
hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
if( FAILED( hr ) ) { goto COMPLETE; }
hr = Document.CoCreateInstance(CLSID_HTMLDocument);
if( FAILED( hr ) ) { goto COMPLETE; }
<BR>
hr = Location.CoCreateInstance(CLSID_HTMLLocation);
if( FAILED( hr ) ) { goto COMPLETE; }
COMPLETE:
Document.Release();
Location.Release();
CoUninitialize( );
if( S_OK != hr )
{
std::wcout << L"COM Error: " << std::hex << L"0x" <<hr;
std::wcout << L" (Win32: " << std::dec << HRESULT_CODE( hr );
std::wcout << L")" << std::endl;
}
return HRESULT_CODE( hr );
}
|
|
|
|
|
I suspect you don't need to CoCreateInstance a location object - the HTML document will pass back a pointer to it's own location object.
As to why the CoCreateInstance call is failing - I've no idea...
|
|
|
|
|
Hi Sohail,
Still fighting it... I'm working from Lightweight HTML Parsing Using MSHTML [^]. The new program is below, but same error occurs on IMarkupServices:
COM Error:
pDocument->QueryInterface( IMarkupServices )
0x80004002 (Win32: 16386)
I tried to unregister, and then register mshtml.dll. Unregister failed with 0x80004002 or 0x80004005. Registration succeeded.
I'm using Visual Studio 6.0, EE on Windows 2000. At this point, I rolled back the March 2006 SDK because of LINK 1103 error (corrupt library) to October 2002. I'm downloading February 2003 SDK now (last supported version for VC++ 6.0). I verified the IE SDK was installed.
I'm going to start to grep the Registry.
Jeff
#define _WIN32_IE 0x0500 // IMarkupServices
#define _WIN32_DCOM // CoInitializeEx(...)
#import "mshtml.tlb"
#include <windows.h>
#include <atlbase.h>
#include <mshtml.h>
#include <mshtmlc.h>
#include <assert.h>
#include <iostream>
int main(int argc, char* argv[])
{
HRESULT hr = S_OK;
CComBSTR error;
try
{
CComPtr< MSHTML::IHTMLDocument2 > pDocument = NULL;
CComPtr< IPersistStreamInit > pStream = NULL;
CComPtr< MSHTML::IMarkupServices > pServices = NULL;
CComPtr< MSHTML::IMarkupContainer > pContainer = NULL;
CComBSTR title = L"", charset=L"";
hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
if( FAILED( hr ) ) {
error = L"CoInitializeEx";
throw error;
}
hr = pDocument.CoCreateInstance( CLSID_HTMLDocument );
if( FAILED( hr ) ) {
error = L"pDocument";
throw error;
}
hr = pDocument->get_title( &title );
if( FAILED( hr ) )
{
error = L"pDocument->get_title";
throw error;
}
std::wcout << L"Title: ";
std::wcout << (wchar_t*)title << std::endl;
hr = pDocument->get_charset( &charset );
if( FAILED( hr ) )
{
error = L"pDocument->get_charset";
throw error;
}
std::wcout << L"Character Set: ";
std::wcout << (wchar_t*)charset << std::endl;
hr = pDocument->QueryInterface( IID_IPersistStreamInit,
reinterpret_cast<void**>( &pStream ) );
if( FAILED( hr ) ) {
error = L"pDocument.QueryInterface( IPersistStreamInit )";
throw error;
}
pStream->InitNew();
hr = pDocument->QueryInterface( IID_IMarkupServices,
reinterpret_cast<void**>( &pServices ) );
if( FAILED( hr ) ) {
error = L"pDocument->QueryInterface( IMarkupServices )";
throw error;
}
}
catch( CComBSTR& e )
{
std::wcout << std::endl;
std::wcout << L"COM Error: " << std::endl << L" ";
std::wcout << (wchar_t*)e << std::endl ;
std::wcout << std::hex << L" 0x" <<hr;
std::wcout << L" (Win32: " << std::dec << HRESULT_CODE( hr );
std::wcout << L")" << std::endl;
}
CoUninitialize( );
return HRESULT_CODE( hr );
}
|
|
|
|
|
No registry entries for:
'IMarkupServices' or '3050f4a0-98b5-11cf-bb82-00aa00bdce0b' (string literal searches, not case sensitive)
I'll try the October 2003 SDK when I finish getting it down.
Jeff
|
|
|
|