|
Yep. You're probably better off doing it that way, anyway.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
|
I know how to write data using fstream but have not been able to figure out how it works reading. Do you know a tutorial?
Thanks,
Ruben
|
|
|
|
|
I'm trying to get back into the hang of programming so I'm writing a small chat program and I need to determine my IP. Anyone has any snippets of code to help ? (I'm using VC++ 6.0 btw).
|
|
|
|
|
One way is gethostname() followed by gethostbyname().
|
|
|
|
|
One solution is getnameinfo().
Kuphryn
|
|
|
|
|
I'll add one comment here -- it's pretty rare that you ever need to know your own IP address.
More often than not, your own IP address is pretty useless, unless you want to print it to the screen out for reference.
If you want to talk to another process on the same machine, you can use 127.0.0.1 as the IP (same as localhost).
If you send either a TCP or a UDP message to another process -- then that process also receives information about where the packet of data came from. Using that information, you can send data back to the sender through a different connection....
"A" wants to talk to "B".
"A" needs to know the address and port to talk to "B".
"A" sends message to "B" using the address of "B" and port XXXX.
"B" now knows the address of "A", and "B" can now send a message to "A" assuming that he knows the port.
This may be too much information and totally off the point. But I thought I should add it anyhow.
Enjoy.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
Santa Cruz Networks
|
|
|
|
|
when a user signIn into MSN messenger , there comes a window at the right bottom of the screen, how can i build this, plz help, or any webpage ragarding help on this
Knowledge is Power
|
|
|
|
|
There you go:
http://www.codeproject.com/dialog/statusbarmsgwnd.asp?target=msn%7Cmessenger
You can also have some tutorial on how to do this in C#.
bye
Everything's beautiful if you look at it long enough...
|
|
|
|
|
Hi All...
I have been doing a little searchng, and am having a hard time finding a succinct explanation (for a beginner) of how to go about creating an app from scratch. My idea is this: I want to create a windows based program that will emulate an electrical system as you would find in a building (residential/commercial/industrial).
(note: I am an electrician by trade, no longer working due to injury, and back in college at 35 to try and get a BSEE. I took a c++ class last semester and this is why I am torturing you all with all these knuckleheaded questions, the class did not get into development for Windows, it was just programming basics.)
Anyway, I just want to do this for the sake of doing it (the learning experience). I will use Dev-cpp, but also have VC++ 6.0 available to me in a student version (although I do not want to use it). I have no intention of releasing this for anything (although if I could make it work well enough, I might just for entertainment purposes, like say to let people see what would happen if they hooked 5000 volts up to their house .....).
My question is this: Where do I start? Would it work if I designed the classes I will need (power source, switch, wire, circuit breaker...etc.) in a console app then integrated them into a windows environment, or should I make it a Windows app from the start? Also, what would be the easiest environment in which to create graphical representations of my classes? Would bitmaps be best? I need to keep this relatively simple (obviously) and my main question is what would be the best Dev environment for this idea? Thanks for the time.
|
|
|
|
|
I'm not sure I would tackle such a problem using C++ (not that it can't be done (DirectX comes to mind), but I don't do graphics and would therefore tend to use a tool that helped me out as much as possible). Based on what you've said, it sounds like Flash would be a better tool for the job. If you've got time, go to www.howstuffworks.com and check out the graphics on their many article pages. They used Flash to create them. Some of them are animated, which I suspect would be a nice feature for you. Show the electricity coming down from the transformer into the breaker box, waiting idly until someone flips a switch and completes the circuit, thus illuminating the bulb, etc.
|
|
|
|
|
OK, my reasoning behind using c++ is that it is the only programming language in which I have any experience at all, I have never used Flash, but if it were something I could puzzle out with a basic knowledge of c++ I would be willing to give it a try.
Also, checked out howstuffworks.com, and that is not really what I had in mind, I want a GUI app that will allow somone to set up an electrical circuit(s). I then want to be able to emulate how that circuit would function under given conditions with a variety of variables. I don't necessarily want to have highly detailed graphics, the ability to manipulate variables is more important. (for instance, building a 120 volt system, then introducing a condition that creates a current overload, or changing the voltage and emulating all the resultant breakers tripping, appliances frying etc.) Can this type of variable manipulation be done with Flash?
|
|
|
|
|
FYI, Just about anything can be done with any tool. If you don't think so, you just haven't figured it out yet.
What I would do if I were you is to start with a graphical app first (VC, using a SDI interface and a docking toolbar) and do the drawings yourself. Not only is this a good intro to drawing on a surface, it will allow you total control of the schematics. Just create a base class called CircuitElement that has a CRect position variable and a virtual Draw() function. Then, derive classes from CircuitElement that override the draw function to draw the specifics of an element. EX:
class CircuitElement : public CObject
{
protected:
CRect m_oPosition;
public:
virtual void Draw(CDC *pDC); // just erase the bkgrnd
virtual void Serialize(CArchive &ar); // save the pos
};
class Outlet : public CircuitElement
{
protected:
amp rating...
etc...
public:
virtual void Draw(CDC *pDC); //call base and draw |=|=|
virtual void Serialize(CArchive &ar);
}
|
|
|
|
|
go with a MFC application right now, you can make a UI fast enough for you to concentrate on the core of the application.
there are 2 important things ( that I see, you can correct me if I'm wrong ) to do, first is the building layout, how will it be presented, will it be only 2D (one floor at a time, with links to pass wires to other floors ), or will it be a 2D1/2 one floor with other floors in transparency, a bit like some architectual plans. or will it be fully 3D with navigate; for the first 2, vector graphics can be easier to work with, or simple GDI graphics, for the 3d, either OpenGL or DirectX
the other thing is to define the electrical layout, switched, fuse boxes, wires, grounds; all the design should be graphic independant, you should be able to define an electrical layout without the need of graphics (i.e. roughly, switch in room X connected to ... )
Everything can be as simple as having simple geometric symbols for each time, all connected with lines, to the more elaborate 3d models to the in-between with bitmaps for each component.
Hope it helps.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
How can i add push buttons instead of check boxes to items in the first coulmn of a ClistCtrl?(Report Type)
Is there any simpler way of doing it without handling OnDrawItems()?
Thanks,
harendra
Haren
|
|
|
|
|
For some reason I get error when I try to call a funtion in another class/file.
Here is what I am doing:
I have written a program that accesses a PCI card and performs functions on that card.
Everything wroks fine when I call these functions from myMainFile.cpp
In that file I have included the pciFunctions.h
I need a class that calls these functions performs tasks on the data and returns the data to the myMainFile.cpp
I need to do this so that I can display the values in various widgets.
so I created a new header file and created a class.
#ifndef rfmAccess_H
#define rfmAccess_H
#include pciFunctions
//other standard includes
class RFMAccess{
private:
public:
RFMAccess(){}
int openCard(char *devPath); //this is the function prototype
};
#endif
*************In myMainFile.cpp***************
#include "rfmAccess.h"
//I created a pointer to the class
RFMAccess *RFMAccess;
Then I call the function.
TmyMainFileForm1::Action1Execute(TObject *Sender){
RFMAccess::openCard("////.//RFM1");
or
RFMAccess.openCard("////.//RFM1");
or
RFMAccess->openCard("////.//RFM1");
}
Should I create the function in the rfmAccess.h or should I create another *.cpp file and do it in there?
Do I have to create a prototype or can I just finish the function in the rfmAccess.h file
Am I doing this right?
Am I calling the function correctly?
Sorry for so many questions, but I need alittle help.
Thanks,
steven
|
|
|
|
|
johnstonsk wrote:
Should I create the function in the rfmAccess.h or should I create another *.cpp file and do it in there?
Technically you could do either, but most of the time you will want to create a .cpp file corresponding to your .h file and define the function there.
johnstonsk wrote:
Do I have to create a prototype or can I just finish the function in the rfmAccess.h file
See answer above. Small technical point: what you have in the header file already *is* the prototype.
johnstonsk wrote:
Am I calling the function correctly?
If you are calling the function via a pointer, then you'll want to use lpRFMAccess->openCard("////.//RFM1");. If you are calling the function from an object you'll want to use oRFMAccess.openCard("////.//RFM1");.
There are some other problems with your code above:
When you define a pointer to the RFMAccess class, you need to give it a valid name. You have written RFMAccess *RFMAccess; -- give the pointer a name other than the class name like this : RFMAccess *lpRFMAccess; Also, when you use a pointer, make sure it is valid. The way you have your code, the pointer is never made to point to a valid RFMAccess object, thus trying to call a function via your pointer will probably crash your program.
--Dean
|
|
|
|
|
Thank you, very helpful and it makes sense.
You mentioned:
most of the time you will want to create a .cpp file corresponding to your .h file and define the function there.
what is the purpose of creating a prototype and then defining the function in another *.h file when you can do it all in one shot?
Just wanting to be a better programmer.
Thanks, steven
|
|
|
|
|
It removes clutter for one. Your header should be as clean as possible. Think of it as a reference for the functions that are contained in the class. If you can't remember how to call a function, you open up the header and find the prototype -- all that extra code in the file makes that task more difficult.
The other (more important) reason for separating the two is known as "separating interface from implementation". Say you write a class and someone else wants to use it later on. They don't need to know how your class works -- only that it does the job you say it will. It keeps things simple for everyone -- it's basically another layer of abstraction.
Plus, if you don't want anyone to see your source code for whatever reason, you can give them the header file and a compiled library to link against and they won't be able to tell how you did what you did with your class (at least not without a bit of extra work.) Then if you change your implementation later on (say for instance you find a faster algorithm for one of your functions) all you have to do is compile a new version of your code library and give it to your users. Then rather than having to recompile their whole program, your users only need to relink their application to your new library rather than recompiling their whole program.
Hope that all makes sense.
--Dean
|
|
|
|
|
very informative,
thanks for the knowledge.
steven
|
|
|
|
|
Is there a web page with a complete listing of Windows Messages and their values?
-Nick Parker
|
|
|
|
|
Try looking in WinUser.h or some of the other header files.
There are 10 kinds of people - those that get binary and those that don't.
|
|
|
|
|
Miszou wrote:
Try looking in WinUser.h or some of the other header files.
I was wondering if the was a website with these listed though, thanks.
-Nick Parker
|
|
|
|
|
You can use the API Text Viewer that comes as part of Visual Studio.
|
|
|
|
|
I use an Object of SplitterWnd class and divide the frame to three view,so how can get one of three views any where .
Thank you !
abc
|
|
|
|
|