Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

Phil Speller

@Phil Speller
About
Posts
81
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • To all you Brits
    P Phil Speller

    Richard Stringer wrote: Yep!! She probably isn't British anyway. She shows far to much guts and gumption. Probably a stealth American planted there long ago by the CIA just in case the Brits needed help - again. Richard Richard Stringer wrote: "He who joyfully marches in rank and file has already earned my contempt. He has been given a large brain by mistake, since for him the spinal cord would suffice. --Albert Einstein That's irony isn't it... Phil

    The Lounge html com

  • Socket Program
    P Phil Speller

    I haven't played with raw sockets or icmp but on a quick scan of your code the use of (SOCKADDR*)dip in the sendto fn looks wrong - don't you mean to use (SOCKADDR*)sin instead? Phil

    C / C++ / MFC help

  • Callbacks
    P Phil Speller

    The problem is to do with your FontHook pointer. To get this working you need to remove the following from your code: //create the pointer LPCFHOOKPROC FontHook; Then ensure that you have a prototype for the callback fn somewhere before where you create your dialog. Prototype will look something like: UINT CALLBACK FontHook( HWND, UINT, WPARAM, LPARAM ); What you are doing wrong is creating an uninitialised local pointer in your dialog creation fn and you specify this pointer as the address of the callback fn. In debug mode, items such as un-initialised pointers always get set to 0xCCCCCCCC so that it's easy to recognise them as such. Phil

    C / C++ / MFC help performance question

  • Drawing an icon with an overlay icon on a dialog
    P Phil Speller

    Salvador Dali wrote: Now, that is truly surreal! :) Phil

    C / C++ / MFC graphics question

  • Would you disguse your web servers?
    P Phil Speller

    Yes, I find a Minnie Mouse costume with large ears and pink ribbons to be very effective. Oh, you were talking about web servers... :-O Phil

    The Lounge com sysadmin question

  • A British super-hero
    P Phil Speller

    Ah, but he (AGM) is working on the principle that clamping is immoral. Phil

    The Lounge html com question announcement

  • Embedded CRC algorithm
    P Phil Speller

    There is more than one type of CRC algorithm, but here[^] you'll find a link to the CRC32 code used in ZLib. It is copyrighted, but whether that means just the code or the algorithm as well I'm not sure. Well, the quiz didn't mention anything about the 3 people communicating with each other, so I thought of using hand-signals pass on what each person saw the others wearing. Phil

    The Lounge html com hardware algorithms question

  • help mee
    P Phil Speller

    Try the VB forum - they might not be able to help you, but they can certainly sing along with you Phil

    C / C++ / MFC c++ java help

  • Winsock question
    P Phil Speller

    Scolinks wrote: How can I communicate with more clients ?(Do I have to create a new socket for all new clients? ) Indeed you do. The socket you initially create on your server is just used to accept new connections from clients. When you call accept it will return a socket which you use to communicate with that client. You'll need to keep track of all sockets created by th accept fn. Phil

    C / C++ / MFC question sysadmin help lounge learning

  • Horrid Memory Management Issue
    P Phil Speller

    Alan, You shouldn't need to perform any copying. The idea of creating a memory block/pool that is several times larger than the object(s) you want to place within it is to reduce the number of times malloc or new are called (not placement new). When you have filled that block, allocate another and start using that one (you will now have two blocks containing object - there should be no need to copy the contents of your original block to the second one). Keep doing this for as long as you need space to store your objects. A scheme such as a two-way linked list that forms a header at the top of each block will enable you to keep track of each one allocated - and provide a mechansim to remove blocks once all the objects it contains are deleted. This should still be fairly efficient. Actually, I'm pretty sure this is how vector is implemented and I think the growth factor effectively determines the block/pool size used. Cheers, Phil

    C / C++ / MFC help graphics docker data-structures performance

  • Horrid Memory Management Issue
    P Phil Speller

    Also, take a look here[^] for some more info. The bit about alignment is worth noting! Phil

    C / C++ / MFC help graphics docker data-structures performance

  • IP Address of own PC
    P Phil Speller

    I might be on the wrong track here but when you call bind on a socket you can specify ADDR_ANY for the ip address. Then, windows will sort out which actual IP address to use based on routing information - this saves you having to manually determine which IP address you need to select. Phil

    C / C++ / MFC question

  • Horrid Memory Management Issue
    P Phil Speller

    Well, first off, I've gotta say thanks - I learnt a new thing today - I was never aware of the placement syntax :/ Mixing C-style and C++ style memory allocations is not a good idea since they use separate memory managers. You could replace your malloc(sizeof(T)) with new char[sizeof(T)]. Realloc would still present you with the copying problem - infact, if realloc can't extend the memory area it will create a completely new area and perform a copy operation. It does look like the placement syntax enables you to give an explicit address for the object you wish to dynamically create - it also looks like that will remove the overhead of the memory manager actually finding a suitable sized piece of free memory. So, I am thinking you are on the right track here. [EDIT] One thing I forgot to mention was that when you do use placement new, Stroustrup states that you need to explicitly call destructors for objects when you want to delete them - this makes sense since the memory manager is being bypassed. [/EDIT] However, you may want to consider creating space for several objects each time you need to reserve space i.e. new char[N*sizeof(T)]. Now create you own memory management scheme that uses that pool of memory with placement new. When that area is exhausted, create another pool. This has the effect of reducing the number of times the standard new operator needs to be called - thus reducing overhead. Ok, you have to manage each pool but working with fixed sized objects within each pool should be fairly efficient to to. There is a book called "Efficient C++" which looks at these issues in some detail. Hope this helps Phil

    C / C++ / MFC help graphics docker data-structures performance

  • Disk Wiper...
    P Phil Speller

    Give Eraser[^] a go. It's free and implements Peter Gutmann's algorithm for secure deletion of data[^] by default Phil

    The Lounge question

  • Tips on learning microcontroller programming / interfacing?
    P Phil Speller

    Well, I don't know if this is a must have book, but it does provide a gentle introduction to the various aspects of microcontroller programming - Programming Embedded Systems in C and C++, by Michael Barr and published by O'Reilly. ISBN 1-56592-354-5 As for interfacing (and electronics in general) you probably still can't do better than The Art Of Electronics, by Paul Horowitz and Winfield Hill. Published by Cambridge University Press. ISBN 0-521-37095-7 Phil

    The Lounge com hardware performance help tutorial

  • The best way 2 skin an application?
    P Phil Speller

    AFAIK I'm afraid not - you are on the right track with what you have found. Skinning an application literally involves stopping windows drawing the various windows/controls and doing the drawing yourself. Many of the techniques you'll see involve taking an MFC class and modifying/overriding the code that actually draws that control - this gives you the look you want while retaining the all functionality. I particularly like the work by Davide Calabro - you can learn alot from this. Phil

    C / C++ / MFC c++ delphi com tutorial question

  • Running
    P Phil Speller

    Take a look at the Runners World[^] website. There is a good beginners section. Here, as well as everywhere else I have looked, they suggest thinking in terms of time spent running rather than distance covered. They also suggest mixing running and walking to help in building up your stamina as well as getting muscles and tendons used to the exercise. All the programmes I have seen aim to get you running continiously for 20-30 mins over a period of 8-10 weeks - basically you start run/walk programme i.e. walk for x mins, run for y mins then repeat n times. You start off walking for longer than you run. Over the weeks you decrease the time you spend walking and increase the running until at the end of the program you are running for 20-30 mins. Hope this helps, Phil

    The Lounge question

  • Starwars in ASCII
    P Phil Speller

    roel_ wrote: something else this guy has build - a jet powered beer cooler! :laugh::laugh::laugh: Phil

    The Lounge c++ database question

  • Timer Callback
    P Phil Speller

    Declaring a member function of class as static will remove the need for an instance of the class to be associated with it - i.e. no this pointer. What this means is that it can't access any of the normal member functions/variables - precisely because there is no associated this pointer. However, supply the static function with a pointer to an instance of the class and you can access all functions/variables (even private ones) via that pointer - because the static function is still declared in the scope of the class. In terms of pointers to functions, because a static member function has no associated this pointer you can obtain it's address directly (just like a C function) - this is why Ryan's suggestion worked. Any normal member function must have an associated this pointer with it, so even when you take the address of a member function you must still use it with a pointer to an instance of the class as well. class CMyClass { public: void MyFn (void); static void MyStaticFn (CMyClass *); }; typedef void(* FnPtr)(CMyClass*); // C style fn pointer typedef void(CMyClass::* MemberFnPtr)(); // C++ style fn pointer CMyClass* pMyClass = new CMyClass; MemberFnPtr pMFn = &CMyClass::MyFn; pMyClass->MyFn(); // Calling as normal pMyClass->*pMFn(); // Calling via pointer to member fn FnPtr pFn = &CMyClass::MyStaticFn; (*pFn)( pMyClass ); // Calling static member fn [edit] You could try using the nIDEvent parameter of SetTimer to hold the pointer to your class instance - cast it back to the correct type and use within your static fn. [/edit] Hope this helps, Phil

    C / C++ / MFC c++ help question

  • Timer Callback
    P Phil Speller

    To expand on Ryan's post - it's all to do with pointers to member functions. Take a look at this[^] site - it will explain all! Phil

    C / C++ / MFC c++ help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups