|
In the .h files of the mb file, add
class ma;
at the begining of the file.
Then in the .cpp file, include the header of this file.
|
|
|
|
|
I alread did that !!
class B;
class A
{
call something on B --- Wont Work
}
class B
{
Call something on A --- Works
}
|
|
|
|
|
You mean everything is in one single file ?? All the functions and everything are in the header file ?
It is better to separate the implementations of the class functions in the .cpp file. If you put that in the header file, when you call something from B in the class A, the compiler only knows that the class exists, but it doesn't know what are the members of the class B. So, put all the definitions of the functions (from classA and class B) in a separate .cpp file. And this is much cleaner that having everything in the same file.
|
|
|
|
|
First of all Thank you very mich Cedric for the quick response....
I already had them in seperate .h and .cpp files but the error in Visual studio was the same....
It seems that Visual Studio is having a problem when I call mb from ma ( *p == p->Foo() ) than the Compile is telling me that I don't have a valid type ???
Thanks
Marcus
|
|
|
|
|
Ok, so if you have forward declaration and all the function defined in a separate .cpp file, this should work (make sure that the header file of class B is included in the .cpp file of class A and the same for class B).
Now, I think this is not due to that fact but probably a syntax error or something like that. It would be really usefull if you post the exact error message (with the error line and everything) and if you could post also the line which gave this error.
Fehma wrote:
*p == p->Foo()
This looks strange to me...
|
|
|
|
|
Thanks I will try it......
With
<*p == p->Foo() > I meant
p->Foo() // Pointer to Object B calls a Function "Foo" on the Object....
|
|
|
|
|
Fehma wrote:
p->Foo() // Pointer to Object B calls a Function "Foo" on the Object....
Yes, that part I understood but why do you compare the result with the object itself ??
*p
Maybe the problem is there: the compiler cannot convert from the return type (probably an int) to the class B...
|
|
|
|
|
Hey,
sorry that ( *p == ) didn't mean anything !!! he he he
I just had forget to delete it...... Typed to much I guess....
Thousand thanx......
I will try it now with the CPP Files and the correct use of include....
A.ccp will include B.h
and
B.cpp will include A.h
right ??
|
|
|
|
|
works no !!!! THANK YOU VERY MUCH
|
|
|
|
|
Hi,
I have a question about static controls and how their backgrounds are painted. If I place a static control on a normal dialog, the background of that dialog is a uniform system grey, and the present static seem to paint their own backgrounds to match that. However, in XP property pages, the background is not uniform, it's a kinda whitish gradient fill. How do the static controls erase their backgrounds here? Do they set themselves to be transparent somehow, and let the parent page paint the whole background over which they just draw the text, but not any background, or do they call some function in the parent page asking it to paint a specific portion of background covered by the static control? I'm asking because I need to replicate this effect, in a custom window of mine. Any clues?
Joel Holdsworth
-- modified at 4:19 Friday 2nd September, 2005
|
|
|
|
|
It`s very simple a Static in requesting a brush(OnCtlColor) from it`s parent dialog, to paint it`s background, you have to give a pattern brush with the portion you need... here it`s an example
if( nCtlColor == CTLCOLOR_STATIC )
{
CRect rc;
pWnd->GetWindowRect(&rc);
ScreenToClient(&rc);
CDC *pBDC = new CDC;
CBitmap *pBmp = new CBitmap;
pBDC->CreateCompatibleDC(pDC);
pBmp->CreateCompatibleBitmap(pDC, rc.Width(), rc.Height());
CBitmap *pOLD = (CBitmap*)pBDC->SelectObject(pBmp);
m_pBackgroundBmp->DrawPart( pBDC->GetSafeHdc(),0,0, rc.left, rc.top, rc.Width(), rc.Height());
pBDC->SelectObject( pOLD );
if(m_hbr) DeleteObject(m_hbr);
m_hbr = ::CreatePatternBrush((HBITMAP)pBmp->m_hObject);
pBDC->DeleteDC();
pBmp->DeleteObject();
delete (pBmp);
pBmp = NULL;
delete (pBDC);
pBDC = NULL;
return m_hbr;
}
int h file you have HBRUSH m_hbr;
NG
-- modified at 6:04 Friday 2nd September, 2005
|
|
|
|
|
Thanks mate. Worked like a charm.
Joel Holdsworth
|
|
|
|
|
Hi guys i sometime get confuse in this?
What is the difference between Instance and Context.
And how two different instances for the same application work.
What are the responsibilities of the OS two maintain the two different instance.
What is the responsibility of the Application developer.
Thanks in advance.
Anil Kumar
|
|
|
|
|
an instance is a representation in memory of a particuliar type (class, struct, union, native type).
when you write int i1 = 4, i2 = 5; , i1 and i2 are 2 instances of an int .
the context is all that can interract with the program and affect the behavior of it (variables values, thread states...)
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi all
I am using VB 6.0 and trying to use SetForeGroundWindow() API in Windows XP . But the API's behavior seems to be different from Non XP OS , because the minimized Application window gets the focus btu waits for a mouse click to come to fore ground . Is there anyway to make the Application window to come to forground straight away ?
regards
Dharani
redindian
|
|
|
|
|
You can use ShowWindow(SW_SHOWNORMAL);
this is this.
|
|
|
|
|
dharani wrote:
Is there anyway to make the Application window to come to forground straight away ?
What about [SetWindowPos] api
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Are you asking for VB or VC++ code ?
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
Try looking at AllowSetForegroundWindow [^]. Recent versions of Windows prevent applications from taking over the foreground window via SetForegroundWindow , since it takes control of the focus away from the user (which is not a good idea, from the user's perspective).
Software Zen: delete this;
|
|
|
|
|
what is difference between a handle and a pointer?
you can access all of the members with both of em!so what is the difference?
|
|
|
|
|
technically, none ; but handles are generally called like this because the allow to handle a whole object, such as window controls...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
In general terms, a handle is an opaque value used to identify an object. In and of itself, it doesn't do anything, and can't be used to access the object directly. You pass it to one or more functions that perform operations on the object.
A pointer is essentially an address of a piece of memory. In C and C++, a pointer is associated with a type, which lets you treat the pointer as an indirect reference to an object of that type.
Handles may be implemented using pointers; in fact, many handle types in Windows probably are pointers, down underneath. There are also a large number of handles that are not pointers, however. Using a handle as a pointer Is Not A Good Thing because you are relying on an implementation detail that may or may not work in future versions.
Software Zen: delete this;
|
|
|
|
|
I have been working on a dialog based app in Visual C++ 6.0.
I set up an accelerator table and assigned shortcuts to some of
my menu items in my menus. Then I discovered the problem.
If I use any F key as a short cut, or any key in conjunction with
the Shift key, the program will carry out the appropriate action,
but then it crashes, whereas if I invoke the menu command manually
from the menu, there is no problem.
I tried looking around the internet for some answers but didnt
find anything useful. This makes no sense whatsoever! Does anyone
have a clue what is going on?
|
|
|
|
|
It seems that when a window closes after a function key or shift
key combination is used as an accelerator key, the
program invariably will crash. The exception is being thrown
from wincore.cpp, line 875 it tells me.
Looking in the file, this line turns out to be part of the
CWnd::AssertValid() function. Line 875 is:
// should be a normal window
ASSERT(::IsWindow(m_hWnd));
This is not helpful though, and if there were a
problem with my windows, then it should happen each time I
open one of them, regardless of whether I invoke the menu command
via the accelerator key or via the menu itself.
I don't know what to do other than just change my accelerator
keys so that none of them use the function keys or the shift key.
Is there any good reason for this, or is it just something else dumb
to blame on microsoft?
-- modified at 0:29 Saturday 3rd September, 2005
|
|
|
|
|
Hi All
I want to retrieve the information related to internet like
1)Visited sites with time & number of hits in certain duration
2)Chatting time
3)Mails sent etc.
Please reply.
Thanks & Regards.
|
|
|
|