|
|
Hi,
I have generated a webservice proxy code in c++ using SPROXY.exe tool.
Using this proxy code I call to webservice methods (written in Java). I can call the methods now but I am not able to send the authentication (username/pwd) information and hence the web service responds with error stating “Failed Authentication”.
How can I modify my proxy code so that I can send the authentication information in the SOAP header?
Proxy class code:
#pragma once
#if !defined(_WIN32_WINDOWS) && !defined(_WIN32_WINNT) && !defined(_WIN32_WCE)
#pragma message("warning: defining _WIN32_WINDOWS = 0x0410")
#define _WIN32_WINDOWS 0x0410
#endif
#include <atlsoap.h>
namespace GetTradesByCLRefIDService
{
template <typename TClient = CSoapSocketClientT<> >
class CGetTradesByCLRefIDServiceT :
public TClient,
public CSoapRootHandler
{
protected:
const _soapmap ** GetFunctionMap();
const _soapmap ** GetHeaderMap();
void * GetHeaderValue();
const wchar_t * GetNamespaceUri();
const char * GetServiceName();
const char * GetNamespaceUriA();
HRESULT CallFunction(
void *pvParam,
const wchar_t *wszLocalName, int cchLocalName,
size_t nItem);
HRESULT GetClientReader(ISAXXMLReader **ppReader);
public:
HRESULT __stdcall QueryInterface(REFIID riid, void **ppv)
{
if (ppv == NULL)
{
return E_POINTER;
}
*ppv = NULL;
if (InlineIsEqualGUID(riid, IID_IUnknown) ||
InlineIsEqualGUID(riid, IID_ISAXContentHandler))
{
*ppv = static_cast<ISAXContentHandler *>(this);
return S_OK;
}
return E_NOINTERFACE;
}
ULONG __stdcall AddRef()
{
return 1;
}
ULONG __stdcall Release()
{
return 1;
}
CGetTradesByCLRefIDServiceT(ISAXXMLReader *pReader = NULL)
:TClient(_T("http://someurl"))
{
SetClient(true);
SetReader(pReader);
}
~CGetTradesByCLRefIDServiceT()
{
Uninitialize();
}
void Uninitialize()
{
UninitializeSOAP();
}
HRESULT getTradeExecutionReportByClOrdID(
BSTR companyName,
BSTR userName,
BSTR clOrdID,
BSTR* __retval
);
};
typedef CGetTradesByCLRefIDServiceT<> CGetTradesByCLRefIDService;
struct __CGetTradesByCLRefIDService_getTradeExecutionReportByClOrdID_struct
{
BSTR companyName;
BSTR userName;
BSTR clOrdID;
BSTR __retval;
};
extern __declspec(selectany) const _soapmapentry __CGetTradesByCLRefIDService_getTradeExecutionReportByClOrdID_entries[] =
{
{
0x7D5AC538,
"companyName",
L"companyName",
sizeof("companyName")-1,
SOAPTYPE_STRING,
SOAPFLAG_NONE | SOAPFLAG_IN | SOAPFLAG_RPC | SOAPFLAG_ENCODED | SOAPFLAG_NULLABLE,
offsetof(__CGetTradesByCLRefIDService_getTradeExecutionReportByClOrdID_struct, companyName),
NULL,
NULL,
-1,
},
{
0x8253F720,
"userName",
L"userName",
sizeof("userName")-1,
SOAPTYPE_STRING,
SOAPFLAG_NONE | SOAPFLAG_IN | SOAPFLAG_RPC | SOAPFLAG_ENCODED | SOAPFLAG_NULLABLE,
offsetof(__CGetTradesByCLRefIDService_getTradeExecutionReportByClOrdID_struct, userName),
NULL,
NULL,
-1,
},
{
0xC68868A1,
"clOrdID",
L"clOrdID",
sizeof("clOrdID")-1,
SOAPTYPE_STRING,
SOAPFLAG_NONE | SOAPFLAG_IN | SOAPFLAG_RPC | SOAPFLAG_ENCODED | SOAPFLAG_NULLABLE,
offsetof(__CGetTradesByCLRefIDService_getTradeExecutionReportByClOrdID_struct, clOrdID),
NULL,
NULL,
-1,
},
{
0x11515F60,
"return",
L"return",
sizeof("return")-1,
SOAPTYPE_STRING,
SOAPFLAG_NONE | SOAPFLAG_OUT | SOAPFLAG_RPC | SOAPFLAG_ENCODED | SOAPFLAG_NULLABLE,
offsetof(__CGetTradesByCLRefIDService_getTradeExecutionReportByClOrdID_struct, __retval),
NULL,
NULL,
-1,
},
{ 0x00000000 }
};
extern __declspec(selectany) const _soapmap __CGetTradesByCLRefIDService_getTradeExecutionReportByClOrdID_map =
{
0x311696DC,
"getTradeExecutionReportByClOrdID",
L"getTradeExecutionReportByClOrdID",
sizeof("getTradeExecutionReportByClOrdID")-1,
sizeof("getTradeExecutionReportByClOrdID")-1,
SOAPMAP_FUNC,
__CGetTradesByCLRefIDService_getTradeExecutionReportByClOrdID_entries,
sizeof(__CGetTradesByCLRefIDService_getTradeExecutionReportByClOrdID_struct),
1,
-1,
SOAPFLAG_NONE | SOAPFLAG_RPC | SOAPFLAG_ENCODED,
0x17BF4332,
"http://someurl",
L"http://someurl",
sizeof("http://someurl")-1
};
extern __declspec(selectany) const _soapmap * __CGetTradesByCLRefIDService_funcs[] =
{
&__CGetTradesByCLRefIDService_getTradeExecutionReportByClOrdID_map,
NULL
};
template <typename TClient>
inline HRESULT CGetTradesByCLRefIDServiceT<TClient>::getTradeExecutionReportByClOrdID(
BSTR companyName,
BSTR userName,
BSTR clOrdID,
BSTR* __retval
)
{
if ( __retval == NULL )
return E_POINTER;
HRESULT __atlsoap_hr = InitializeSOAP(NULL);
if (FAILED(__atlsoap_hr))
{
SetClientError(SOAPCLIENT_INITIALIZE_ERROR);
return __atlsoap_hr;
}
CleanupClient();
CComPtr<IStream> __atlsoap_spReadStream;
__CGetTradesByCLRefIDService_getTradeExecutionReportByClOrdID_struct __params;
memset(&__params, 0x00, sizeof(__params));
__params.companyName = companyName;
__params.userName = userName;
__params.clOrdID = clOrdID;
__atlsoap_hr = SetClientStruct(&__params, 0);
if (FAILED(__atlsoap_hr))
{
SetClientError(SOAPCLIENT_OUTOFMEMORY);
goto __skip_cleanup;
}
__atlsoap_hr = GenerateResponse(GetWriteStream());
if (FAILED(__atlsoap_hr))
{
SetClientError(SOAPCLIENT_GENERATE_ERROR);
goto __skip_cleanup;
}
__atlsoap_hr = SendRequest(_T("SOAPAction: \"\"\r\n"));
if (FAILED(__atlsoap_hr))
{
goto __skip_cleanup;
}
__atlsoap_hr = GetReadStream(&__atlsoap_spReadStream);
if (FAILED(__atlsoap_hr))
{
SetClientError(SOAPCLIENT_READ_ERROR);
goto __skip_cleanup;
}
// cleanup any in/out-params and out-headers from previous calls
Cleanup();
__atlsoap_hr = BeginParse(__atlsoap_spReadStream);
if (FAILED(__atlsoap_hr))
{
SetClientError(SOAPCLIENT_PARSE_ERROR);
goto __cleanup;
}
*__retval = __params.__retval;
goto __skip_cleanup;
__cleanup:
Cleanup();
__skip_cleanup:
ResetClientState(true);
memset(&__params, 0x00, sizeof(__params));
return __atlsoap_hr;
}
template <typename TClient>
ATL_NOINLINE inline const _soapmap ** CGetTradesByCLRefIDServiceT<TClient>::GetFunctionMap()
{
return __CGetTradesByCLRefIDService_funcs;
}
template <typename TClient>
ATL_NOINLINE inline const _soapmap ** CGetTradesByCLRefIDServiceT<TClient>::GetHeaderMap()
{
static const _soapmapentry __CGetTradesByCLRefIDService_getTradeExecutionReportByClOrdID_atlsoapheader_entries[] =
{
{ 0x00000000 }
};
static const _soapmap __CGetTradesByCLRefIDService_getTradeExecutionReportByClOrdID_atlsoapheader_map =
{
0x311696DC,
"getTradeExecutionReportByClOrdID",
L"getTradeExecutionReportByClOrdID",
sizeof("getTradeExecutionReportByClOrdID")-1,
sizeof("getTradeExecutionReportByClOrdID")-1,
SOAPMAP_HEADER,
__CGetTradesByCLRefIDService_getTradeExecutionReportByClOrdID_atlsoapheader_entries,
0,
0,
-1,
SOAPFLAG_NONE | SOAPFLAG_RPC | SOAPFLAG_ENCODED,
0x17BF4332,
"http://someurl",
L"http://someurl",
sizeof("http://someurl")-1
};
static const _soapmap * __CGetTradesByCLRefIDService_headers[] =
{
&__CGetTradesByCLRefIDService_getTradeExecutionReportByClOrdID_atlsoapheader_map,
NULL
};
return __CGetTradesByCLRefIDService_headers;
}
template <typename TClient>
ATL_NOINLINE inline void * CGetTradesByCLRefIDServiceT<TClient>::GetHeaderValue()
{
return this;
}
template <typename TClient>
ATL_NOINLINE inline const wchar_t * CGetTradesByCLRefIDServiceT<TClient>::GetNamespaceUri()
{
return L"http://someurl";
}
template <typename TClient>
ATL_NOINLINE inline const char * CGetTradesByCLRefIDServiceT<TClient>::GetServiceName()
{
return NULL;
}
template <typename TClient>
ATL_NOINLINE inline const char * CGetTradesByCLRefIDServiceT<TClient>::GetNamespaceUriA()
{
return "http://someurl";
}
template <typename TClient>
ATL_NOINLINE inline HRESULT CGetTradesByCLRefIDServiceT<TClient>::CallFunction(
void *,
const wchar_t *, int,
size_t)
{
return E_NOTIMPL;
}
template <typename TClient>
ATL_NOINLINE inline HRESULT CGetTradesByCLRefIDServiceT<TClient>::GetClientReader(ISAXXMLReader **ppReader)
{
if (ppReader == NULL)
{
return E_INVALIDARG;
}
CComPtr<ISAXXMLReader> spReader = GetReader();
if (spReader.p != NULL)
{
*ppReader = spReader.Detach();
return S_OK;
}
return TClient::GetClientReader(ppReader);
}
} // namespace GetTradesByCLRefIDService
Code: webservice client
using namespace GetTradesByCLRefIDService;
GetTradesByCLRefIDService::CGetTradesByCLRefIDService service;
//HRESULT hr = service.getTradeExecutionReportByClOrdID("","","","");
//GetTradesByCLRefIDService::String str;
BSTR str;
//str.resp = CComBSTR(L"AlexDemoCO");
HRESULT hr = service.getTradeExecutionReportByClOrdID(companyname,username,ClOrdId,&str);
cout << sizeof(str);
if (FAILED(hr))
{
cout <<" fail to call";
//cout << L"0x" << hr;
//std::wcout << L"0x" << std::hex << hr;
//cout << (char *)str;
cout << sizeof(str);
return hr;
}
// cout << (char *)str;
std::wcout << static_cast<const wchar_t*> (str);
cout << "Web Service Called:Success";
cout << sizeof(str);
Regards
|
|
|
|
|
I Created a list view and modified the style with LVS_EX_CHECKBOXES, and the checkbox is created, but there is no image where the checkbox should be, only a blank space.
Here's part of the code:
<br />
<br />
<br />
CAPPRESULT CListViewCtrl::Create(HWND pHWndParentS_, int nWndID_, CWnd::SCWndConf* pConfDataS)<br />
{<br />
<br />
CAPPRESULT sRes;<br />
<br />
if(CAPP_FAILED(sRes = CCtrl::Create(pHWndParentS_, nWndID_, pConfDataS)))<br />
{<br />
<br />
return sRes;<br />
<br />
}
<br />
WNDCLASSEX WindowClassS;<br />
<br />
if(CWndMgr::GetInstance().InsertRegisteredClassName("CListViewCtrl", FALSE))<br />
{<br />
<br />
INITCOMMONCONTROLSEX InitCommCtrlS = {0};<br />
InitCommCtrlS.dwSize = sizeof(INITCOMMONCONTROLSEX);<br />
InitCommCtrlS.dwICC = ICC_TREEVIEW_CLASSES;<br />
InitCommonControlsEx(&InitCommCtrlS);<br />
<br />
}
<br />
DWORD ulStyle, ulExStyle;<br />
<br />
if(static_cast<CListViewCtrl::SCListViewCtrlConf*>(pConfDataS)->m_bEditLabel)<br />
{<br />
<br />
ulStyle = WS_TABSTOP | WS_CHILD | WS_VISIBLE | LVS_AUTOARRANGE | LVS_REPORT | LVS_OWNERDATA | LVS_EDITLABELS;<br />
<br />
}else<br />
{<br />
<br />
ulStyle = WS_TABSTOP | WS_CHILD | WS_VISIBLE | LVS_AUTOARRANGE | LVS_REPORT | LVS_OWNERDATA;<br />
<br />
}
<br />
HWND pHWndS;<br />
<br />
if(static_cast<CListViewCtrl::SCListViewCtrlConf*>(pConfDataS)->m_bNoBorder)<br />
{<br />
<br />
ulExStyle = NULL;<br />
<br />
}else<br />
{<br />
<br />
ulExStyle = WS_EX_CLIENTEDGE;<br />
<br />
}
<br />
if(CAPP_FAILED(sRes = this->CreateEx(ulExStyle, WC_LISTVIEW, "", ulStyle,<br />
0,0,0,0, pHWndParentS_, (HMENU) (int) nWndID_, NULL, &pHWndS)))<br />
{<br />
<br />
return sRes;<br />
<br />
}
<br />
<br />
this->m_unIconID = static_cast<CListViewCtrl::SCListViewCtrlConf*>(pConfDataS)->m_unIconID;<br />
<br />
if(CAPP_FAILED(sRes = (this->OnCreate(pHWndS, nWndID_))))<br />
{<br />
<br />
return sRes;<br />
<br />
}
<br />
return CAPP_ERR_NO_ERRORS;<br />
<br />
}
<br />
<br />
<br />
<br />
CAPPRESULT CListViewCtrl::SetExtendedStyleEx(DWORD ulExMask_, DWORD ulExStyle_)<br />
{<br />
<br />
CAPPRESULT sRes;<br />
<br />
HWND pHWndS;<br />
<br />
if(CAPP_FAILED(sRes = this->GetHWnd(&pHWndS)))<br />
{<br />
<br />
return sRes;<br />
<br />
}
<br />
ListView_SetExtendedListViewStyleEx(pHWndS, ulExMask_, ulExStyle_);<br />
<br />
<br />
return CAPP_ERR_NO_ERRORS;<br />
<br />
}
<br />
<br />
<br />
<br />
<br />
Please if anybody has any clue as to what might be happening let me know.
I aoplogize if the OO library that I'm using, which is my own, can be a bit confusing, but it's basically the same Win32.
|
|
|
|
|
When I tried to run my Dialog based application .. i Got the error message - Failed to create empty Document...
Why is it so
Proud To Be an Indian
|
|
|
|
|
vivekphlp wrote: When I tried to run my Dialog based application
Are you sure that it's dialog based? That message usually only is seen for SDI or MDI apps.
|
|
|
|
|
oops sorry its an SDI appln only...
Proud To Be an Indian
|
|
|
|
|
Hi,
I think some where near your View creation fails.
Check for OnCreate,... return -1;
This happens when the document is created with no views.
Best Regards
Raj
|
|
|
|
|
yes -1 is returned .
but i dont understand that how no view is created...
Proud To Be an Indian
|
|
|
|
|
Hi,
What I meant is check whether the code hits on "return -1;" like statement upon execution.
ie; Your View creation may not be successfull, You may debug/review the code, this is only a hint. May be, you have overrided your frame window OnCreateClient and its baseclass is not called, causing it to create no view.
Best Regards,
Raj
|
|
|
|
|
Thanks for the help . . .
Actually a toolbar resource was removed, but still the code for creating the toolbar was there... which lead to the same error
Proud To Be an Indian
|
|
|
|
|
I Created a list view and modified the style with LVS_EX_CHECKBOXES, and the checkbox is created, but there is no image where the checkbox should be, only a blank space.
Here's part of the code:
<br />
<br />
CAPPRESULT CListViewCtrl::Create(HWND pHWndParentS_, int nWndID_, CWnd::SCWndConf* pConfDataS)<br />
{<br />
<br />
CAPPRESULT sRes;<br />
<br />
if(CAPP_FAILED(sRes = CCtrl::Create(pHWndParentS_, nWndID_, pConfDataS)))<br />
{<br />
<br />
return sRes;<br />
<br />
}
<br />
WNDCLASSEX WindowClassS;<br />
<br />
if(CWndMgr::GetInstance().InsertRegisteredClassName("CListViewCtrl", FALSE))<br />
{<br />
<br />
INITCOMMONCONTROLSEX InitCommCtrlS = {0};<br />
InitCommCtrlS.dwSize = sizeof(INITCOMMONCONTROLSEX);<br />
InitCommCtrlS.dwICC = ICC_TREEVIEW_CLASSES;<br />
InitCommonControlsEx(&InitCommCtrlS);<br />
<br />
}
<br />
DWORD ulStyle, ulExStyle;<br />
<br />
if(static_cast<CListViewCtrl::SCListViewCtrlConf*>(pConfDataS)->m_bEditLabel)<br />
{<br />
<br />
ulStyle = WS_TABSTOP | WS_CHILD | WS_VISIBLE | LVS_AUTOARRANGE | LVS_REPORT | LVS_OWNERDATA | LVS_EDITLABELS;<br />
<br />
}else<br />
{<br />
<br />
ulStyle = WS_TABSTOP | WS_CHILD | WS_VISIBLE | LVS_AUTOARRANGE | LVS_REPORT | LVS_OWNERDATA;<br />
<br />
}
<br />
HWND pHWndS;<br />
<br />
if(static_cast<CListViewCtrl::SCListViewCtrlConf*>(pConfDataS)->m_bNoBorder)<br />
{<br />
<br />
ulExStyle = NULL;<br />
<br />
}else<br />
{<br />
<br />
ulExStyle = WS_EX_CLIENTEDGE;<br />
<br />
}
<br />
if(CAPP_FAILED(sRes = this->CreateEx(ulExStyle, WC_LISTVIEW, "", ulStyle,<br />
0,0,0,0, pHWndParentS_, (HMENU) (int) nWndID_, NULL, &pHWndS)))<br />
{<br />
<br />
return sRes;<br />
<br />
}
<br />
<br />
this->m_unIconID = static_cast<CListViewCtrl::SCListViewCtrlConf*>(pConfDataS)->m_unIconID;<br />
<br />
if(CAPP_FAILED(sRes = (this->OnCreate(pHWndS, nWndID_))))<br />
{<br />
<br />
return sRes;<br />
<br />
}
<br />
return CAPP_ERR_NO_ERRORS;<br />
<br />
}
<br />
<br />
<br />
<br />
CAPPRESULT CListViewCtrl::SetExtendedStyleEx(DWORD ulExMask_, DWORD ulExStyle_)<br />
{<br />
<br />
CAPPRESULT sRes;<br />
<br />
HWND pHWndS;<br />
<br />
if(CAPP_FAILED(sRes = this->GetHWnd(&pHWndS)))<br />
{<br />
<br />
return sRes;<br />
<br />
}
<br />
ListView_SetExtendedListViewStyleEx(pHWndS, ulExMask_, ulExStyle_);<br />
<br />
<br />
return CAPP_ERR_NO_ERRORS;<br />
<br />
}
<br />
<br />
<br />
CAPPRESULT CListViewCtrl::OnCreate(HWND pHWndS_, int nWndID_)<br />
{<br />
<br />
CAPPRESULT sRes;<br />
if(CAPP_FAILED(sRes = CCtrl::OnCreate(pHWndS_, nWndID_)))<br />
{<br />
<br />
return sRes;<br />
<br />
}
<br />
if(this->m_unIconID)<br />
{<br />
<br />
if(CAPP_FAILED(sRes = this->m_ImageListC.Create( 16, 16, ILC_COLOR32 | ILC_MASK, 1, 0 )))<br />
{<br />
<br />
return sRes;<br />
<br />
}
<br />
HICON pIconHandleS;<br />
<br />
if(!(pIconHandleS = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(this->m_unIconID), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR)))<br />
{<br />
<br />
return sRes;<br />
<br />
}
<br />
UINT unImageIndex;<br />
if(CAPP_FAILED(sRes = this->m_ImageListC.Add((HICON)pIconHandleS, &unImageIndex)))<br />
{<br />
<br />
return sRes;<br />
<br />
}
<br />
if(CAPP_FAILED(sRes = this->SetImageList(&this->m_ImageListC, CListViewCtrl::m_eImageListStyle::SMALL)))<br />
{<br />
<br />
return sRes;<br />
<br />
}
<br />
}
<br />
<br />
<br />
return CAPP_ERR_NO_ERRORS;<br />
<br />
}
<br />
<br />
<br />
<br />
<br />
<br />
CListViewCtrl::SCListViewCtrlConf ConfDataS;<br />
<br />
ZeroMemory(&ConfDataS, sizeof(CChildWnd::SCChildWndConf));<br />
<br />
ConfDataS.m_bFrameDrawOvr = FALSE;<br />
ConfDataS.m_bClientDrawOvr = FALSE;<br />
ConfDataS.m_bEditLabel = FALSE;<br />
ConfDataS.m_pParentC = this;<br />
ConfDataS.m_unIconID = NULL;<br />
ConfDataS.m_fRelX = 0;<br />
ConfDataS.m_fRelY = 13;<br />
ConfDataS.m_fRelWidth = 100;<br />
ConfDataS.m_fRelHeight = 87;<br />
ConfDataS.m_nNoReszSide = CChildWnd::SCChildWndConf::m_eNoReszSide::NO_RESZ_TOP | CChildWnd::SCChildWndConf::m_eNoReszSide::NO_RESZ_LEFT | CChildWnd::SCChildWndConf::m_eNoReszSide::NO_RESZ_RIGHT | CChildWnd::SCChildWndConf::m_eNoReszSide::NO_RESZ_BOTTOM;<br />
<br />
if(CAPP_FAILED(sRes = this->AddChild("CListViewCtrl", &(this->m_pClientEventsListViewC), &ConfDataS, &(this->m_nClientEventsListViewID))))<br />
{<br />
<br />
return sRes;<br />
<br />
}
<br />
<br />
<br />
LV_COLUMN ListViewColumnS;<br />
<br />
ListViewColumnS.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;<br />
ListViewColumnS.fmt = LVCFMT_LEFT;<br />
ListViewColumnS.cx = 100;<br />
ListViewColumnS.pszText = "Evento";<br />
<br />
int nColumnIndex = 0;<br />
if(CAPP_FAILED(sRes = dynamic_cast<CListViewCtrl*>(this->m_pClientEventsListViewC)->InsertColumn(nColumnIndex, &ListViewColumnS, &nColumnIndex)))<br />
{<br />
<br />
return sRes;<br />
<br />
}
<br />
<br />
ListViewColumnS.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;<br />
ListViewColumnS.fmt = LVCFMT_LEFT;<br />
ListViewColumnS.cx = 100;<br />
ListViewColumnS.pszText = "Utilidades";<br />
<br />
nColumnIndex = 1;<br />
if(CAPP_FAILED(sRes = dynamic_cast<CListViewCtrl*>(this->m_pClientEventsListViewC)->InsertColumn(nColumnIndex, &ListViewColumnS, &nColumnIndex)))<br />
{<br />
<br />
return sRes;<br />
<br />
}
<br />
if(CAPP_FAILED(sRes = dynamic_cast<CListViewCtrl*>(this->m_pClientEventsListViewC)->SetExtendedStyleEx(LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES)))<br />
{<br />
<br />
return sRes;<br />
<br />
}
<br />
<br />
<br />
<br />
Please if anybody has any clue as to what might be happening let me know.
I aoplogize if the OO library that I'm using, which is my own, can be a bit confusing, but it's basically the same Win32.
|
|
|
|
|
|
Hello
I need to apply margins to CEditView text while printing through a page setup dialog. these should be visible in print preview also.
any help ?
Thanks
|
|
|
|
|
hi all
i have made a SDI application
please help me
when i right click on a menu item
it will not show the event handler on menu item
// I double click on IDR_MAINFRAME and i will show mwnues
i add a tool menu and a dependent item under this but when i right
click on it it will not show event handler
thanks
hi
|
|
|
|
|
Can you more explainn do you want when you right click it shows a contextmenu or you want to fire an event?
|
|
|
|
|
I'd hoped since CHtmlView was derived from CFormView that I could use dialog templates to put controls over the HTML. Isn't that *why* it was derived from CFormView?
But CHtmlView has no constructor with a template parameter as CFormView(templateID) does.
And here I'd got a CDhtmlDialog test program working so well, thinking it would be easy to port to an existing MDI CFormView program I need the technique in
I don't think I can pass a templateID to protected CFormView(templateID) in the base initialization
although CHtmlView can, because its *directly* derived from CFormView, unlike my class.
// What CHtmlView does
CHtmlView::CHtmlView()
: CFormView((LPCTSTR) NULL)
{
}
// And I can't after deriving from CHtmlView
// error C2614: 'CMfcieView' : illegal member initialization: 'CFormView' is not a base or member
CMfcieView::CMfcieView()
: CFormView(IDD_MYDIALOG)
{
}
|
|
|
|
|
Hi,
If you want your CDhtmlDialog to be used in any of your view you can make it a modeless dialog and make a client of View window.
I prefer CDhtmlDialog, since It has already loaded with event sinks, while if you want CHtmlView to get events from controls like button click you need to code a little.
|
|
|
|
|
Sounds promising, thanks for your response.
Do you know of any examples, or a code snippet?
|
|
|
|
|
Hi,
I used similar method in my project, I used modeless CDHtmlDialog there.
I think there are lots of article in codeproject for CDhtmlDialog, please search.
MSDN example DhtmlExplore will give you a good start, it demonstrates dynamic
content on html page.
Best Regards
Raj
|
|
|
|
|
I think I already understand the CDHtmlDialog techniques.
I'm trying to figure out what you meant by "and make a client of View window".
Something like this? (which hasn't worked for me yet )
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext)
{
CDummyDlg *pDummy = new CDummyDlg();
BOOL res = pDummy->Create(IDD_DIALOG1, NULL);
return res;
/*
return m_wndSplitter.Create(this,
2, 2, // TODO: adjust the number of rows, columns
CSize(10, 10), // TODO: adjust the minimum pane size
pContext);
*/
}
|
|
|
|
|
WhiteSky has posted a link to document, which uses CDhtmlDialog Code and made a CView based class. You may try this,
And if you want modeless dialog method, would I like to know want's the problem, Does it isn't compiled or run time problem.
pDummy->Create(IDD_DIALOG1, NULL);
you are passing "NULL", you need to pass "this", then only it becomes the client of CChildFrame.
Moreover, I expect you to create a client of view. since you are making client of frame window, the document has no View object, this will cause problem.
Best Regards
Raj
|
|
|
|
|
I'd seen that sample, but it's not using any dialog templates.
Like you, I think I'd prefer to use CDHtmlDialog, if I could figure out how to display the dialog in the view
|
|
|
|
|
Ok,
Its simple,
1) create a modeless dialog of CDhtmlDialog.
Create a dialog resource and add class derived from CDhtmlDialog.
To make it modeless implement a default contructor and implement a simple create function
BOOL CYourModelssDHTMLdlg::Create(CWnd* pParentWnd)
{
return CDHtmlDialog::Create(IDD_DIALOG1, pParentWnd);
}
use create() function in your CView OnCreate() / equavalent.
int CYourView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
m_yourModelssDHTMLdlg.Create(this);
}
Note: set the dialog style to WS_CHILD, WS_VISIBLE, No BORDER , NO TITLEBAR use resource designer or on your code (precreateWindow()).
2) On your Views OnSize()
void CYourView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
m_yourModelssDHTMLdlg.MoveWindow(0, 0, cx, cy);
}
You might have missed it so you thought its not working.
Try this, this requires a time of 5~10 minutes.
Note: remember dialog style, resize and the dialog might have ok and cancel button this will cause the dialog to exitin its default behaviour.
I didn't explored CDHtmlDialog::EnableModeless, try this when you get time
Best Regards
Raj
|
|
|
|
|
|
how to send mail from vc++ program.
I want to sent same message at same time to both yahoo as well as google.
How to do this
|
|
|
|
|