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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 260k
  • Answers 260k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer From Wikipedia: When a computer is first powered on, it… May 13, 2026 at 11:25 am
  • Editorial Team
    Editorial Team added an answer In addition to using quotes properly, don't retype the alphabet.… May 13, 2026 at 11:25 am
  • Editorial Team
    Editorial Team added an answer Try something like this: class ServiceApplicationProxy : MarshalByRefObject { public… May 13, 2026 at 11:25 am

Related Questions

Using: VS2008, Win32, C/C++ I'm trying to encapsulate my entire dialog window into a
I just started using C++ VS2008, and downloaded an archive of samples from MSDN.
So I'm learning C++. I've got my C++ Programming Language and Effective C++ out
We have a c++ application which I recently ported from Linux/gcc to build on
I am new to Windows and Visual Studio. I have a strong background in

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.