|
Please reread my response.
It doesn't matter if you use MFC or not, or if you use header files or not.
The compiler is going to parse the code from the top-down. To resolve the
circular reference problem, you have to have similar code to the code I posted
and it needs to be in that order.
Again, this will not work:
class X
{
Y Y1 <-- the compiler does NOT know what a Y object is here!!!
}
class Y
{
X X1
}
You could try this, but it won't work either:
class Y;
class X
{
Y Y1 <-- the compiler does NOT know what SIZE a Y object is here!!!
}
class Y
{
X X1
}
So, you must use a pointer. The compiler knows the size of a pointer:
class Y;
class X
{
Y *pY1
}
class Y
{
X X1
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Oh no,when you use MFC (Dialoge box) ,you create two class (class X and class Y)which different place,you can't spacify which class will compile before
|
|
|
|
|
Oh yes, you have complete control over the order of the code.
You always have to put your code in the order you want it compiled.
That doesn't change for "#include"d header files - they get compiled
right where you place the #include.
You're really missing my point here. My point is that you can't include
a type in a class that the compiler doesn't know anything about. You can,
however, use an empty class declaration (e.g. "class SomeClass;") to let the
compiler know that a class of that name exists but its size is unknown.
You are NOT going to be able to have a "circular reference" like you're showing
without using a pointer to an object of the unknown type in at least one of the
classes in question.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Come on, Mark, quite beating around the bush and tell us exactly what is going on. Do you have to make it so blasted difficult?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Heh. I'm trying! My head is clogged and I'm hopped up on cold medicine.
That's my story and I'm sticking to it
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
sorry Mark,My foreign language is too bad,so I use many word which not true,I am sorry,
|
|
|
|
|
What was first, the egg or the chicken?
That's the problem that Mark is trying to explain.
Hope is the negation of reality - Raistlin Majere
|
|
|
|
|
dear Mark,I sorry about this question,My English language is very bad,so I don't good at using words,I thanks about your your answers,and I hope you can skip for me
good look to you
|
|
|
|
|
No problem
Did you fix your issue?
I don't know how else to explain it - you have to include your .h files and/or
add the appropriate lines of code in the correct order for the compiler.
The sample code in my replies looks really simple, but it should have everything you
need to resolve your circular reference. MFC is just C++ - all the same rules apply.
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Oh yes,I finished my trouble,that is great,you say exactly,I read many times and translate(because I am VietNamese) and understand,Thanks you very much,
good look to you
|
|
|
|
|
hi
I am working on network assignment in C/C++
n I am having runtime error
Invalid argument to sendto()
Can any one plz tell me wat might be the possible reasons
Regards
Majid Mahmood
|
|
|
|
|
If sendto() is returning SOCKET_ERROR, then you should call WSAGetLastError() to
get the actual error code.
If you do this, what is the error code?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
i want to print a picture. If I print it to a file on my hard disk, every thing's fine. But I can't print with my printer.
This is because my memory dc (2172 x 3072 px) is smaller than my print dc (6675 x 4800 px). As msdn says, we can't use 'StretchBlt()' when the source and target dc sizes differs much.
So I wanted to create very large memory dc (As large as my print dc):
CBitmap bBitmap;
CPaintDC pPaintDC(this);
CDC dMemDC;
CSize sSize;
if ((dMemDC.CreateCompatibleDC(&pPaintDC)) && (bBitmap.CreateCompatibleBitmap(&pPaintDC, sSize.cx, sSize.cy)))
{
dMemDC.SelectObject(&bBitmap);
}
But creating a large dc fails, too. The error ocurs when I call 'CreateCompatibleBitmap()'.
So how to solve this problem ? I have to get printed my memory dc to the print dc.
Thank you
Greetings
Marco
|
|
|
|
|
it's probably a memory issue - not enough memory to create a bitmap of that size on the printer. so you might have to do the drawing in multiple bands (or tiles).
|
|
|
|
|
Why not just output directly to the printer DC without the memory bitmap in between?
|
|
|
|
|
Do you want to have a preview on your project or no?
|
|
|
|
|
Thank you for this fast answers.
@Hamid:
No, i dont have a preview.
I can't print directly to the print dc, because i don't only draw a single bitmap. The memory dc is used to draw a background and some texts. Printing this directly to the printer dc (sizes differes for each printer) needs a special calculation I don't think this could be done as good as working with a memory dc.
Drawing in tiles sounds good, but I would get the same error, or not? I also have to use 'StretchBlt()'.
Thanks
Greetings
Marco
|
|
|
|
|
I've tested printing in tiles. It doesn't work.
I think this problem realy needs to get solved by using two dc's with similar sizes.
|
|
|
|
|
You really need to lookup mapping modes in MSDN.
Lookup MM_ANISOTROPIC and MM_ISOTROPIC. Pay particular attention to CDC::SetWindowExt() and CDC::SetViewportExt() and how you setup a single DC to do all the dirty work for you.
If you are printing a bitmap, drawing primitives, text, or anything else, the mapping mode functions allow you to draw to a single DC and have the output translated to the devices coordinate system.
A world coordinate system of 2000x2000 needs to be drawn on a printer page 8 1/2 inches by 11 inches at a DPI of 1200? A screen with resolution of 1024x768? 1280x800? No problem.
You need to start thinking in terms of mapping modes and extents when you translate between different metrics or coordinate systems.
Hope that helps.
|
|
|
|
|
If I have my memory and the printer dc, do i have to setup only the printer dc (using map modes, SetWindowExt and SetViewportExt)?
Or do I have to setup my memory dc as well?
I tried thinking in terms of mapping modes and extents, but i didn't work so far (But i will try)
bob16972 wrote: A world coordinate system of 2000x2000 needs to be drawn on a printer page 8 1/2 inches by 11 inches at a DPI of 1200? A screen with resolution of 1024x768? 1280x800? No problem.
Sorry, i didn't unterstand that.
|
|
|
|
|
I found an interesting article: link
And here my code so far:
dPrintDC->SetMapMode(MM_ANISOTROPIC);<br />
<br />
dPrintDC->SetWindowOrg(0, 0);
dPrintDC->SetWindowExt(sBackgr.cx, sBackgr.cy);<br />
<br />
dPrintDC->SetViewportOrg(0, 0);
dPrintDC->SetViewportExt(rArea.Width(), rArea.Height());
'dPrintDC' is my print dc object
'sBackgr' is the size of my memory dc.
'rArea' is the rectangle of my print dc.
But 'StretchBlt()' returns the same error !?
|
|
|
|
|
Meisterzunge wrote: As msdn says, we can't use 'StretchBlt()' when the source and target dc sizes differs much.
This doesn't apply when StretchBlting from a screen-compatible memdc to a printer dc. Try StretchBlt and I think you'll get the results you're looking for.
When creating a screen-compatible memdc, you may want to give it the same ratio of width to height as a printer dc as follows:
HDC hdc = GetDC(0);
prn_dat.w = GetDeviceCaps(prn_hdc,HORZRES);
prn_dat.h = GetDeviceCaps(prn_hdc,VERTRES);
prn_dat.dw = GetDeviceCaps(hdc,LOGPIXELSX);
prn_dat.dw /= GetDeviceCaps(prn_hdc,LOGPIXELSX);
prn_dat.dh = GetDeviceCaps(hdc,LOGPIXELSY);
prn_dat.dh /= GetDeviceCaps(prn_hdc,LOGPIXELSY);
w = mulr(prn_dat.w,prn_dat.dw);
h = mulr(prn_dat.h,prn_dat.dh);
(The values in prn_dat are floating point and mulr is just my own routine for multiplication with rounding which may or may not be necessary. When you create a memdc use w,h as dimensions for the bitmap.)
|
|
|
|
|
Visual C++ 2003 MFC MDI app.
I have a docking control bar that has a tree view in it.
Is there a standard keyboard sequence to switch between the MDI views and the control bars and to switch between the control bars in a frame.
I know <ctrl> + <F6> and <ctrl> + <shift> + <F6> switch between the child panes but I can't figure out how to switch to the control bar that has the tree view in it using the keyboard.
Any ideas?
|
|
|
|
|
Hi.
In the project that I am working, I need to develop a listener that checks a folder and files.
Well, on CLIENT this listener will have detect ANY internal change in ANY file in the folder and instantly will synchronizer with SERVER, like a ShadowCopy, and different of a snapshot, for keep integrity between CLIENT-SERVER, ok?
Can anyone give me a hand? Libraries, and similar components.
I'm working in c++ builder, but visual studio components also help.
Regards,
|
|
|
|
|
Caetano.n.a wrote: In the project that I am working, I need to develop a listener that checks a folder and files.
While not a direct answer to your question, here is a brief example of FindFirstChangeNotification() . Other examples are just a click away.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|