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

The Archive Base Latest Questions

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

I am facing a very odd problem. Can any one tell me what is

  • 0

I am facing a very odd problem. Can any one tell me what is wrong with the following code-:

#include <Windows.h>

LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);

char szWinName[]="MyWin";

int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
                   LPSTR lpszArgs, int nWinMode)
{
    HWND hwnd;
    MSG msg;
    WNDCLASSEX wndclass;

    wndclass.cbSize=sizeof(WNDCLASSEX);

    wndclass.hInstance=hThisInst;
    wndclass.lpszClassName=szWinName;
    wndclass.lpfnWndProc=WindowFunc;
    wndclass.style=0;

    wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION)
    wndclass.hIconSm=NULL;
    wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);

    wndclass.lpszMenuName=NULL;
    wndclass.cbClsExtra=0;
    wndclass.cbWndExtra=0;

    wndclass.hbrBackground=(HBRUSH) GetStockObject(LTGRAY_BRUSH);

    if(!RegisterClassEx(&wndclass)) return 0;

    hwnd=CreateWindow(
        szWinName,
        "Hello World",
        WS_OVERLAPPED,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        500,
        500,
        NULL,
        NULL,
        hThisInst,
        NULL
        );

    ShowWindow(hwnd, nWinMode);
    UpdateWindow(hwnd);

    while(GetMessage(&msg, NULL, 0, 0)>0)
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.wParam;

}

LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wparam, 
                            LPARAM lparam)
{
    switch(message){
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        default:
            return DefWindowProc(hwnd,message,wparam,lparam);
    }
    return 0;
}

I am getting the following window-:
Output of the above code

As you can see there is no system menu. I do not know why this is happening. But if I replace the above code with the following code it seems to work just fine-:

#include<windows.h>

LRESULT CALLBACK WinProc(HWND,UINT,WPARAM,LPARAM); 

char szWinName[]="Main Window";

int WINAPI WinMain(HINSTANCE thisInst,HINSTANCE prevInst,
                             LPSTR lpCmdArgs, int nMode){

  HWND hwnd;
  MSG msg;
  WNDCLASSEX wndclass;

  wndclass.cbSize=sizeof(WNDCLASSEX);

  wndclass.hInstance=thisInst;
  wndclass.lpszClassName=szWinName;
  wndclass.lpfnWndProc=WinProc;
  wndclass.style=0;

  wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION)
  wndclass.hIconSm=NULL;
  wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);

  wndclass.lpszMenuName=NULL;
  wndclass.cbClsExtra=0;
  wndclass.cbWndExtra=0;

  wndclass.hbrBackground=(HBRUSH)GetStockObject(LTGRAY_BRUSH);

  if(!RegisterClassEx(&wndclass)) return 0;

  hwnd=CreateWindow( szWinName,
                     "Hello World",
                     WS_OVERLAPPEDWINDOW,
                     CW_USEDEFAULT,
                     CW_USEDEFAULT,
                     500,
                     500,
                     NULL,
                     NULL,
                     thisInst,
                     NULL
  );

  ShowWindow(hwnd,nMode);
  UpdateWindow(hwnd);

  while(GetMessage(&msg,NULL,0,0))
  {
    TranslateMessage(&msg);                                  
    DispatchMessage(&msg);  
}
    return msg.wParam;

}

    LRESULT CALLBACK WinProc(HWND hWnd, UINT message,
                              WPARAM wparam, LPARAM lparam){

    switch(message){
                case WM_DESTROY:
                     PostQuitMessage(0);
                     break;
                default:
                return DefWindowProc(hWnd, message, wparam, lparam);
                }
    return 0;
}                    

Please can someone tell me what I doing wrong in the first code segment I have tried everything and not been able to find what is wrong with it. I am using a normal Win32 Project in Visual Studio 2008 Professional Edition. If anyone wants I can mail the project to them to test it out for themselves. A quick reply would be appreciated. Thank You.

  • 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-01T21:13:02+00:00Added an answer on June 1, 2026 at 9:13 pm

    In the bottom code segment you use WS_OVERLAPPEDWINDOW as a window style, which is what gives you the system menu. The first code segment only has WS_OVERLAPPED, which only gives you the title bar and border.

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

Sidebar

Related Questions

I'm facing a apparently very strange problem (I must be doing something wrong, just
I am facing a very silly problem with my code for buttons in the
I am facing a really very interesting problem with string. My code is: Dim
I am writing a very basic web spider in java.I am facing one problem,
I am facing a very basic problem. Some time small things can take your
I am facing very strange problem. After debugging from my side, I thought to
I am facing a very strange problem where the same loop keeps giving me
In my 2nd ASP.NET MVC project I'm facing a very weird problem: when I
Im facing the following problem: I want to integrate the mercurial hash into my
Im facing following problem I have created mentioned condition, but when I choose y

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.