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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:36:51+00:00 2026-06-04T05:36:51+00:00

I am having issues with my code. I am making a class to wrap

  • 0

I am having issues with my code. I am making a class to wrap around some WinAPI to create GUIs, however I am having issues when attempting to register the class.

My code:

inline Window::Window(const TCHAR *windowName, const int x, const int y, const int width, const int height, const TCHAR *className) : abstractWindow() {
    Window(0, className, windowName, WS_OVERLAPPEDWINDOW, x, y, width, height, NULL, NULL, NULL, NULL);
}    

Window::Window(const DWORD dwExStyle, const TCHAR *lpClassName, const TCHAR *lpWindowName, const DWORD dwStyle, const int x, const int y, const int nWidth, const int nHeight, const HWND hWndParent, const HMENU hMenu, const HINSTANCE hInstance, const LPVOID lpParam) : abstractWindow() {
    _proc           = (WNDPROC*) &abstractWindow::msgRouter;

    _styleEx        = dwExStyle;
    _className      = (!lpClassName) ? TEXT("MyGuiClass") : lpClassName;
    _windowName     = lpWindowName;
    _style          = dwStyle;
    _x              = x;
    _y              = y;
    _width          = nWidth;
    _height         = nHeight;
    _hwndParent     = hWndParent;
    _hInstance      = (!hInstance) ? ::GetModuleHandle(NULL) : hInstance;
    _hMenu          = hMenu;
    _lpParam        = lpParam;

    _wndClassEx.cbSize          = sizeof(_wndClassEx);
    _wndClassEx.style           = CS_HREDRAW | CS_VREDRAW;
    _wndClassEx.lpfnWndProc     = abstractWindow::msgRouter;
    _wndClassEx.cbClsExtra      = 0;
    _wndClassEx.cbWndExtra      = 0;
    _wndClassEx.hInstance       = _hInstance;
    _wndClassEx.hIcon           = ::LoadIcon(NULL, IDI_APPLICATION);
    _wndClassEx.hCursor         = ::LoadCursor(NULL, IDC_ARROW);
    _wndClassEx.hbrBackground   = (HBRUSH) COLOR_WINDOW;
    _wndClassEx.lpszMenuName    = NULL;
    _wndClassEx.lpszClassName   = _className;
    _wndClassEx.hIconSm         = ::LoadIcon(NULL, IDI_APPLICATION);
}

_wndClassEx is already defined in the class header as of WNDCLASSEX and the register function simply runs RegisterClassEx(&_wndClassEx).

The following are how I call these classes: (However only one is called at a time)

Window gui (TEXT("Title"), 10, 10, 500, 250);
Window gui (0, NULL, TEXT("Title"), WS_OVERLAPPEDWINDOW, 10, 10, 500, 200, NULL, NULL, hInstance, NULL);

The second one works perfectly fine, however when I call the first (shorter parameters, which puts it through to the second) class registration fails. I have completely written the _wndClassEx as well as gone through every single one and modified it to no success. I have gone through with a debugger and everything seems fine. So I have absolutely no idea what to do.

By the way, abstractWindow::msgRouter is static.

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. Editorial Team
    Editorial Team
    2026-06-04T05:36:52+00:00Added an answer on June 4, 2026 at 5:36 am

    The problem is with this constructor:

    inline Window::Window(const TCHAR *windowName, const int x, const int y, const int width, const int height, const TCHAR *className) : abstractWindow() {
        Window(0, className, windowName, WS_OVERLAPPEDWINDOW, x, y, width, height, NULL, NULL, NULL, NULL);
    }
    

    You can’t call a constructor from another constructor like that. What ends up happening is that a temporary object is created and then immediatly discarded. The way to achieve that (this only works if you have a compiler which implements this feature from the new C++11 Standard) is if you say

    inline Window::Window(const TCHAR *windowName, const int x, const int y, const int width, const int height, const TCHAR *className) : Window(0, className, windowName, WS_OVERLAPPEDWINDOW, x, y, width, height, NULL, NULL, NULL, NULL) {};
    

    Another way would be to do what @aztaroth said: create a separate method and call it from both constructors (that works even with an older compiler).

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

Sidebar

Related Questions

I've been making an image uploader and I'm having a couple of issues. Code
I'm having some issues with my code. This is probably due to some design
I'm having some issues with some jQuery code, and I'm hoping and thinking that
I am having some issues with logging. After reviewing JBoss Seam source code, I
I'm making a blog API and am having some very strange issues when trying
Im having issues making the code below to work. Basically, I wanted to move
I'm having issues in my code due to the multiple representations that a same
I'm trying to learn C++ currently, but I'm having issues with the code below.
I'm having issues with a bit of code that I am writing in C#.
I am having issues with the following code which loads an SQLite database. -

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.