|
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
|
|
|
|
|
Hi Stuart,
I haven't tried the IHTMLLocation Interface yet, but the IMarkupServices was resolved by replacing the call to CoInitializeEx() with CoInitialize().
Jeff
|
|
|
|
|
hr = CoInitializeEx( NULL, COINIT_APARTMENTTHREADED );
|
|
|
|
|
HRESULT 0x80040154 corresponds to Class Not Registered
I don't know anything about CLSID_HTMLLocation so I think the error could be either because of missing class registration information or the class is noncreatable directly. In case of noncreatable class, you will have to invoke a method or proerty of some other object which returns you the intance of this class.
S o h a i l K a d i w a l a
To Err Is Human; to Debug, Divine
modified 21-Apr-21 21:01pm.
|
|
|
|
|
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 );
}
|
|
|
|
|
|
From MSDN (The following in BOLD is what i told in my earlier post, there is certain way you should follow to get access to some interfaces. The following is an example) -
IMarkupServices
Having understood the fundamental concepts of Markup Services, you now are ready to take a closer look at Markup Services interfaces. The best place to start is the IMarkupServices interface. This interface is the starting point for all the MarkupServices, such as IMarkupContainer and IMarkupPointer. The IMarkupServices interface also contains all the methods for performing actual manipulations of elements of the document.
You can perform a QueryInterface operation on a document object for IID_IMarkupServices to obtain IMarkupServices.
On MSDN, read in Overview and Tutorial about IMarkupServices
I hope this helps.
S o h a i l K a d i w a l a
To Err Is Human; to Debug, Divine
modified 21-Apr-21 21:01pm.
|
|
|
|