Advertisement Jump to content
  • Advertisement

Muhammad Haggag

  • Content Count

  • Joined

  • Last visited

Community Reputation

1358 Excellent

About Muhammad Haggag

  • Rank

Personal Information

  • Interests

Recent Profile Visitors

17028 profile views
  1. You're probably running into a corner case in the extension where it's not expecting to be invoked as part of the open file dialog. The dialog runs as part of your process, and so your process crashes.
  2. Can you post your attempts? Which version of Visual Studio are you using?
  3. The last time I ran into this, I was calling DefWindowProcA instead of DefWindowProcW.
  4. Muhammad Haggag

    weird win32 GDI bug

    The problem manifests because of the MoveBall call: pe = gpBall->MoveBall(*gpPlayerOne, *gpPlayerTwo); You're dereferencing pointers. That'd have been fine if MoveBall took Player references (Player&), but it doesn't: PlayerEnum Ball::MoveBall(Player argP1, Player argP2) What happens is: 1. The MoveBall call copy-constructs two copies of players one and two. That'd have been fine if you'd implemented proper copy construction and assignment on the Player class, but you didn't, so the compiler-generated ones were used. 2. The compiler-generated copy constructor does a shallow copy of the instances (i.e. copies all members), so argP1 and argP2 both end up with handles to the player bitmaps (mhbmpPaddle). 3. At the end of MoveBall, both argP1 and argP2 are destroyed, and your destructor releases mhbmpPaddle, leaving gpPlayerOne and gpPlayerTwo with invalid mhbmpPaddle handles. 4. You SelectObject() with an invalid handle, which fails. You try to draw the paddles, but you're drawing with whatever object was selected before your drawing. There are several good things to learn from this: 1. If your class manages resources (i.e. releases them in the destructor), either write a proper copy constructor and assignment operator, or suppress the compiler from generating them. You can do this by declaring them private: private: Player(const Player&); Player& operator=(const Player&); 2. Avoid jumping to early conclusions while debugging. The problem has nothing to do with height at all. The first thing I did when debugging was to paint the paddles blue, with thin yellow and red stripes at the top and bottom. They still showed up as white, which confirmed that the bitmaps aren't being painted at all when the bug manifests, which pointed to either corruption of the bitmaps or their handles (since they were drawn fine at startup). 3. Always check for return values. If you were checking the return values of SelectObject(), you'd notice that it returns NULL for players right after you unpause the game. After suspecting the bitmaps, I replaced all calls to SelectObject() with a CheckedSelectObject() that breaks in the debugger if SelectObject() fails: inline HGDIOBJ CheckedSelectObject(HDC dc, HGDIOBJ obj) { HGDIOBJ result = SelectObject(dc, obj); if (!result || result == HGDI_ERROR) { OutputDebugString("SelectObject failed"); DebugBreak(); } return result; Once I related the bug to unpausing the game, I quickly isolated the MoveBall call as culprit. 4. Don't pass objects by value. By default, pass them as const references. You avoid painful bugs like this, as well as object slicing bugs (which are equally hairy to locate).
  5. Muhammad Haggag

    Brunhilda and the Dark Crystal - Open Beta

    That looks beautiful. I'll give it a try when I get home. Consider posting it to the Image of the Day gallery.
  6. It's been a long time since I've installed a DirectX SDK, so I don't recall what they used to do. I can confirm that the March one doesn't modify the Visual C++ directories, and I think it's better that way. System-wide include/library overrides are dangerous. It makes more sense to add directories per project instead.
  7. Muhammad Haggag

    Alternatives to Visual Assist X?

    As far as Visual Studio plugins go, you won't find anything better for C++. If you're open to moving to other editors, though, some folks on my team use SlickEdit and swear by it. I haven't used it myself, though.
  8. Muhammad Haggag

    MVP Summit time!

    I'd love to see you when you come to Redmond for the MVP summit. I'm not much of a pub/restaurant/whatever guy, but we'll manage something. I'll mail or PM you my phone number when the time draws closer.
  9. Muhammad Haggag

    DLL abstract class export

    1. Is that the actual code you used? I don't see any __declspec(dllexport) on the Object3D class. 2. Where's the code that calls initialize()?
  10. Muhammad Haggag

    DLL abstract class export

    CodeProject: HowTo: Export C++ classes from a DLL. I'm not sure how things work on the gcc side, though. I generally avoid exporting C++ classes.
  11. Muhammad Haggag

    Registry comparison software

    Microsoft KB: How to Use WinDiff to Compare Registry Files. Summary: Export registry to text file before and after, use a textual file diff. Given that you're testing your installer, it's generally recommended to do this on clean OS installations using a virtual machine.
  12. Muhammad Haggag

    Does C++0x...

    Don't call the non-const version from the const one. By definition, the non-const version might change the object state, thus violating the contract of the const version. Do it the other way round: Call the const version from the non-const one. You'll need two casts: One static_cast to add const to this, and a const_cast to remove the const from the return type. Casting the constness away is safe because whoever called the non-const version in the first place has a non-const reference to the object. Color& getPixel( uint x, uint y ) { return const_cast<Color&>(static_cast<const Image*>(this)->getPixel(x, y)); } const Color& getPixel( uint x, uint y ) const { return pixels_[ y * width_ + x ]; }
  13. Muhammad Haggag

    C++/VS2008 linker PAIN AND SUFFERING

    Quote:Original post by InvalidPointer Quote:Original post by xZekex Why don't you just link it normally in the project settings and not through #pragma stuff. I lose the ability to cleanly differentiate between the 64- and 32-bit versions of the libraries. You can create separate 64-bit configuration variants (i.e. Debug 64-bit, and Release 64-bit). Use the linker search path setting, which is a per-configuration setting, to point to either the 32-bit or 64-bit library directories.
  14. Muhammad Haggag

    Oh boy....

    Mice can be harmful. They can transmit diseases. Back before the advent of electricity, it was possible for mice to cause fires by knocking down lanterns and similar primitive lighting devices. The first incident I could find was when a house was lit on fire by a mouse, and so prophet Muhammad told people they shouldn't leave fires lit at night, and that they're allowed to kill mice. So in general Sharia allows killing mice if they're deemed harmful. For those living in rich countries, this might seem irrelevant. It is relevant in many parts of the world--remember, the poor vastly outnumber the rich, the under-developed vastly outnumber the developed. The village where my mother was born, for example, was introduced to electricity only 40 years ago. My mother, a pathologist, used to study on Kerosene lamps when she was a child. How this guy projected the above into "Mickey Mouse is a soldier of Satan, and should be killed" is his problem. There are no "insane laws". The same guy, for example, thinks it's prohibited to take personal photographs unless necessary (as in: you can't just photograph yourself and keep the photo in an album--it has to be for a driver's license or something. And he's probably against using photos in drivers' licenses, but I digress). You'll find these sorts of opinions mostly among some Saudi "scholars", because of their somewhat bedouin lifestyle.
  15. Muhammad Haggag

    So far so good

    Windows Server 2008 seems to beat the pants off Vista in terms of responsiveness. A coworker installed it recently and we watched in shock as he right clicked the desktop and the menu appeared right away! [grin] Seriously, Control Panel doesn't take time to load (as it does on the retarded Vista). He can have a build running, and actually be able to use Outlook (not possible under either Vista or XP with our Quad core machines at MS). And so on.
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!