|
Christian,
Try your method without success. But later I put class A and class B in the same file. The problem solved.
// Header file:
class A;
class B;
class B
{
A m_variable;
}
class A
{
B m_variable;
}
In the above header file, the sequence is very important. class B must be defined before the class A.
Is it possible to separate class A and class B into different file?
Best Regards,
Wayne King
|
|
|
|
|
It depends on how you're accessing class B. If it's by pointer or reference, then you only need to provide A with a forward declaration of B:
class B;
class A
{
private:
B* m_pB;
B& m_b;
};
This is because you're only declaring B as a pointer or reference, which are always 4 bytes (in Win32), so the compiler doesn't need anymore information to determine the size of A.
If you were going to declare an instance of B directly inside of A, then the compiler would need to know how big B is so that it could add it to A's size. For that, the compiler needs B's definition. So you need to put B's definition on top of A, which is typically done by including the header file where it's defined (B.h):
#include "B.h"
class A
{
private:
B m_b;
};
I hope to have shed some light on this stuff.
Regards,
Alvaro
Insanity: doing the same thing over and over again and expecting different results. - Albert Einstein
|
|
|
|
|
Alvaro,
Thanks very much. Your answer is very informative. It not only solve my annoying problem, it also give me an answer why this thing happen and how to avoid them. Thanks again.
Best Regards,
Wayne King
|
|
|
|
|
I have a dialog with a list control in it and a handler for the LVN_COLUMNCLICK notification. In the handler I am displaying a modal dialog, the problem is that this dialog does not initially have the focus, I have to click on it once to activate it. But it gets worse..... if I click outside the dialog on the list control header in the background window then I get another dialog popup! (the header click handler is being called again)
What is going on here? I did a test and moved the dialog display into the NM_CLICK notification of the list control and all works ok, seems to be some problem with popping up a dialog in the header click notification.
|
|
|
|
|
The header will capture the mouse when it is clicked, so that drag&drop can be detected (if the header is dragged, LVN_COLUMNCLICK will not be sent). To avoid the problem you're seeing, you can call ::SetCapture(NULL); prior to displaying the dialog.
--------
From now on we can call C# and MC++ "The square wheel languages" -- Jack Handy, The Lounge
|
|
|
|
|
|
Hi,
Is there a relatively straightforward way of determining the video card? I am creating a small settings panel for a game, and want the video card to appear in a listbox. I figure I probably need to use DirectX to find out the video card driver. Any pointers as to how to do this would be much appreciated.
Many thanks,
Keith
|
|
|
|
|
If you simply want a list of the display devices currently installed on the system, then you can use EnumDisplayDevices .
If you would like to get more complicated and list all of the display modes that each of the devices that each display adapter supports, then there is a really nice example program that does this in the DirectX 8.0 SDK.
Good Luck!
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Many thanks for your reply, EnumDisplayDevices sounds exactly what I need. Unfortunately, I have tried to use it but I get a compile error:
EnumDisplayDevices: Undeclared Identifier
I have inluded user32.lib and the windows.h header, and the autotext in VC++ seems to recognise the function, but it just won't compile.
If anyone has any ideas of why this might be, I would be very grateful.
Again, many thanks,
Keith
|
|
|
|
|
It says in MSDN that the function is only available in Win98, Windows 2000 or above. That means that you will have to define the version that you would like to compile for to include the version 5 function headers. make this definition at the top of your stdafx.h file:
#define WINVER 0x0500
but once again, this will make you program so that it will not work on windows 95. Hopefully this is acceptable.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
BTW, it will also not work on Windows NT 4.0, as this is a version WIN OS as well.
Good Luck.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I have a function: CString GetNextString( ifstream &InFile )
This works fine, but it seems everytime I get an error(such as a missing semicolon) I get another error that says it doesn't understand what an ifstream is. So I have to deleted the GetNextString function, comment out all calls to the GetNextString function, build it without any errors, then recreate the GetNextString function. It's a big hassel. Can it be fixed?
-Raffi
|
|
|
|
|
This is most weird, I'd bet the problem lies elsewhere. Things to check:- Are you including
using namespace std; ? If not, you should replace ifstream with std::ifstream throughout.
- What header are you using (should be
<fstream> ) and where are you including it?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Here's the declarations and functions i use, when i get to EnumObjects, it comes with an "Unhandled exeption" error and stops at that line.
IShellFolder *pSf = NULL;
LPENUMIDLIST pEidl;
pSf->EnumObjects(ghWnd, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &pEidl);
ghWnd is the handle to my window and it is valid, i have tested that.
Anyone know whats wrong?
Thankyou
|
|
|
|
|
I guess this is not the exact code you're using, since pSf is null.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Sorry, here's the definition of pSf;
LPSHELLFOLDER pSf;
|
|
|
|
|
I mean, maybe it is the way you're obtaining this pSf what it's wrong. Have you checked it is not null before calling EnumObjects on it?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
It looks real bad. Could you post the code you're using to retrieve pSf ?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Heh, woops called the wrong function to set the pSf, i have to call
SHGetDesktopFolder (&pSf); thanks for the help :=)
|
|
|
|
|
You are welcome.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
u are sooooo diplomatic joaquin
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" sonork: 100.18128 8028finder.com
|
|
|
|
|
I have had a problem programming in Windows for some time which I have never solved and would appreciate anybody's help !! I shall describe the current incarnation !!
I am writing an application (using MFC and VC++) using the Document/View architecture. Within a Document/View process, I need to produce a secondary window (to the view) to display certain other information. I invoke this via a menu item associated with the View, and have tried to display this secondary window by using the following statements within the menu routine:
void CIRCView::OnMenuItem()
{
// TODO: Add your command handler code here
CIRCDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(!m_bButtonSelected)
AfxMessageBox("Please select a key to adjust");
else
{
CRect rect(20,20,100,100);
CWnd Wnd;
int rc;
rc = Wnd.Create(NULL,NULL,
WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW | WS_VSCROLL | WS_HSCROLL,
rect,(CWnd*)GetParent(),NULL);
}
}
I get a good (non-zero) return code from Create(), but no new window (apart from the View) is visable (if I add a Wnd.ShowWindow(), it returns that the window WAS already visable !).
Where am I going wrong ??? (Any help appreciated on this trivial, but important, question will be greatly appreciated !!)
Doug
|
|
|
|
|
Your CWnd variable is local, so it gets destroyed as soon as you exit OnMenuItem .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquin, Many thanks for your response - I'm now kicking myself because it's so obvious !! (the simple ones always are !!!) Thanks again
Doug
|
|
|
|