Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8977239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:19:33+00:00 2026-06-15T19:19:33+00:00

I am using C++(11) w/ Visual Studio 2012. I create windows using a custom

  • 0

I am using C++(11) w/ Visual Studio 2012.

I create windows using a custom made wrapper class.

CUIWindow* winA = new CUIWindow ( NULL, TEXT("winAClassName"), TEXT("winACaption"), 200, 300 );

Each window has a series of “sockets” for pluggabe events.

public:
    LPFNCUIWINDOWONCLOSE OnClose;
    LPFNCUIWINDOWONDESTROY OnDestroy;
    LPFNCUIWINDOWONNOTIFY OnNotify;
    LPFNCUIWINDOWONSIZE OnSize;
    LPFNCUIWINDOWONHOTKEY OnHotkey;

I use the following macro for calling the different sockets that can be assigned to my window class in the message loop:

#define MapEvent(e, fn) \
{ \
    case e: \
        if ( fn != nullptr ) \
            return static_cast<LPARAM>( HANDLE_##e((hWnd), (wParam), (lParam), fn) ); \
}

I have a situation as below;

Code with breakpoint

You can assume pWindow is a valid pointer to a CUIWindow object.

At the shown breakpoint some of the uninitialized OnXXXX events are defined as 0xCDCDCDCD and are getting called when their message arrives (regardless of me never actually explicitly setting them after class creation). This gives me an 0x0BADFOOD exception because the function pointer is bad. I would have assumed that null function pointers would have been caught by if ( fn != nullptr ) however now I am not so sure and I’m requesting help to;

  1. Explain why this is occurring
  2. Find the best way to stop this from occurring, preferably without explicitly setting all the function pointers to zero in the constructor since sometimes there are many, many, sockets.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:19:34+00:00Added an answer on June 15, 2026 at 7:19 pm

    Uninitialized pointers don’t generally get set to a null pointer automatically. Is changing your class slightly an option? If so, you can set all of them without naming all of them.

    struct CUIWindowEvents
    {
        LPFNCUIWINDOWONCLOSE OnClose;
        LPFNCUIWINDOWONDESTROY OnDestroy;
        LPFNCUIWINDOWONNOTIFY OnNotify;
        LPFNCUIWINDOWONSIZE OnSize;
        LPFNCUIWINDOWONHOTKEY OnHotkey;
    }
    
    class CUIWindow
    {
    public:
        CUIWindowEvents Events; // move all events to a simple struct
    
        CUIWindow() // and in your constructor
            : Events() // initialise Events; this sets all the pointers to null
        { ... }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Visual Studio Express 2012 RC. If a create a blank hello
I'm using Visual Studio 2012 for Windows Phone 7 and this is my first
Using Visual Studio 2012, I'd like to create a C++ project folder called Include
I've created a brand new MVC 4 application in C# using Visual Studio 2012.
I'm trying to use Visual Studio 2012 to create a Windows Forms application that
I'm using Visual Studio 2012 in Windows 7 64 bit. I need to use
I've developing a Windows 8 app using .NET 4.5 in visual studio 2012 ultimate.
I am using Windows 8 Pro and Visual Studio 2012 Ultimate (both RTM). I
I'm using Bullet Physics, on Windows 7 and Visual Studio 2012. I have compiled
When I create a new F# Application under Visual Studio 2012 and build it,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.