|
|
You will need to retain the .h includes as well as the
declaration of the class.
Or, you can see Rage's post below. Both methods should work.
|
|
|
|
|
when you say "...as well as the
declaration of the class.", you're saying all the code
(functions and variables)?
thanks for the patience John, I'll try the two methods.
Ricky
|
|
|
|
|
No no. Just include the header file for class A in the .cpp file of
class B. Then in Class B's header file place "Class A;" as indicated
previously.
ie:
in B's .cpp fild, #include<classA.h>
in B's .h file, class A;
Do the same for class A.
In A's .cpp file, #include<classB.h>
in A's .h file, class B;
This should work.
|
|
|
|
|
Yeah!
This works great!
Thanks all of you for your help!
Thanks John!
cheers!;)
Ricky
|
|
|
|
|
Ricky_TheBard wrote:
I put:
class A;
class B : public CDialog
{
...
A objA;//just for test
}
If you forward declare class A in the header file for class B, then you don't need the header for class A in the header for class B as long as you use a pointer to class A. In your example you are using an object.
class A;
class B : public CDialog
{
...
A* ptrA;//just for test
}
|
|
|
|
|
Declare your global variables in one of the .h, and declare them also in the other one where you need them, but put extern before all declaration.
~RaGE();
|
|
|
|
|
Ok, Rage, I'll try your suggestion after John's
thanks!
Ricky
|
|
|
|
|
Ricky_TheBard wrote:
I need global variables.
If you need using global variables, then you may consider redesinging your application... Global variables are not your friend in an OO environment.
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
I've used IPicture to provide a resizable imagepanel in my application. It only took me 10 minutes to implement it. It's very straightforward.
When I resize my app, the picture resizes along.
But I don't want the picture to be just resized. It's fast, but there's a great loss off quality.
So, is there some sort of way to "resample" an IPicture? Using various resample-filters?
There's no function to do that inside IPicture, I think. But during a search on google, an IPicture2 turned up, with a Resample(x,y) function in it. Is there someone who knows more about it?
tnx
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
i have a CFrameWnd inside of a CSplitterWnd pane. when it first appears, it has size of, say 500x300. then assume i resize the frame manually, to 600x500. simple enough so far.
the OnPaint handler of the CFrameWnd looks like this:
void cDataExpressInternalFrameWnd::OnPaint()
{
CPaintDC dc(this);
CRect client_rect;
GetClientRect(&client_rect);
afxDump << "fv " << client_rect << "\n";
}
all i do is trace out the client rect of the frame wnd.
but... if i invalidate a part of the frame, by resizing or by dragging another window on top of it, the CFrameWnd's client area redraws like this:
fv (0, 0, 500, 300)
fv (0, 0, 600, 500)
fv (0, 0, 500, 300)
fv (0, 0, 600, 500)
fv (0, 0, 500, 300)
fv (0, 0, 600, 500)
...
in other words, each time the CFrameWnd is invalidated, it draws twice: once at the initial size (500x300, in this example) and then once at the new size (600x500).
i can't figure out why the client rect keeps reverting back to the original size. i'm not resizing the frame wnd back to that size anywhere.
has anyone ever seen this?
-c
To vote with no response is to follow the way of the coward.
|
|
|
|
|
That's interesting. I've never noticed this behaviour before.
I am wondering if it needs the initial values to retain the aspect
ratio??
Let me know if you figure it out.
|
|
|
|
|
I have the following bit of code:
vector<double>::iterator itr;
for (itr = dmStack.begin(); itr != dmStack.end(); ++itr)
{
TRACE("Node Number: %d ", i);
TRACE("Node Energy: %d \n", *itr);
i++;
}
Node energy values are usually in the range of 1x10^(-16). If I send
the value of i and *itr to stdout (console) they are displayed properly,
however, if I send them to the Debug window of the vc++ IDE (using TRACE()), I get:
Node Number: 0 Node Energy: -1684540248
Node Number: 1 Node Energy: -1684540248
Node Number: 2 Node Energy: 0
Node Number: 3 Node Energy: 0
Node Number: 4 Node Energy: 391017576
(Energies should never be negative or excessively large.)
I suspect that I am not formatting the output properly. I could have
sworn it was %d that I wanted - is that not correct?
|
|
|
|
|
If I remember correctly, I've read somewhere here on CP that it is not possible to output STL things with the TRACE command using an iterator.
~RaGE();
|
|
|
|
|
Oh no, really?
Do you know where that post/article would be by any chance?
|
|
|
|
|
I found that this works:
vector<double>::iterator itr;
for (itr = dmStack.begin(); itr != dmStack.end(); ++itr)
{
TRACE("Node Number: %d ", i);
TRACE("Node Energy: %e\n", *itr);
i++;
}
|
|
|
|
|
OK. Nevermind.
~RaGE();
|
|
|
|
|
Hi John,
*itr is a double.
The format string that you are using in "Node Energy: %d \n", which formats an int.
You need to use "Node Entry: %lf \n".
Best regards,
John
|
|
|
|
|
Thanks for the suggestion.
I tried that, but I kept getting 0.00000, so I looked up
c++ format specifiers.
I discovered that
TRACE("Node Energy: %e\n", *itr);
works perfectly.
|
|
|
|
|
Hi,
I have a dialog that have a bitmap as background. When I put control on the dialog, I can see the surrounding white rectangle around the controls. Is there a way to see my background around the controls and not the white rectangle?
for example, suppose that I have a CStatic with text in it, is there a way to to see the bitmap behind the text?
thanks
Everything's beautiful if you look at it long enough...
|
|
|
|
|
Does enabling the Transparent property (when right-clicking on the control in the ressource editor) change something ?
~RaGE();
|
|
|
|
|
No, enabling the transparent property don't change anything. I have been able to make it work throught OnPaint() redefinition in a CStatic control, but I cannot use to make it work for other controls such as CButton (radio button)
for CStatic, in the OnPaint of the control you can use:
dc.setBkMode(TRANSPARENT)
dc.DrawText(...)
Everything's beautiful if you look at it long enough...
|
|
|
|
|
Try adding a handler for OnEraseBkgnd and either doing nothing or erasing the background with a hollow brush. ex:
BOOL MyDialog::OnEraseBkgnd( CDC* pDC )
{
return TRUE;
}
|
|
|
|
|
Well,
I doesn't seem to work, I also tried to use:
HBRUSH RightDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = ShapedDlg::OnCtlColor(pDC, pWnd, nCtlColor);
if ( pWnd->GetDlgCtrlID() == IDC_RADIO1)
{
// m_bkbrush is a CBrush member variable
m_bkbrush.CreateStockObject(HOLLOW_BRUSH);
pDC->SetBkMode ( TRANSPARENT );
return m_bkbrush;
}
return hbr;
}
If I use BLACK_BRUSH, I will see a black background if I use GREY_BRUSH I will see grey background, but HOLLOW_BRUSH give me a strange blue background.
Everything's beautiful if you look at it long enough...
|
|
|
|
|
Hi
Any one have a link to a free electronic book cover Drivers for Win 2000 & Hook Drivers
Please
Thanks Very much
|
|
|
|