|
Key type could be a set of variables inside a structure or class.
valikac
|
|
|
|
|
I am able to find whether the webpage is a document object or not if it is then i want to retrieve the complete source code of the webpage and store it in a CString, Which interface to query and which function to use.
I want this thing to happen in BeforeNavigate2 of DWebBrowserEvents2.
Thanks in advance.
Dhiraj
Dhiraj Kumar Saini
|
|
|
|
|
Hi,
I want to create an IE plug-in where whenever a download dialog is expected, the file is downloaded automatically to a specified folder - the dialog should should not appear.
Has anyone worked on something similar? Is such a thing work be possible to do w/out extensive COM/IE/ATL/OLE knowledge?
I am somewhat familiar with C++ & COM/ATL/OLE concepts.
From the MSDN docs, I also know that I just need to create a COM object which implements a couple of interfaces and register it.
But, am absolutely clueless where to begin & how to get to that. (Never used the Visual Studio)
Any helpful pointers plz ?
Thanks,
-pk
|
|
|
|
|
|
You can use IMoniker for downloads files and IBindStatusCallback for accepts information on an asynchronous bind operation.
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
// CestDLHandler
CestDLHandler::CestDLHandler()
{
m_lUid = 0;
}
STDMETHODIMP CestDLHandler::Download(IMoniker* pmk,
IBindCtx* pbc,
DWORD dwBindVerb,
LONG grfBINDF,
BINDINFO* pBindInfo,
LPCOLESTR pszHeaders,
LPCOLESTR pszRedir,
UINT uiCP )
{
traceFerruccio(_T("IMoniker %p CestDLHandler %p \n"),pmk, this);
HRESULT hr;
//Stream will be released in the BSCB OnDataArrival
IStream *pstm;
//Attempt to create our BindStatusCallBack
WBBSCBFileDL *filedl = NULL;
//Returns a NonAddRef pointer to a new BSCB
//AddRef is called on this BSCB during a successfull call
//to RegisterBindStatusCallback
if(WBCreateBSCBFileDL(&filedl) != S_OK)
{
return E_FAIL;
}
//Init the BSCB
m_lUid++;
filedl->InitByUser(m_lUid, this, pszHeaders, NULL);
IBindStatusCallback *pPrevBSCB = NULL;
hr = RegisterBindStatusCallback(pbc,
reinterpret_cast<ibindstatuscallback*>(filedl), &pPrevBSCB, 0L);
/*
Exception to the rule
RegisterBindStatusCallback return E_FAIL
Cause: Content_Disposition header returned from a server
in response to a file download via a post or ,..
Example: downloading attachements from Hotmail, Yahoo, ...
Unfortunately, due to no documentation regarding an E_FAIL return,
and more specifically, regarding RegisterBindStatusCallback internal workings,
I had to resort to using RevokeObjectParam on the previous BSCB and in my
implementation of BSCB, relay certain calls to the previous BSCB to make DL work.
I do not know if this is a bug or done intentionaly.
*/
/*
KB article http://support.microsoft.com/default.aspx?scid=kb;en-us;274201
Notifies the client application that this resource contained a
Content-Disposition header that indicates that this resource is an attachment.
The content of this resource should not be automatically displayed.
Client applications should request permission from the user.
This value was added for Internet Explorer 5.
*/
if( (FAILED(hr)) && (pPrevBSCB) )
{
//RevokeObjectParam for current BSCB, so we can register our BSCB
LPOLESTR oParam = L"_BSCB_Holder_";
hr = pbc->RevokeObjectParam(oParam);
if(SUCCEEDED(hr))
{
//Attempt register again, should succeed now
hr = RegisterBindStatusCallback(pbc,
reinterpret_cast<ibindstatuscallback*>(filedl), 0, 0L);
if(SUCCEEDED(hr))
{
filedl->m_pPrevBSCB = pPrevBSCB;
//Need to add ref to our DLMan
filedl->AddRef();
pPrevBSCB->AddRef();
filedl->m_pBindCtx = pbc;
pbc->AddRef();
}
}
}
if(SUCCEEDED(hr))
{
hr = pmk->BindToStorage(pbc, 0, IID_IStream, (void**)&pstm);
}
else //add right-click "save target as" support
{
delete filedl;
USES_CONVERSION;
LPOLESTR data = NULL;
pmk->GetDisplayName(pbc, NULL, &data);
TCHAR* myUrl = OLE2T(data);
HRESULT hr;
hr = URLDownloadToFile(NULL,myUrl,NULL,0,NULL);
if ( SUCCEEDED(hr) )
{
}
else
{
LPTSTR lpszErrorMessage;
if ( FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, hr,
MAKELANGID ( LANG_NEUTRAL, SUBLANG_DEFAULT ),
(LPTSTR) &lpszErrorMessage, 0, NULL ))
{
//sMsg.Format ( _T("Download failed. Error = 0x%08lX\n\n%s"),
// (DWORD) hr, lpszErrorMessage );
LocalFree ( lpszErrorMessage );
}
else
{
//sMsg.Format ( _T("Download failed. Error = 0x%08lX\n\nNo message available."),
// (DWORD) hr );
}
}
}
return hr;
}
History
|
|
|
|
|
Dear all,
I am writing a CMyFileDialog class inherited from CFileDialogImpl. When I choose some special file,a checkbox will show at this time. Now the question is I don't know how to create a dynamic checkbox. or is there other way to realize this function??? Waiting for the answer...;) Thanks!!!
Anna
^_^
|
|
|
|
|
Hi Anna,
Use the code
1) Get the handle of the check box control
HWND hwnd=GetDlgItem(IDC_CHECKNOX1);
2) Call the enable window function and pass TRUE if you want it to be
visible otherwise make it false.
hwnd->EnableWindow(FALSE);
OR
hwnd->EnableWindow(TRUE);
Hope this solves your problem.
Do reply
Dhiraj
Dhiraj Kumar Saini
|
|
|
|
|
hi,Saini
Thanks for your help. I use "this->ShowWindow(TRUE)" to make the checkbox show. But does hWnd have the function "EnableWindow()"??? It seems that it only has one variable...
|
|
|
|
|
Dear ATL people,
I have a maybe-newbie question, so sorry for that. I have a
CAtlExeModuleT (see code below) and want to adjust a sample that I
got. It started by creating a modal CAxDialogImpl object in the
PreMessageLoop of the CAtlExeModuleT. What I wanted to do is to make
the dialog modeless so that I can display additionally a CWindowImpl
(with the option to make it fullsceen later, to display jpegs).
So is it possible to create a CAxDialogImpl and a CWindowImpl which
both have the desktop as parent (giving NULL as first parameter in
the Create call)? Or do they have to be related to each other (forming
a chain of parent-child)? When I execute the code below the program
runs for short and then ends without displaying anything. I added
a Sleep(5000) after the window creation and the window was visible.
So it seems to be a matter of scope. But the dialog wasn't visible.
How could I get it work that the window AND the modeless dialog are
created correctly and do not go out of scope so that the event
handling works properly? Do I have to put them in PreMessageLoop
(I tried this, but the effect was the same; do I need
PreMessageLoop)? - I would prefer a solution with _tWinMain only to
get rid of the PreMessageLoop if possible.
Please help, I think it's not a hard problem for someone who has some
experience with the ATL. You would really help me greatly because I am
totally stuck despite two books on ATL and the web (I only found exam-
ples where they use the older CCom stuff with a main message loop in
_tWinMain and TranslateMessage(&msg) and DispatchMessage(&ms) into it)
but not how to use ATL windows in context of the CAtlExeModuleT like
I need in this case (ATL 8.0, Visual Studio 2005).
So with the hope on help I send you
Best regards,
Peter.
Here comes the code:
#include "stdafx.h"
#include "resource.h"
#include "mainDialog.h"
class CMyWindow : public CWindowImpl<CMyWindow>
{
public:
DECLARE_WND_CLASS("MyName")
BEGIN_MSG_MAP(CMyWindow)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
END_MSG_MAP()
LRESULT OnPaint(UINT nMsg, WPARAM wParam,
LPARAM lParam, BOOL& bHandled)
{
return 0;
}
};
class CSampleModule : public CAtlExeModuleT< CSampleModule >
{
public :
HRESULT PreMessageLoop(int nShowCmd)
{
HRESULT hr = CAtlExeModuleT<SampleModule>::PreMessageLoop(nShowCmd);
if (FAILED(hr))
return hr;
return S_FALSE;
}
};
CSampleModule _AtlModule;
extern "C" int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE ,
LPTSTR , int nShowCmd)
{
CMainDialog* mainDlg = new CMainDialog();
mainDlg->Create(NULL);
CMyWindow* myWnd = new CMyWindow();
myWnd->Create( 0, CWindow::rcDefault, "Image Test",
WS_OVERLAPPEDWINDOW, WS_EX_CLIENTEDGE );
if( !myWnd ) {
return FALSE;
}
myWnd->CenterWindow();
myWnd->ShowWindow( nShowCmd );
myWnd->UpdateWindow();
return _AtlModule.WinMain(nShowCmd);
}
|
|
|
|
|
Passing Cstring to BSTR gets truncated.The lengthy strings gets truncated.
CString str= "fjgdfldfkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"
add(_btsr_t(str.AllocString,false))
add(BSTR arg1)
{
}
I am passing in this maaner to a function which accepts BSTR , but the string gets truncated.
Thanks in Advance.
|
|
|
|
|
Why you are using _bstr_t ?
Modify code to,
CString str= "fjgdfldfkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"
BSTR bsStr = str.AllocSysString();
add(bsStr);
Prasad
MS MVP - VC++
|
|
|
|
|
I want to craete a custom right click context menu for Internet Explorer whenever the user takes the pointer over an image and right clicks. The custom menu context should have icons along with the text for menu items.
i want the code for the events fired on clicking menu items.
Please help me out.
Thanks In advance.
Dhiraj
Dhiraj Kumar Saini
|
|
|
|
|
|
The API AlphaBlend doesn't work in ATL owner-draw button.
why?
and how to implement the spark effect when pushed a button?
thx!!
C++, MFC, ATL, PHP
|
|
|
|
|
i want to add a new item menu whenever user right click a image file saved on hard disk. The right click context menu of windows explorer bar for the file should show a new item with the name upload to 123greeting and also want an event handler for it.
Make sure it should be for windows explorer and not for internet explorer.
pls help me out
Thanks in advance.
Dhiraj
Dhiraj Kumar Saini
|
|
|
|
|
|
Are you calling him a "complete idiot"?
Steve
|
|
|
|
|
Hello
I am working on a COM project in which i use Interface Inheritance.
The IDL file looks like this,
interface IEarthInterface : IUnknown
{};
interface IOceanInterface : IEarthInterface
{};
interface IPacificInterface : IOceanInterface
{};
interface IAntarticInterface : IOceanInterface
{};
interface IDataInterface : IUnknown
{};
interface IFindInterface : IDataInterface
{
HRESULT GetOceanTypeInterface(IOceanInterface** pOceanInterface);
};
From inside IFindInterface i need to figure out which Ocean is currently attached and then attach or typecast
it was IOceanInterface and send it back to client.
All i wanted to know is how to get a Interface pointer from inside another Interface.
ie, can i call CoCreateInstance or QueryInterface from inside IFindInterface and get the
Interface Pointer to IPacificInterface or IAntarticInterface.
I been already told that CoCreateInstance will not work in this case.
Any idea how to implement this?
Thanks in advance.
|
|
|
|
|
This should work:
<br />
IPacificInterface* pPacific = NULL;<br />
pOceanInterface->QueryInterface(NULL, IID_IPacificInterface, &pPacific);<br />
If this fails, try all other possible derived interfaces until a call to QueryInterface succeeds. This is pretty much like using dynamic_cast to determine the type of object by pointer or reference to base.
|
|
|
|
|
SCENARIO:
From a C++ ATL program I'm submitting database queries to an MSSQL 2000 system in the following formats:
Select * from dbo.table (returns a rowset)
Select * from dbo.table for xml auto (returns an XML stream)
Exec dbo.sproc ... (could return a rowset or an XML stream)
I can't tell before I execute the query whether it will return a rowset or an XML stream, however, after the query is executed I can determine which type of output was returned by checking the rowset's number of columns and first column name.
PROBLEM:
I now have the output in a rowset. This is fine if the output is a rowset, but, if its an XML stream I have a problem. How can I get the output from the rowset into a stream object AND have it properly translate the XML to a readable format?
-- modified at 11:17 Friday 24th August, 2007
The art of conversation is not only saying the right thing at the right time,
but to leave unsaid the wrong thing at a most tempting moment!
|
|
|
|
|
I want to get hwnd of IE main menu,and click one of the items,for example:View->Refresh,I write codes like this:
HWND hwndIE=::FindWindow(_T("IEFrame"),NULL);
HMENU appMenu=::GetMenu(hwndIE);
HMENU subMenu=::GetSubMenu(appMenu,1);
...
Everytime I got zero from subMenu,why?
|
|
|
|
|
It is because IE doesn't have a standard menu, but instead uses a Rebar band with menu in it. Sadly, there's hardly any way to retrieve IE's menu with GetMenu().
Instead, you may want to try using IE's automation interface. I haven't used it to get IE's menu, but it shouldn't be too difficult.
|
|
|
|
|
Dhiraj kumar Saini wrote: how to convert VT_DISPATCH into CString or VT_BSTR
They are not convertable, are they ?
The value returned is in form of VT_DISPATCH , then there must be some property of that interface(object), that might interests you.
Prasad
MS MVP - VC++
|
|
|
|
|
Good morning,
i derived a class CMyStatusBarCtrl from CWindowImpl<mycstatusbarctrl,cstatusbarctrl>
i re-define the create method (private) and i need also to derive the "SubclassWindow" method.
But i don't know from which parent-class i need to derive
For example CStatusBarCtrl::SubclassWindow doesn't exists
Big thanks for help
|
|
|
|
|