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 181721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:48:50+00:00 2026-05-11T14:48:50+00:00

Using: VS2008, Win32, C/C++ I’m trying to encapsulate my entire dialog window into a

  • 0

Using: VS2008, Win32, C/C++

I’m trying to encapsulate my entire dialog window into a class for reusability. Sort of like a custom control. In doing this, I am moving my seperate functions into a class. The following struct design though is giving me problems, with Visual Studio outputting: error C2334 ‘{‘.

It’s a simple message map layout. But I can’t seem to escape this C2334 error. 🙁

Here is my class code snippet.

class CScrollingListDlg { private:  LRESULT DoCommandMain (HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam); LRESULT DoPaintMain   (HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam); LRESULT DoAnimationTimer (HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam); LRESULT DoHandleTouch (HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam); LRESULT DoDestroyMain (HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam);  // // message maps // // Generic defines and data types. struct decodeUINT {     UINT Code;     LRESULT (*Fxn)(HWND, UINT, WPARAM, LPARAM); };  struct decodeCMD {     UINT Code;     LRESULT (*Fxn)(HWND, WORD, HWND, WORD); };  // WM_Message dispatch table for MainWndProc.  // // ***  error C2334 '{'  *** // const struct decodeUINT MainMessages[] = {     WM_PAINT,   DoPaintMain,     WM_DESTROY, DoDestroyMain,     WM_QUIT,    DoDestroyMain,     WM_COMMAND, DoCommandMain, };   }; 

What am I missing here?

Thanks.

  • 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. 2026-05-11T14:48:50+00:00Added an answer on May 11, 2026 at 2:48 pm

    You cannot specify initialisers for non-static members that way — you would normally need to declare the array and then populate it inside the constructor… Except that, in fact there is no way to initialise const member arrays in C++ (see this thread).

    If you are prepared to share MainMessages amongst all instances of CScrollingListDlg (which I suspect was your intention all along), you should make it static, in which case you can declare:

    static const decodeUINT MainMessages[];  // 'struct' keyword unnecessary 

    inside the class definition of CScrollingListDlg, and then define it outside the class:

    const CScrollingListDlg::decodeUINT CScrollingListDlg::MainMessages[] = {     WM_PAINT,   DoPaintMain,     WM_DESTROY, DoDestroyMain,     WM_QUIT,    DoDestroyMain,     WM_COMMAND, DoCommandMain,    // The comma *is* allowed -- thanks Josh! }; 

    In order for this to actually compile, you’ll need to make DoPaintMain(), DoDestroyMain(), etc. static as well — as it stands, they are all per-object methods that implicitly take a this pointer, so they can’t actually be contained in a function pointer of type LRESULT (*Fxn)(HWND, UINT, WPARAM, LPARAM). (You could leave them as non-static methods and change the pointer type in decodeUINT to a pointer-to-member-function type, but that’s probably not what you want.)

    [EDIT: Thanks to Josh for some helpful comments!]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a Custom Server Control in C# using VS2008. I
Using VS2008 C# am attempting to interop a C++ dll. Have a C++ class
I'm trying to get a simple example working using gSoap, for VS2008. I've done
I'm using VS2008 and would like to create a compile time warning / error
I have been trying to add a .cu file into my own(dll) win32 project
In vs2008's project settings you can define custom symbols, such as DEBUG or WIN32.
Using VS2008, c#. When I call Path.GetTempFileName(), the temp file generated is something like:
I am using VS2008 for ASP.NET apps. My Solution Explorer has hierarchy like this:
I am trying to create a simple service in C# using VS2008 that creates
I am trying to debug the .Net framework source using VS2008 SP1. It is

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.