|
You've declared the Inner class as protected. declare it as public and you'll get it to work!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
class Big
{
protected:
static const int CONST_VALUE;
class Inner
{
public:
Inner ();
int x;
};
<font color=red> friend class Inner;</font>
}; Add the friend declaration, that should do the trick.
--Mike--
Friday's GoogleFight results: Britney Spears 2,190,000 - Erica Weichers 23
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hello,
I know that if I declare Inner as friend it works on VC 6.0. My problem is: Which compiler's bug is this?
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
But it is not a compiler bug!
Protected members can ONLY be accessed through inheritance.
Do it piblic or as Dunn said friend.
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Rickard Andersson wrote:
Protected members can ONLY be accessed through inheritance.
I understand that perfectly. My problem is why my sample compiles in VC 7.0!
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
Alexandru Savescu wrote:
My problem is why my sample compiles in VC 7.0
That's a bug... or something... weird!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Alexandru Savescu wrote:
Which compiler's bug is this?
That, I don't know. Needing the friend declaration just seemed like The Way It Was Done. You should probably consult the C++ spec for the definitive answer.
--Mike--
Friday's GoogleFight results: Britney Spears 2,190,000 - Erica Weichers 23
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
To all specialists,
i wrote a MFC programm which starts Microsoft Word, creates a document, adds a table to the document and saves the document.
I used the msword9.olb to add the needed classes to my project.
The only thing that bothers me is that i have to find out what values to pass to function by "try and error".
For example i want to create a table with the autofitbehavior set to "FitToContent".
The tables.add function is defined as:
Tables::Add(LPDISPATCH Range, long NumRows, long NumColums, Variant* DefaultTableBehavior, Variant* AutoFitBehavior)
What value does this function expect in "AutoFitBehavior" to set the table to "FitToContent"?
As i said, i fond out by "Try and error". But there must be a better way because there are a lot of functions where this approach will definitely not work.
If anybody knows where to find some documentation like:
"Set AutoFitBehavior to '2' to get 'FitToContent'" i would be glad if he could let me know.
Thanks in advance.
|
|
|
|
|
I added a band with a checkbox with this:
m_reabr.AddBar(&m_check, "On the bar", NULL, RBBS_BREAK|RBBS_GRIPPERALWAYS)
APparently RBBS_GRIPPERALWAYS means that "sizing wrinkles" are present. WHen I ran my code I wasnt able to resize the rebar.
ALso I couldnt move it around. For this do I need to do some docking code?
Thanks
Appreciate your help,
ns
|
|
|
|
|
I tried duplicating the docking code that m_wndToolBAr has, but it asserted on the very first line:
rebar.EnableDocking(CBRS_ALIGNANY);
So what do I need to do to make my rebar move around like the standard toolbar does?
Appreciate your help,
ns
|
|
|
|
|
Hello,
I've used this code in order to get access to the HTMLDocument:
CComQIPtr<IHTMLDocument2> spHTMLDocument = this->m_HTMLCtrl.GetHtmlDocument();
if(spHTMLDocument)
{
CComQIPtr<IHTMLElement>> spHTML;
spHTMLDocument->get_body(&spHTML);
if (spHTML)
{
bstr = csCodiHTML.AllocSysString();
spHTML->put_innerHTML(bstr);
spHTML.Release();
}
else
{
bstr = csCodiHTML.AllocSysString();
spHTMLDocument->createElement(bstr,&spHTML); <code>
}
}
But the first time in which it is accessed the document doesn't exist, and I was wondering if it was possible to create it programatically.
In order to create it I've thought in doing what is written in the else clause, but it has no effect over the HTML document...
Could you give me an advice?
Thank you in advance...
|
|
|
|
|
Joan Murt wrote:
spHTMLDocument->get_body(&spHTML);
This line of code tries to retrieve the <BODY> element. Depending on what is loaded into Internet Explorer, this indeed may be NULL. In this case, a document is created after the first document.write call (translate this to C++ code).
|
|
|
|
|
OK,
in order to do that I need to use a SAFEARRAY, do you know how to work with the SAFEARRAY?
Searching to the MSDN I've not found any example...
Thank you in advance...
|
|
|
|
|
Here is a sample code :
LPVOID ptr = "my text";
LPSAFEARRAY psa;
UINT cElems = lstrlen( (char*)ptr );
LPSTR pOutput;
psa = ::SafeArrayCreateVector(VT_UI1, 0, cElems);
if (!psa)
return;
::SafeArrayAccessData(psa, (LPVOID*)&pOutput);
memcpy(pOutput, ptr, cElems);
::SafeArrayUnaccessData(psa);
pHtmlDoc->write( psa );
::SafeArrayDestroy( psa );
|
|
|
|
|
I don't understand why, but it has not worked as I expected...
it seems that the document is not created as it should be...(I'll try again...)
but thank you for your cute sample...
One question:
at the beggining you assign "my text" to a LPVOID ptr, how do I assign a CString to that ptr?
Thank you in advance!
|
|
|
|
|
HI,
How to access USB port from VC++?
I have used DirectInput IDirectInput8::EnumDevices() but it's not working
How to use DirectInput to access USB port, and enumerate
all devices attached to computer?
thnaks
|
|
|
|
|
I've seen few good source code here at CP implementing POP3 and SMTP protocol, but not a single that implements IMAP protocol. If you know any such code that implements IMAP, then please inform me.
|
|
|
|
|
Hello
I want to create a baseclass for socket servers that use io completion ports.
But I cant manage to pass a class function to BindIoCompletionCallback.
BOOL BindIoCompletionCallback(
HANDLE FileHandle,
LPOVERLAPPED_COMPLETION_ROUTINE Function,
ULONG Flags
);
I call it with:
BindIoCompletionCallback((HANDLE)m_sdListen, DoneIO, 0);
My class looks like:
class IocpServer
{
public:
IocpServer(void);
~IocpServer(void);
void CreateListenSocket(int ListenPort);
void Start(void);
HANDLE GetDieEvent();
void CALLBACK DoneIO(DWORD dwErrorCode,
DWORD dwNumberOfBytesTransferred,
LPOVERLAPPED lpOverlapped);
private:
SOCKET m_sdListen;
DWORD m_dwThreadCount;
HANDLE m_hIOCP;
UINT m_iListenPort;
HANDLE m_hDieEvent;
};
I get this error:
d:\projects\cpp\Datatal\HvdServer\IocpServer.cpp(24) : error C2664: 'BindIoCompletionCallback' : cannot convert parameter 2 from 'void (DWORD,DWORD,LPOVERLAPPED)' to 'LPOVERLAPPED_COMPLETION_ROUTINE'
None of the functions with this name in scope match the target type
|
|
|
|
|
I guess, that if the DoneIO is the member of your class, you can't do it in that way. The DoneIO can be a member only if it is a static member, then you can use it for callbacks. Normal class members have calling convention _thiscall, which you cannot achieve in callbacks. So for you it will help to make that function static (static members do not have the first hidden parameter - this).
|
|
|
|
|
I'm using MSVC++6, and I have a normal Doc/view application.
I have an item in the File menu, which iniates a dialog. How can I initiate the dialog automatically when the application is started, _after_ the application window is fully visible?
I have placed a call to the function in more places than I want to think about, and I always get the dialog _before_ the application window is drawn.
I'm just so tired of that, so tired...
|
|
|
|
|
Try to add the dialog call in the InitInstance() function of your application before you return the function.
BOOL CTestApp::InitInstance()
{
...
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
...
CMyDialog dlg;
dlg.DoModal();
return TRUE;
}
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
The function is in CView derived class. How could I get a pointer there so I won't have to rewrite the code in InitInstance?
(Explanation: The OnFileSelectserver() function is in CView derived class, and it has calls to CDocument derived class. Now it would need to be called from CWinApp based class.)
|
|
|
|
|
What kind of pointer do you have in CView derived class?
I thought you want do display a dialog after showing the application ... is that right?
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Yes, I want to show a dialog *after* showing the application window. All solutions I have tried will show the dialog before painting the application window.
Err.. I am not sure what you mean with "what kind of pointer do you have in CView derived class".
The only flaw in my application (that I know of ) is that the dialog should be iniated automatically instead of having to iniate it from menu. The menu item is handled in CView derived class (CMyView), in OnFileSelectserver() function. That function has calls to CDocument derived class (CMyDocument).
So I need to be able to call CMyView::OnFileSelectserver() from inside CWinApp based class (CMyApp), in InitInstance(). How to do that?
Putting the CMyView::OnFileSelectserver() in CMyView::OnInitialUpdate() causes the dialog to be shown first, then a pause as the program gathers data and only after that the application is shown. Doing that skips the progress bar and gives the impression that nothing is happening. That's the problem. First application window, THEN dialog.
|
|
|
|
|
Add the following code lines in your InitInstance function of your application:
...
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
CYourView* pView = (CYourView*) ((CFrameWnd*) m_pMainWnd)->GetActiveView();
pView->SendMessage(WM_COMMAND, ID_for_your_OnFileSelectserver_menu_item, 0);
return TRUE;
Insert the right ID for the ID_for_your_OnFileSelectserver_menu_item in the SendMessage function.
I hope this helps you!
Daniel
---------------------------
Never change a running system!
|
|
|
|