|
Which destructor? If you are talking about the base-class destructor, this is a classic one. The destructor must be virtual
|
|
|
|
|
Both base class destructor and inherited class destructor are plain public.
So, do you say that I must convert one of them to virtual?
Miroslav Rajcic
http://www.spacetide.com
|
|
|
|
|
Absolutely - your base class destructor must be virtual. This is how, for example, the designers of the string class stopped people deriving from it, they didn't make the destructor virtual.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
I tried your tip and it works now
I have declared base class destructor as virtual.
Thanks again.
Miroslav Rajcic
http://www.spacetide.com
|
|
|
|
|
We have a server app that uses overlapped socket I/O that runs fine on a single-CPU machine under NT 4 and W2K and also on a dual under NT. We have just received a quad running W2K Advanced Server and our app blows up big time.
We have nailed the problem down to WSAAccept() returning 0 when nobody is trying to connect instead of -1 (i.e. INVALID_SOCKET). We tried hacking around this by checking for 0 as well as -1 but we ran into problems later on: we also receive data using overlapped I/O and when our event gets signalled we call WSAGetOverlappedResult() to find out how many bytes have arrived; this is failing with WSASYSCALLFAILURE ("A system call that should never fail has failed"!!!) and doesn't initialize the byte count variable.
We have stripped everything out into a test app, running on a single thread, as dumb and as simple as we can make it and it is still failing. We are not sure if this problem is SMP-related but that is certainly our first suspicion.
Has anyone ever seen anything like this?!?! It just occurred to me that we were using WSA- functions on a socket created by socket(), but apparently that is OK (from the MSDN: "Overlapped I/O follows the model established in Win32 and can be performed only on sockets created through the WSASocket function with the WSA_FLAG_OVERLAPPED flag set or sockets created through the socket() function").
This is our stripped-down sample app:
cout << "Creating a socket..." << endl ;
SOCKET hListenSocket = socket( AF_INET , SOCK_STREAM , 0 ) ;
if ( hListenSocket == INVALID_SOCKET )
{
cout << "ERROR: Can't create the socket." << endl ;
exit( 1 ) ;
}
cout << "- hListenSocket=" << hListenSocket << endl ;
struct hostent* pHostEnt = gethostbyname( pHostAddress ) ;
if ( pHostEnt == NULL )
{
cout << "ERROR: Can't resolve the host name: " << pHostAddress << endl ;
exit( 1 ) ;
}
in_addr hostAddress = *((struct in_addr *)pHostEnt->h_addr_list[0]) ;
cout << "Binding the socket." << endl ;
sockaddr_in addr ;
addr.sin_family = AF_INET ;
addr.sin_addr.s_addr = hostAddress.s_addr ;
addr.sin_port = htons( portNo ) ;
int rc = bind( hListenSocket , (sockaddr*)&addr , sizeof(addr) ) ;
if ( rc != 0 )
{
cout << "ERROR: Can't bind the socket ; rc=" << rc << endl ;
exit( 1 ) ;
}
cout << "Listening on the socket..." << endl ;
rc = listen( hListenSocket , SOMAXCONN ) ;
if ( rc != 0 )
{
cout << "ERROR: Can't listen on the socket ; rc=" << WSAGetLastError() << endl ;
exit( 1 ) ;
}
WSAEVENT hConnectEvent = WSACreateEvent() ;
rc = WSAEventSelect( hListenSocket , hConnectEvent , FD_ACCEPT ) ;
if ( rc != 0 )
{
cout << "ERROR: Can't set the connect event ; rc=" << WSAGetLastError() << endl ;
exit( 1 ) ;
}
cout << "Waiting for a connection..." << endl ;
SOCKET hSocket = WSAAccept( hListenSocket , NULL , NULL , NULL , NULL ) ;
if ( hSocket == INVALID_SOCKET )
{
cout << "- Connection pending..." << endl ;
WSAEVENT hEvents[1] ;
hEvents[0] = hConnectEvent ;
DWORD rc = WSAWaitForMultipleEvents( 1 , hEvents , FALSE , INFINITE , FALSE ) ;
if ( rc == WSA_WAIT_EVENT_0 )
{
cout << "Connection received." << endl ;
hSocket = WSAAccept( hListenSocket , NULL , NULL , NULL , NULL ) ;
cout << "- hSocket=" << hSocket << endl ;
onServerConnection( hSocket ) ;
}
}
else
{
cout << "- Connection received immediately ; hSocket=" << hSocket << endl ;
onServerConnection( hSocket ) ;
}
|
|
|
|
|
Hi!
I'm trying to load a docking bar stored inside a
DLL into my client app, but I just can't get it
to work. It asserts when I call the docking bar's
Create() method.
Inside the DLL, I'm doing all my work in a
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// do MFC stuff here
}
block. The docking bar works on its own. It works
if I declare and create it inside the client
instead of inside the DLL.
I guess the problem comes from the fact that
I can't get a valid CFrameWnd* to pass to the
docking bar's Create() method, and I'm not
sure how to get one.
I've tried passing a pointer to the CFrameWnd of
the client app to the DLL, but I still get that
ASSERT. I've tried passing the HWND of the client
to the DLL, and then have the DLL find the right
CFrameWnd* by calling FromHandle(), but what I
get never works either. The same ASSERT fires.
The actual ASSERT (if it's helpful to know) is
ASSERT(pMap != NULL);
At line 879 in Wincore.cpp.
Does anybody have any ideas about this?
Thanks a bunch!
Steve The Plant
|
|
|
|
|
Check the KB article Q192853: "BUG: Wincore.cpp Line 879 Assert When Using MFC Classes"
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hi all.
Has anyone else ever had a problem with the VC++ resource editor giving controls, strings etc. constants with negative values in resource.h? eg, I often get an assertion because the res ed has put something in like this:
#define IDC_MYCTRL -63231
is it a known issue? is there a fix?
pls excuse me if this is an old one
NB
|
|
|
|
|
This has happened to me, only once. I have no idea why - I just made the value positive and that was it. I suspect it may have something to do with the 'next' values stored at the bottom, I don't know what the maximum value there is, but if it's not stored as an unsigned value, then it will roll over to a big negative number.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Has anyone ever done this? I'd like to basically create a software that runs on my server and clients can connect to it and conduct meetings with other clients much like webex.com.
Eventually I'd write it into an activex control, but I really don't know where to start. I've written a lot of code in my days, but I can't comprehend how to start with remote desktop sharing?
Any help would be appreciated.
Thanks,
Kevin
|
|
|
|
|
I am attempting to use a VB DLL in a C++ project (actually 2), I am rather successfull at handling BSTR but not BSTR* - specifically I need to convert any "normal" string (char*, string, CString) into a BSTR* because the DLL's functions only take BSTR*
BryanV
bryanv@factualdata.com
|
|
|
|
|
Why not convert to a BSTR and pass in &vBstr ?
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
BSTR* stoBSTRp(string input)
{
BSTR bob;
bob = stoBSTR(input); //lets assume I have have stoBSTR vorking fine (takes in a string and returns a BSTR)
return &bob;
}
so you are saying something like this?
|
|
|
|
|
No, of course not. But
BSTR* stoBSTRp(string input)
{
BSTR * bob = new BSTR;
bob = stoBSTR(input); //lets assume I have have stoBSTR vorking fine (takes in a string and returns a BSTR)
return bob;
}
would work fine. I didn't expect this to be the question though, I'd assume he doesn't have to *return* a BSTR*, but rather pass one in to something. The point of my suggestion was more to see if I was missing something as anything.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Hi
How do you set the number of tabs on a tab control and how do you insert objects into each tab? Is this done with an event handler when the form loads, and if so what event? I am a bit of a newby to VC++ being so used to the way VB hands it out on a plate.
Live each day like yer first...
...write songs like there yer last
Cheers
Craig
|
|
|
|
|
Create a variable from the tab control, and in OnInitDialog use the methods of the tab control to add items, etc.
Here's an example from my program:
m_Tabs.InsertItem(0,"Combined");
for (int i = pDoc->m_LayerManager.GetLayerCount(); i>0; i--)
{
CString s;
s.Format("Layer %d", i);
if (pDoc->m_LayerManager.GetLayer(i)->layerName .GetLength()<2)
m_Tabs.InsertItem(1, s);
else
m_Tabs.InsertItem(1, pDoc->m_LayerManager.GetLayer(i)->layerName );
}
m_Tabs.SetItemSize(CSize(60,20));
The important bit is that Insert Item adds an item, the count is how many you have added this way, and SetItemSize sets the size of a tab. If you don't have the MSDN CD's, go to msdn.microsoft.com to get full documentation on the CTabCtrl methods.
Hope that helps...
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Where does pDoc come from and what does it point to? I do not have pDoc declared so i get an error when i compile.
Live each day like yer first...
...write songs like there yer last
Cheers
Craig
|
|
|
|
|
I'm sorry, I should have trimmed irrelevant code. The point is the calls to InsertItem, the rest of it will not compile ( it's a pointer to the document ).
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Have i dont this right? It crashes when i run it
BOOL CRemoteControlDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
CTabCtrl m_Tabs;
m_Tabs.InsertItem(0,"Combined");
return TRUE; // return TRUE unless you set the focus to a control
}
Live each day like yer first...
...write songs like there yer last
Cheers
Craig
|
|
|
|
|
First off, use the dialog editor to add the tab control to the dialog. Then use the class wizard to add a member variable to your dialog class.
Click on the Member Variables tab on the Class Wizard Dialog, find the control named IDC_TAB1, and press the Add Variable button. Make sure the variable is a Control of type CTabCtrl, and name it whatever you like (m_Tabs).
Then in your OnInitDialog() function, call the InsertItem() function with the member variable.
m_Tabs.InsertItem(0,"Combined");
The problem was that when you created the CTabCtrl in your program, it was not really a control at all.
CTabCtrl m_Tab; //Just creates the class, not the control!!
|
|
|
|
|
Imagine there is an edit control on a dialog. The variable for that edit control is m_eEdit.
Have a look at this:
COleDateTime oledt;
oledt = COleDateTime::GetCurrentTime();
oledt.Format("%X");
m_eEdit.SetWindowText(oledt);
When compiling and so... the are no errors... BUT! the result of the time that is to be seen in
the edit control looks like this: AD0G135
Why!
/*
BETA
*/
|
|
|
|
|
Hi,
I don't know how did your code compile!!! , you must have type casted it .
Format will return the formated string.
Any way
Try this
m_eEdit.SetWindowText(oledt.Format ("%X"));
Cheers
Alfadhly
/*
It is Illogical to define an inventor by his invention
*/
|
|
|
|
|
How do I get a Bitmap and a String on the same Menu Item??
The menu is created at runtime using .CreateMenu() and CreatePopupMenu().
I'm using .AppendMenu(...) to add the items but I can only add MF_STRING or MF_BITMAP.
I tried to .AppendMenu(..) then .ModifyMenu(..) but still no luck.
Once the Menu is created it is ran through a function which sets the whole Menu to Ownerdraw but the Bitmap ain't coming up.
please throw some light into the sutuation if you can.
regards,
pgudge
|
|
|
|
|
I want to create a ActiveX Control in VC++, in which i want to use custom class(Complex) that is defined in a dll file(Complex.dll), that dll file is created in Visual basic .
I want to use that class & their properties & methods in the my activeX Control in VC++. Please help me on above as earliest. please let me know what is the best suitable way to do this.
My aim is to create a activex control which have a property of Complex type Complex class must have real & imagenary values & offcource all Complex type features.
please let me know how this is possible.
Satyen
|
|
|
|
|
I want to use doubleclick on my multiple selection listbox..
None of the CListBox class members seem to provide a way of telling which entry was doubleclicked, only which ones are selected.
Any hints?
Thanks,
Gustav
|
|
|
|