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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:17:07+00:00 2026-06-13T21:17:07+00:00

I have an application in win32 that has a top menu in its main

  • 0

I have an application in win32 that has a top menu in its main window, this menu has 2 options with submenus in each.

The problem is..after some clicks on its options it suddenly freezes. The rest of the application keeps responding normally, but when i click on the menu options, the buttons go down like pressed and the submenus just doesnt appear, and i need to restart the application or it wont work anymore.

I thik it is something related to memory allocation, maybe i need to free some allocation, but since im new to this kind of programming, i can say just looking at it.

Some code..i think its in the window procedure where i manipulate the WM_COMMAND that theres something wrong:

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{

int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;

HMENU hMenubar = CreateMenu();
HMENU hFile = CreateMenu();
HMENU hEDIT = CreateMenu();
HMENU hHelp = CreateMenu();     



switch (message)
{


case WM_COMMAND:
    wmId    = LOWORD(wParam);
    wmEvent = HIWORD(wParam);

    // Parse the menu selections:

    switch (wmId)
    {
    case ID_FILE_DIALOG2:
        DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG2), hWnd, Add);
        break;

    case ID_FILE_TESTE:

    Check();

    break;

    case ID_FILE_DIALOG1:
        DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, Conf);
        break;

    case ID_OPEN:
        Open();
        break;

    case IDM_ABOUT:
        DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
        break;

    case IDM_EXIT:
        DestroyWindow(hWnd);
        PostQuitMessage(0);
        break;

    default:
        return DefWindowProc(hWnd, message, wParam, lParam);

    }
    break;

case WM_PAINT:

    break;

case WM_CLOSE:
    DestroyWindow(hWnd);
        PostQuitMessage(0);
break;

case WM_DESTROY:

break;

default: 
    return DefWindowProc(hWnd, message, wParam, lParam);

}
return 0;
}
  • 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-13T21:17:08+00:00Added an answer on June 13, 2026 at 9:17 pm

    You are probably running out of handles as you’re creating the menus each time WndProc is called. This function gets called a lot!

    Create the menus once during the app initialisation.

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

Sidebar

Related Questions

I have a window that has a menu, a toolbar at the top, and
I have an existing C++ win32 console app. This application contains a main program
I have a application that uses the Aero glass effect, so each pixel has
I have a Win32 GUI application that has several edit controls (plain old EDIT
I have developend a window application(Win32 API) in visual C++. I have to add
I have a Win32 C++ Application using a handful of third-Party DLLs that is
I have a Win32 application that includes an EXE, an ActiveX control (DLL) and
I have a very simple Win32 application that uses CAtlExeModuleT. The module simply creates
i have a native win32 c++ application which has a checkbox in it. I
I have a Unicode Win32 application that uses 3rd party libraries, some of which

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.