|
First of all, good for you for being willing to recognise the need to go back to C++ without the MFC trimmings, etc.
You should own 'The C++ Programming Language' by Bjarne Stroustrup if you program C++. If you don't, go out and buy it. As well as being a great reference, it is full of suggested projects so you can choose tasks that relate to the areas you want to learn.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Alright, thanks! I will pick it up this weekend.
|
|
|
|
|
Hey I'm in a big need for a async sockect class that is pretty much a clone of the MFC version, with all it's features.. But importantly Is thread safe! . or doesn't have to be used in a single thread
Any ideas ? I'm looking for any library out there that you guys can recommend , free is good but $$$ is fine if it does the job and is solid.
Thanks heaps!
Jared Allen.
www.chironexsoftware.com
|
|
|
|
|
why do you want to use an async sockect class in more than one thread?
|
|
|
|
|
do you know where can i get a simplest crc32 algorithm written without mfc?
|
|
|
|
|
|
zLib has a pure C implementation
http://www.gzip.org/zlib/
-c
"[it was..] one of those evenings when you feel that not only will there definitely be a revolution, but that the Association of Manufacturers will foot the bill."
-- Umberto Eco, Foucault's Pendulum
|
|
|
|
|
|
Im wondering how to set a "StayOnTop" for some window.
Could anyone help me?
No mfc.
|
|
|
|
|
::SetWindowPos(myHWND, &hwndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
&hwndTopMost might be wrong, but it's something like that, the rest is correct. Check MSDN for the right parameter if I blew it.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
true, it should be:
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
big thx.
|
|
|
|
|
No worries - I think I may have given you the MFC paramters, but so long as it got you on the right path.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
|
You may be trying to make your window always stay on top, if that is the case then you will want to use:
<br />
LONG exstyle = ::GetWindowLong(hwnd, GWL_EXSTYLE);<br />
::SetWindowLong(hwnd, GWL_EXSTYLE, exstyle | WS_EX_TOPMOST);<br />
[edit]If you use the SetWindowPos function, and set the window in the topmost slot, it only temporarily moves your window to the top of the Z-Order for all non-topmost windows. As soon as application focus shifts somewhere else your window will shift away from the top.[edit]
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Paul Watt (kilowatt) wrote:
If you use the SetWindowPos function, and set the window in the topmost slot, it only temporarily moves your window to the top of the Z-Order for all non-topmost windows. As soon as application focus shifts somewhere else your window will shift away from the top.
Sorry, wrong. if you set it to top, it will drop again, but if you set it to topmost, it will stay there.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
I know, this is a really novice type of question, but, I'm trying to understand the subject in detail, before I start generating vast numbers of incomprehensible error messages.
In allocating memory dynamically in an application either globally or in a class-specific scope, how does a person know what is actually happening in the "pool called the free store"? Are there ways to monitor this without writing a "custom exception-handling routine" (which in my case, would undoubtedly generate many more error messages)?
...And, (ha ha) I have absolutely NO IDEA what a custom exception-handling routine is, much less, how to approach the problem.
I have been doing some preliminary reading over at the MSDN site, where they have an overwhelming amount of technical information. In the C++ Language Reference, they tell us that: "when new is used to allocate memory for a C++ class object, the object's constructor is called after the memory is allocated". They also tell us that "the new keyword allocates memory for an object or array of objects of type-name from the free store and returns a suitably typed, nonzero pointer to the object". They then show a couple of code examples, but, I don't see how the pointer can be used to demonstrate either the amount of memory used in that particular expression, or if this feature can be utilized to detect that evil scourge 'memory leakage'.
Any enlightenment is appreciated. ...And, humor, even malicious humor (if necessary) will be thoroughly enjoyed.
Trash me,...
|
|
|
|
|
Wow - you're trying to understand some heavy stuff here. FWIW I have no idea what the answer is, excepting that you can use sizeof to get the size of an object, which I presume is what you want to know. However, it doesn't really matter to know how much memory you are in risk of leaking, just make sure you delete everything you new, and you won't leak at all.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
I'm not quite sure exactly what you're asking, but I'll address the particular question you asked earlier in the post:
Anonymous wrote:
In allocating memory dynamically in an application either globally or in a class-specific scope, how does a person know what is actually happening in the "pool called the free store"?
Basically, at that point the operating system is giving you memory from the available ram on the system (called somewhat generically 'free-store') and returning an address to that ram (that address being a relative address, not an absolute). You as the programmer shouldn't have to worry about 'what happens' in the pool. Theoretically, nothing should 'happen' to that memory at all, except that it's now allocated to your particular process, and the operating system more than likely marks it as such so other processes (naturally) don't get ahold of it.
Now, to address some other stuff you loosely talked about, such as allocating a c++ class and automatic calling of a constructor-- those things have little to do with the 'free-store' but have a lot to do with the methodology of a c++ program. Don't allow the text: "when new is used to allocate memory for a C++ class object, the object's constructor is called after the memory is allocated" confuse you. The two things happening in the description have nothing to do with eachother (technically). If I instantiate a c++ object (class) its constructor is automatically called. If I do the same thing using the NEW operator, then its constructor is automatically called. The only difference is that the 'new' operator dynamically allocates the memory space for the new class on the heap, and then calls a constructor. If I allocate 'int' or 'char' or 'float' with the 'new' operator, the same thing occurs on the free-store (as it's called), but no constructors are called because they're not c++ classes but base data types.
Does this help at all?
Paul Oss
|
|
|
|
|
The amount of memory in the free store really depends on your memory manager. When you call new, the default memory manager is the C-runtime libraries. These libraries allocate a page of memory, and then dish out pointers to you as you need it. When you call delete that memory is returned to the store. It really does not matter how much memory is available in the store as you could use a memory manager that does things completely differently. In fact you could write your own memory manager and over load the new operator to faciliate this yourself.
What I would recommend is that you become very comfortable with the interface that C++ has supplied to allocate memory (new and delete) and move on from there.
C++ does not really supply a clean way to report how much memory has been allocated to a specific pointer. It is up to the developer to manage these sizes. If you allocate memory for an array of bytes with new like this:
<br />
new BYTE[100];<br />
you will get 100 bytes. If you want to pass that pointer to a function call, and that function needs to know how much memory is in that buffer, you will need to pass the 100 in as well.
Objects created on the stack can use the sizeof() operator. This is a compile time feature that will report the number of bytes in a particular object or variable. But beware if you try this:
<br />
Object *obj = new Object;<br />
int size = sizeof(obj);<br />
size will equal 4 (or the size of the pointers on your system), because you are requesting the size of the pointer to the object rather than the object itself.
Like Christian already posted, if you dont want to leak memory, then make sure you match each new with a delete, and each new[] with a delete[]. There are tricks however to help your memory management work a little smoother. C++ has a few template classes called auto_ptr or smart pointers. Another technique that you may want to look into is reference counting. This is a technique that COM uses exensively.
I hope I answered some of your questions, I am not quite sure what all of them were. If you have any others feel free to ask.
Good luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Paul Watt (kilowatt) wrote:
C++ has a few template classes called auto_ptr or smart pointers.
C++ currently has one smart pointer AFAIK, with more to come in the next standard. It's probably a good thing to know about, but it's important to know how it's going to behave before using it.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Christian Graus, Paul Oss, and Paul Watt,
Thank you for the tremendous response (I am the original anonymous that asked). The information (and background) that you provided is exactly what I was looking for, this helped alot.
I will experiment with the new and delete operators in simple, controlled situations to gain insight.
|
|
|
|
|
If anyone can point me to an example of how to make tracking tooltips work in a CControlBar, I will be eternally grateful!
|
|
|
|
|
if I understand correctly, you need to handle the message TTN_NEEDTEXT in a a CWnd window.
Max.
|
|
|
|
|
Say my MDI Document has 3 views. Whenever a File New is done 3 views are created . I want to be able to Tile all the three views during this time .
How can do this ?
|
|
|
|
|
make a call to MDITile.
cheers,
-B
|
|
|
|
|