|
You can use CDocument::GetFirstViewPosition / GetNextView to get the view windows. Then, as CView inherits from CWnd, you can use CWnd::GetDC to get the view's DC.
If you are in a SDI app, you can get the view straight away. In am MDI view, you potentially need to iterate ythrough them.
Another alternative, is to us CDocument::UpdateAllView (...) with a custom lParam, and let the views draw on themselves. A CDocument is supposed to have no idea about how its data is displayed - thats the point of separating them!
Iain.
|
|
|
|
|
Iain Clarke wrote: A CDocument is supposed to have no idea about how its data is displayed
Yup! but we break the rules sometimes!
Actually, I just need a refrence to a DC (the View's DC) to set some parameters, I am not doing any drawing...
- A programmer's national anthem; "AAAAAHHHHH!!!!"
|
|
|
|
|
Hi guys i want to save a file from a dialog box. II have my save dialog and all but when i save a file, i get only a blank file. is it bcoz of the CREATE_NEW attribute of the createFile method??? how do i save data in that file
please help
|
|
|
|
|
what other actions do you take to save the data?
|
|
|
|
|
what dialog box ? a CFileDialog dialog ?
When you create the file with CreateFile, you write something in it ? or you simply create it and hope that something will put data in the file ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Make sure you set the CREATE and/or WRITE flag(s) before you write something to that file. If you need a Save Dialog I recomend you Davide Calabro's CFileDialogST[^] Good luck!
|
|
|
|
|
Hello all.
I'm trying to get the source-code from the active text-editor window on the VS IDE.
I'm using the COM interface as follows:
<br />
CComPtr<EnvDTE::Document> ADocument;<br />
m_pDTE->get_ActiveDocument(&ADocument);
But what's next ? EnvDTE::Document does not contain any methods for text retrieval.
Any help would be appreciated.
|
|
|
|
|
Hi all,
I have a Win32/windowless/GUI-less/MFC-less application that currently sends a bit of data through HTTP via winsock.
Essentially, in some buffer, I format the standard HTTP headers in plain text, then the actual data to send, then send the whole thing via winsock, and close the connection. Relatively straightforward.
Now I've been asked to replace this so the program uses HTTPS instead, and to do this I have been provided with nothing more than a link to W3MFC[^], whose goal I suspect was not fully understood by The Powers That Be (who sent me the link).
My understanding of this library is that it essentially derives some classes from MFC's CSocket, and requires the library from OpenSSL.org, to implement some wrapper around all of this.
I'm not allowed to rely on MFC, as my final EXE must remain as small as possible--statically linking is not acceptable, and I don't have the luxury either of being able to rely on an external DLL that may or may not be there. It's just "gotta run" on anything from Win95 onward. This EXE's been in production for nearly 6 years.
So much for this library. I've started looking at OpenSSL itself.
On the server side, .NET is already being used to implement the site itself, provide access to a database, etc. I'm not familiar (yet) with .NET, and can only assume .NET already has some library (built in?) that can handle HTTPS clients...Either way, I'm not the one who's going to implement the server, but I can only assume an SSL server can handle any SSL client, provided the syntax is correct (just like any web server can handle any web browser, provided the requests adhere to the HTTP standard)...
Given the requirements above and this nebulous idea of "replacing HTTP with HTTPS"--where do I even start?
|
|
|
|
|
Daniel.
I recently had to add SSL support to a custom mail client of mine, and though this is an MFC app, I was using an old socket class in plain vanilla C++. In the end I used the MS SSPI library, but this probably won't work on Win9x unfortunately, so is probably of little use to you. I found some sample ATL code that used SSPI with a raw socket, which made life easier. I don't think HTTPS will be that different from POP/SMTP TLS/SSL, except you have to worry about certificates, etc.
|
|
|
|
|
> In the end I used the MS SSPI library, but this probably won't work on Win9x unfortunately
Well, to be honest, Win9x support is getting to be more of a "nice to have" feature at this point as there aren't too many 9x-based machines out there--we may be able to get away with telling our 9x customers that SSL will be for NT+ only.
I'll definitely look into MS's SSPI; in the meantime, if you could forward any relevant link or sample, that would be very much appreciated.
Thanks.
PS - anybody has experience with OpenSSL? Am I wasting my time even looking at that?
|
|
|
|
|
I'm not familiar with CSocket, but winsock works wells with OpenSSL API.
Kuphryn
|
|
|
|
|
> I'm not familiar with CSocket,
I'd rather not use it. My current code doesn't rely on MFC, and I don't want to introduce this dependency at this point in the program's life.
> but winsock works wells with OpenSSL API.
I "sorta" got this to run with the OpenSSL library. Compiling the library (with ms\do_ms.bat)generated two files, which got copied in the Windows directory: libeay32.dll (668KB), and ssleay32.dll (152KB). Do these figures sound correct to you? My compiled EXE is under 500KB, and I would hate to see it double in size "just" because of the SSL library it's using. I'm not allowed to require clients to have the DLLs pre-deployed (eg, preinstalled), so I'd have to embed the DLLs in the EXE itself and then extract/execute/delete them when done...
I'm beginning to see OpenSSL as a dead end. It's hard for me to believe an SSL library can't be compiled to under 50KB worth of binaries.
I'm starting to take a closer look at MS's SSPI as Robert suggested. If you can convince me otherwise, by all means, please tell me the library can be made smaller...
-- modified at 16:51 Monday 20th March, 2006
|
|
|
|
|
Is possible to transmit some parameters to a function in dll
am
|
|
|
|
|
|
Hello,
I want to overload only the IPropertyPage::Apply() part of the COlePropertyPage, and keep the call to other IPropertyPage method managed by COlePropertyPage
I have some thing similar to this:
class COleBaseParamPage : public COlePropertyPage
{
...
DECLARE_INTERFACE_MAP()
BEGIN_INTERFACE_PART(PropertyPage, IPropertyPage)
INIT_INTERFACE_PART(COleBaseParamPage, PropertyPage)
STDMETHOD(Apply)();
STDMETHOD(SetPageSite)(LPPROPERTYPAGESITE);
...
END_INTERFACE_PART(PropertyPage)
}
BEGIN_INTERFACE_MAP(COleBaseParamPage, COlePropertyPage)
INTERFACE_PART(COleBaseParamPage, IID_IPropertyPage, PropertyPage)
END_INTERFACE_MAP()
STDMETHODIMP COleBaseParamPage::XPropertyPage::SetPageSite(LPPROPERTYPAGESITE pPageSite)
{
METHOD_PROLOGUE_EX(COleBaseParamPage, PropertyPage)
// here I would call the original COlePropertyPage::XPropertyPage::SetPageSite()
}
I have made some test for calling the original COlePropertyPage::XPropertyPage::SetPageSite() by using the _GetBaseInterfaceMap() to get it's adress, but without success. I can't figure how to optain the original COlePropertyPage::XPropertyPage object adress
If someone have a suggestion, I will be very happy...
Thanck's
---
for information, I'm using some code issued from the CmdTarget code, like:
#define GetInterfacePtr(pTarget, pEntry) \
((LPUNKNOWN)((BYTE*)pTarget + pEntry->nOffset))
static LPUNKNOWN _getInterface(REFIID _iid, LPVOID me, const AFX_INTERFACEMAP* pMap)
{
const void* iid = &_iid;
DWORD lData1 = ((IID*)iid)->Data1;
do
{
const AFX_INTERFACEMAP_ENTRY* pEntry = pMap->pEntry;
ASSERT(pEntry != NULL);
while (pEntry->piid != NULL)
{
if (((DWORD*)pEntry->piid)[0] == lData1 &&
((DWORD*)pEntry->piid)[1] == ((DWORD*)iid)[1] &&
((DWORD*)pEntry->piid)[2] == ((DWORD*)iid)[2] &&
((DWORD*)pEntry->piid)[3] == ((DWORD*)iid)[3])
{
// check INTERFACE_ENTRY macro
LPUNKNOWN lpUnk = GetInterfacePtr(me, pEntry);
// check vtable pointer (can be NULL)
if (*(DWORD*)lpUnk != 0)
return lpUnk;
}
// entry did not match -- keep looking
++pEntry;
}
#ifdef _AFXDLL
} while ((pMap = (*pMap->pfnGetBaseMap)()) != NULL);
#else
} while ((pMap = pMap->pBaseMap) != NULL);
#endif
return NULL;
}
STDMETHODIMP COleBaseParamPage::XPropertyPage::SetPageSite(LPPROPERTYPAGESITE pPageSite)
{
METHOD_PROLOGUE_EX(COleBaseParamPage, PropertyPage)
IPropertyPagePtr p = _getInterface(IID_IPropertyPage, pThis, pThis->_GetBaseInterfaceMap());
p->SetPageSite(pPageSite);
return S_OK;
}
This code do recursive call, because the 'me' parameter is not the COlePropertySheet adress (I admit I'm a little lost with all these stuff)
|
|
|
|
|
Hello,
I want to overload only the IPropertyPage::Apply() part of the COlePropertyPage, and keep the call to other IPropertyPage method managed by COlePropertyPage
I have some thing similar to this:
class COleBaseParamPage : public COlePropertyPage
{
...
DECLARE_INTERFACE_MAP()
BEGIN_INTERFACE_PART(PropertyPage, IPropertyPage)
INIT_INTERFACE_PART(COleBaseParamPage, PropertyPage)
STDMETHOD(Apply)();
STDMETHOD(SetPageSite)(LPPROPERTYPAGESITE);
...
END_INTERFACE_PART(PropertyPage)
}
BEGIN_INTERFACE_MAP(COleBaseParamPage, COlePropertyPage)
INTERFACE_PART(COleBaseParamPage, IID_IPropertyPage, PropertyPage)
END_INTERFACE_MAP()
STDMETHODIMP COleBaseParamPage::XPropertyPage::SetPageSite(LPPROPERTYPAGESITE pPageSite)
{
METHOD_PROLOGUE_EX(COleBaseParamPage, PropertyPage)
// here I would call the original COlePropertyPage::XPropertyPage::SetPageSite()
}
I have made some test for calling the original COlePropertyPage::XPropertyPage::SetPageSite() by using the _GetBaseInterfaceMap() to get it's adress, but without success. I can't figure how to optain the original COlePropertyPage::XPropertyPage object adress
If someone have a suggestion, I will be very happy...
Thanck's
---
for information, I'm using some code issued from the CmdTarget code, like:
#define GetInterfacePtr(pTarget, pEntry) \
((LPUNKNOWN)((BYTE*)pTarget + pEntry->nOffset))
static LPUNKNOWN _getInterface(REFIID _iid, LPVOID me, const AFX_INTERFACEMAP* pMap)
{
const void* iid = &_iid;
DWORD lData1 = ((IID*)iid)->Data1;
do
{
const AFX_INTERFACEMAP_ENTRY* pEntry = pMap->pEntry;
ASSERT(pEntry != NULL);
while (pEntry->piid != NULL)
{
if (((DWORD*)pEntry->piid)[0] == lData1 &&
((DWORD*)pEntry->piid)[1] == ((DWORD*)iid)[1] &&
((DWORD*)pEntry->piid)[2] == ((DWORD*)iid)[2] &&
((DWORD*)pEntry->piid)[3] == ((DWORD*)iid)[3])
{
// check INTERFACE_ENTRY macro
LPUNKNOWN lpUnk = GetInterfacePtr(me, pEntry);
// check vtable pointer (can be NULL)
if (*(DWORD*)lpUnk != 0)
return lpUnk;
}
// entry did not match -- keep looking
++pEntry;
}
#ifdef _AFXDLL
} while ((pMap = (*pMap->pfnGetBaseMap)()) != NULL);
#else
} while ((pMap = pMap->pBaseMap) != NULL);
#endif
return NULL;
}
STDMETHODIMP COleBaseParamPage::XPropertyPage::SetPageSite(LPPROPERTYPAGESITE pPageSite)
{
METHOD_PROLOGUE_EX(COleBaseParamPage, PropertyPage)
IPropertyPagePtr p = _getInterface(IID_IPropertyPage, pThis, pThis->_GetBaseInterfaceMap());
p->SetPageSite(pPageSite);
return S_OK;
}
This code do recursive call, because the 'me' parameter is not the COlePropertySheet adress (I admit I'm a little lost with all these stuff)
|
|
|
|
|
Besides printf, can anyone think of another example of variable number of parameters using ellipsis?
<br />
void printf( const char *format, ... );<br />
This is the only declaration type I can't really think of when to use it, and HOW. Anyone?
|
|
|
|
|
what do you want to know ?
only some functions that use ellipsis?
or how they do that ?
|
|
|
|
|
v2.0 wrote: what do you want to know ?
only some functions that use ellipsis?
or how they do that ?
A situation where I want to use it, and how. Okay, for example,
<br />
int addition(int a, ...);<br />
This function returns the sum of variable number of integers, now in the function definition, how do I reference the other integer? b, c, d, etc?
What I want to know is an example of a function prototype with its definition. Can you think of any?
Thanks
|
|
|
|
|
int addition (int first, ... ) {
int iResult = 0;
int i = 0;
va_list int_list;
va_start(int_list, first);
while( i != -1 ) {
iResult += i;
i = va_arg(int_list, int);
}
va_end(int_list);
return iResult;
}
|
|
|
|
|
Hey thanks. Now I have another question, where did va_list come from? printf function has it too, I've seen va_list, va_start and va_arg. Are they built-in variables? macros?
|
|
|
|
|
don't mind how they are implemented. only keep in mind that they are part of the C (so C++) standard, and thanks to this, you can use them on whatever plateform knowing that they'll work...
you simply have to #include <stdio.h> and <stdarg.h>
for more informations, you could read this[^]
ps: if my answer was what you needed, score it right...
|
|
|
|
|
v2.0 wrote: ps: if my answer was what you needed, score it right...
Okay, done.
|
|
|
|
|
|
My advice on ellipsis - Don't use them, there're crap. My gripe is that it is impossible to create a type safe function that uses ellipsis.
Steve
|
|
|
|
|