|
I was trying to include it in my created .h file.
Why must I include this in a cpp file and declare it in a .h file? It is working now but this seems nonstandard.
Am I missing something?
Thanks
Jeff Patterson
Programmers speak in Code.
http://www.anti-dmca.org[^]
|
|
|
|
|
Jeff Patterson wrote:
It is working now but this seems nonstandard.
Yes, it is nonstandard, but it's a very common feature of compilers. For easier use of old C code, they only enable C++ extensions in files with specific extensions, like cpp, cc, cxx, and so on.
You can always force C++ compilation, even without these extensions.
My latest article:
SQL Server DO's and DONT's[^]
|
|
|
|
|
Thanks.
Since you have grabbed my curiosity now
How do you force C++ compilation?
Jeff Patterson
Programmers speak in Code.
http://www.anti-dmca.org[^]
|
|
|
|
|
You can use one of the Tc, /Tp, /TC, /TP to specify source file type or, in VC.NET (I don't recall where it is in VC 6.0), open the project's Property Pages, "C/C++", "Advanced", "Compile As"
My latest article:
SQL Server DO's and DONT's[^]
|
|
|
|
|
|
Jeff Patterson wrote:
using namespace std;
There really is no point in having namespaces if you're going to pull them into the global namespace holus bolus. You should instead have using statements like this
using std::vector;
Yes, all the books do it wrong, I don't know why.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
all the books do it wrong, I don't know why.
because it's not wrong.
if "using namespace x" was wrong, his holiness Bjarne wouldn't have included it.
-c
There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'.
--Holgate, from Plastic
|
|
|
|
|
Chris Losinger wrote:
if "using namespace x" was wrong, his holiness Bjarne wouldn't have included it.
I'm afraid it's 'his holiness' that you're arguing with. using an entire namespace is included for a number of reasons, but we are strongly discouraged from using it, unless it is within a very limited scope, such as including all of one namespace within another.
Do you own 'The C++ Programming Language' ? My copy is not here, but if you look up the chapter on namespaces, it's all in there.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
but we are strongly discouraged from using it
don't care. it's part of the language. if it's so bad, he should've decreed a compiler warning.
yes, i understand your point about "using namespace std" defeats the purpose. but, i disagree that people need to be hammered with dogma when they're trying to learn the basics.
-c
There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'.
--Holgate, from Plastic
|
|
|
|
|
Chris Losinger wrote:
if it's so bad, he should've decreed a compiler warning.
See, this comes down to C++ not being a language for idiots. Once you get flooded with warnings, will you really read them all, or none of them ?
Chris Losinger wrote:
i disagree that people need to be hammered with dogma when they're trying to learn the basics.
I disgaree totally. People are creatures of habit, and half the reason so much bad code is written is because people form bad habits early on.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
I disgaree totally
i'm shocked.
-c
There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'.
--Holgate, from Plastic
|
|
|
|
|
Christian Graus wrote:
Once you get flooded with warnings, will you really read them all, or none of them ?
I've learned from many books that you're going to treat warnings like errors.
But sometimes you just have to ignore some warnings, like:
while(1)
{
}
This will cause a warning (warning level 4 only I think) that says it's a constant expression, even if you do a break inside the brackets!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Rickard Andersson wrote:
while(1){ // do something}
I'd regard this as a bad idea. Why not while (whatever condition you end up breaking on), or a do...while if you want to make sure it runs once ?
But you're right, it's generally good to treat warnings as errors, which is why using namespace... should not be a warning, there are places where it is useful. The whole basis of C++ is to provide the constructs that you may one day need, and not to confine you to what the impliments think is a good idea. That's one reason it is so powerful.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
I'd regard this as a bad idea. Why not while (whatever condition you end up breaking on), or a do...while if you want to make sure it runs once ?
If I say socket programming, does it wake any codelines in your brain?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
I agree with you. I've actually gone as far as to do the "unthinkable!": put using namespace std; inside the precompiled header. Oh the horror!
The result? Clean, Easy-to-read code!
Unfortunately, like you say, a lot of people prefer to preach, "Don't you ever do this", instead of "Doing this is OK as long as you're aware of such and such potential problems". When it comes to the using directive, the only problem that can occur is name clashes, which the compiler is happy to tell you about, and can be corrected with the scope-resolution operator.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Hi,
does anybody know how i can make some changes at the axis scaling of a MSChart Control at runtime ?
Marco
|
|
|
|
|
I'm stuck in this CControlBar hell, using the wonderfull CSizingControlBar, I need to be able to do some stuff when the user closes the floating bar, when he presses on the x button, which is different than when the user show/hide the bars, because I can handle the menu item in the mainframe.
by default, the floating control bar frame is a CMiniDockFrameWnd, see the deeply undocumented m_pFloatingFrameClass member of the CFrameWnd class. so, when I use a CSizingControlBar, the frame is "hard coded" to CMiniDockFrameWnd. and I can't handle messages for it, and I can't handle the close.
So, as explained in the the CSizingControlBar documentation and code, I can replace the pFloatingFrameClass with my own CMiniDockFrameWnd derived class, this kinda' work, but will this replace the miniframe for all toolbars ? yep, looks like it,
I was able to fix this by using my own CMiniDockFrameWnd derived class to handle the WM_NCLBUTTONDOWN and check for HTCLOSE ... and do my stuff, and I also needed to handle the same kind of things when the bar is docked ...
Anyway, I think that the way the controlbars are handled are the work of the devil!
now, go about your daily business ...
Max.
|
|
|
|
|
Maximilien wrote:
Anyway, I think that the way the controlbars are handled are the work of the devil!
Yup.
---
Shog9
Life seems pretty easy when it's from my easy chair
And you're burnin up inside and no one cares...
|
|
|
|
|
Ok, I'm modifying someone else's cool OpenGL program. All I wish to do now is to add some cool zoom functions (it's a 3D mapping program).
I was thinking that when you would click on a spot, it would zoom in on it. So I found these functions:
SetViewportOrgEx() // I would use this to set the new orgin
ScaleViewportExtEx() // I would use this to zoom in
I put them both in my code, but nothing happened! No errors, no screen changes, no bad return values--nothing!
If you have any ideas (or even another way to do it), please help! This functionality would be really cool to the program,
~ Selevercin
If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
Bonjour,
I don't where you put this code but you need to put it on the OnPaint event like this :
void CTNSImageCtrl::OnPaint()
{
PAINTSTRUCT ps;
CDC *cDC = BeginPaint(&ps);
// SetMapMode(cDC->m_hDC, MM_LOMETRIC);
SetWindowOrgEx(cDC->m_hDC, 0, 0, NULL);
SetViewportOrgEx(cDC->m_hDC,
-GetScrollPos(SB_HORZ),
-GetScrollPos(SB_VERT),
NULL);
OnDraw(cDC, &ps.rcPaint, NULL);
EndPaint(&ps);
}
Here is a sample where i just move not scale for the scale i use another way !!!
Simplicity is the supreme sophistication.
-------------------------------------------
http://www.borie.org/
|
|
|
|
|
If it is really an OpenGL program as you stated then the GDI Viewport functions will have no effect on it. There are two techniques commonly used to zoom in on an object in OpenGL. Either add a scale call (GLscalef(x,y,z) I think) and incrementally bump up the scale factors to increase the size of the object or move the camera gradually closer to the object. There are OpenGL samples on this site that demonstrate this.
The Ten Commandments For C Programmers
|
|
|
|
|
Well that explanes my problem! First of all, the person who origonally wrote this prog said that maybe a glscale() function existed. I can't find either your version or his of this function.
Also,I don't suppose you happen to know if I really need a z value. I would assume for a zoom-in function, you would simply decrease x and y to make it appear that you are zooming in.
If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
Selevercin wrote:
Also,I don't suppose you happen to know if I really need a z value.
You talked about 3D, so the z value is necessary.
Selevercin wrote:
you would simply decrease x and y to make it appear that you are zooming in
... decrease them by dividing them by a value which appears to be related to z ....
~RaGE();
|
|
|
|
|
Hello all,
I had a question regarding how to get to the View of a particular window. I created an MDI application without doc/view support. When I hit File->new, a new window appears thansk to this App Generated Code
CMainFrame* pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd);
// create a new MDI child window
pFrame->CreateNewChild(
RUNTIME_CLASS(CChildFrame), IDR_NICKMITYPE, m_hMDIMenu, m_hMDIAccel);
My problem is that I wish to open a DIB into this new window. Everytime I open the DIB though, it goes to the background of my application and not to this new window. I have determied that this happens due to the fact that when I call GetView(), it returns &m_wndView. m_wndView is the view of the ChildView class, and hence it always appears as the background (right?). How can I get to the View of the Child Window that was created? Please help me out, or let me know if I am going about this in the right way.
I am thinking that what I should do is write a new view class, and have the DIB open into a new window using this view class. What do you guys think?
Thanks,
NickOne
|
|
|
|
|
Hi,
I'm working on an Add-in for VS6. One of my pb is to deal with modeless dialog.
When I use a non modal window, I do not catch all the messages from the keyboard anymore. For instance, if I type some text in an edit box, everything is fine except for the DEL key (same with Escape, Ctrl-Z, etc.) which acts in the VS editor window behind...
If you have any suggestions...
Christophe
|
|
|
|
|