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

The Archive Base Latest Questions

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

I need to make a few programs in C and i cannot get the

  • 0

I need to make a few programs in C and i cannot get the window to work. Its come up with about 30 errors mostly saying ; is expected when there is one there, no storage class or type specifier, and declaration expected, not sure what these mean. I have looked at two turtorials and they both look extremely similar and mine looks the same, so not sure what these missing things are.

Heres my code

#include <windows.h>

LRESULT CALLBACK WindowFunc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
        case WM_CLOSE:
            DestroyWindow(hwnd);
        break;
        case WM_DESTROY:
            PostQuitMessage(0);
        break;
        default:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    return 0;
}

int WINAPI WinMain(HINSTANCE hThisInst, 
                         HINSTANCE hPrevInst, 
                         LPSTR lpszArgs, 
                         int nWinMode);

{
WNDCLASS wcls;
HWND hwnd;
MSG msg;

LPCWSTR szClassName = L"ThreadsProgram";
LPCWSTR szWinName = L"My Threads Program"

    //Register Class
  wcls.style         =0; 
  wcls.lpfnWndProc   =WindowFunc;
  wcls.cbClsExtra    =0;
  wcls.cbWndExtra    =0;
  wcls.hInstance     =hThisInst;
  wcls.hIcon         =LoadIcon(NULL, IDI_APPLICATION);
  wcls.hCursor       =LoadCurser(NULL, IDC_ARROW);
  wcls.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);
  wcls.lpszMenuName  =NULL;
  wcls.lpszClassName =szClassName;

      if(!RegisterClass(&wcls))
    {
        MessageBox(NULL, "Window Registration Failed!",
            MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }

//Make Window 
hwnd = CreateWindow(szClassName,
szWinName,
WS_OVERLAPPINGWINDOW,
100,
100,
400,
400,
HWND_DESKTOP,
NULL,
hThisInst,
NULL);

//Show Window

if(hwnd == NULL)
    {
        MessageBox(NULL, "Window Failed!",
            MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }

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

//Main Message Loop
while(GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return (int)msg.wParam;
}
  • 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-04T23:51:37+00:00Added an answer on June 4, 2026 at 11:51 pm

    A lot of typos there.

    1. semicolon after the WinMain

    2. MessageBox() function taking 3 instead of 4 params.

    3. LPWCSTR params

    4. ShowWindow() with nCmdShow doesn’t … show

    5. WS_OVERPLAPPEDWINDOW (not WS_OVERLAPPINGWINDOW)

    6. LoadCursor instread of LoadCurser

    Should work now. Next time type carefully

    #include <windows.h>
    
    LRESULT CALLBACK WindowFunc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
         switch(msg)
         {
             case WM_CLOSE: DestroyWindow(hwnd); break;
             case WM_DESTROY: PostQuitMessage(0); break;
             default: return DefWindowProc(hwnd, msg, wParam, lParam);
         }
         return 0;
    }
    
    int WINAPI WinMain(HINSTANCE hThisInst,  HINSTANCE hPrevInst,  LPSTR lpszArgs,  int nWinMode)
    {
        WNDCLASS wcls;
        HWND hwnd;
        MSG msg;
    
        LPCSTR szClassName = "ThreadsProgram";
        LPCSTR szWinName = "My Threads Program";
    
        //Register Class
        wcls.style         =0; 
        wcls.lpfnWndProc   =WindowFunc;
        wcls.cbClsExtra    =0;
        wcls.cbWndExtra    =0;
        wcls.hInstance     =hThisInst;
        wcls.hIcon         =LoadIcon(NULL, IDI_APPLICATION);
        wcls.hCursor       =LoadCursor(NULL, IDC_ARROW);
        wcls.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);
        wcls.lpszMenuName  =NULL;
        wcls.lpszClassName =szClassName;
    
         if(!RegisterClassA(&wcls))
        {
            MessageBoxA(NULL, 0, "Window Registration Failed!", MB_ICONEXCLAMATION | MB_OK);
            return 0;
        }
    
        //Make Window 
        hwnd = CreateWindowA(szClassName, szWinName,
           WS_OVERLAPPEDWINDOW,
           100, 100, 400, 400,
           HWND_DESKTOP,
           NULL, hThisInst, NULL);
    
        //Show Window
    
        if(hwnd == NULL)
        {
            MessageBoxA(NULL, 0, "Window Failed!", MB_ICONEXCLAMATION | MB_OK);
            return 0;
        }
    
        ShowWindow(hwnd, SW_SHOW/*nWinMode*/);
        UpdateWindow(hwnd);
    
        //Main Message Loop
        while(GetMessage(&msg, NULL, 0, 0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        return (int)msg.wParam;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to make a fake window.location = testCall call in order to generate
I have developed a few python programs that I want to make available online.
me need make settings language I've got: #define kMenuSettingsHeaderrus @Настройки #define kMenuSettingsHeadereng @Settings and
I just to need make sure I've got the PDO prepare statements correctly, will
I'm doing an project, where I need make an PageControl with 3 images. It's
I have some part of asynchronous code in my handlers, I need make this
Need to make a stored procedure that will do a simple search on a
I need to make a batch file that detects what drive and directory it
I need to make a request to an URL of my app, every 15
I need to make a server that recieves and sends single integers using tcp.

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.