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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:40:41+00:00 2026-05-27T14:40:41+00:00

i am compiling a simple Win32 api program but the problem is that it

  • 0

i am compiling a simple Win32 api program but the problem is that it compiles fine but no window appears. I checked the process in taskmanager and the program is there but doesn’t show up a window. I am using CodeBlocks IDE 10.05 with GNU GCC compiler under windows 7 32-bit.
I know there is a similar question here on stackoverflow but the solution given there was a’==’ instead of ‘=’. here is the code:

#include <windows.h>
#include <tchar.h>

/* Global Vars */
HINSTANCE hInst;
HWND wndHandle;
int winWidth = 640;
int winHeight = 480;

//func prototypes
bool InitWindow(HINSTANCE hInst, int width, int height);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
/********************************************************
* WINMAIN FUNCTION
*********************************************************/
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
hInst = hInstance;

//app window

if (!InitWindow(hInst, winWidth, winHeight))
{
    return false;
}

// MESSAGE LOOP
MSG msg = {0};
while (WM_QUIT != msg.message)
{
    //window messages
    while(PeekMessage(&msg, NULL,0,0, PM_REMOVE) == TRUE)
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    //additional logic
}
return (int)msg.wParam;
 }

/*******************************************************************
* InitWindow
* Inits and creates and main app window
* Inputs - application instance - HINSTANCE
           Window width - int
           Window height - int
* Outputs - true if successful, false if failed - bool
*******************************************************************/
bool InitWindow(HINSTANCE hInstance, int width, int height)
{
// Register class
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style          = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc    = WndProc;
wcex.cbClsExtra     = 0;
wcex.cbWndExtra     = 0;
wcex.hInstance      = hInstance;
wcex.hIcon          = 0;
wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground  = (HBRUSH) + (COLOR_WINDOW+1);
wcex.lpszMenuName   = NULL;
wcex.lpszClassName  = TEXT("DirectX 10 Example");
wcex.hIconSm        = 0;

if(!RegisterClassEx(&wcex))
{
  return false;
}

// resize window
RECT rect = { 0, 0, width, height };
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, false);

// create the window from the class above
wndHandle = CreateWindow(   TEXT("DX 10 Example"),
                            TEXT("DX10 WINDOW"),
                            WS_OVERLAPPEDWINDOW,
                            CW_USEDEFAULT,
                            CW_USEDEFAULT,
                            rect.right - rect.left,
                            rect.bottom - rect.top,
                            0,
                            0,
                            hInstance,
                            0);
if(wndHandle == 0)
{
    return false;
}
ShowWindow(wndHandle, SW_SHOW);
UpdateWindow(wndHandle);
return true;
}
/*******************************************************************
* WndProc
* The main window procedure for the application
* Inputs - application window handle - HWND
           message sent to the window - UINT
           wParam of the message being sent - WPARAM
           lParam of the message being sent - LPARAM
* Outputs - LRESULT
*******************************************************************/
 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
   switch (message)
{
    // Allow the user to press the escape key to end the application
    case WM_KEYDOWN:
        switch(wParam)
        {
            // Check if the user hit the escape key
            case VK_ESCAPE:
              PostQuitMessage(0);
            break;
        }
    break;

        // The user hit the close button, close the application
    case WM_DESTROY:
            PostQuitMessage(0);
    break;
    }

    return DefWindowProc(hWnd, message, wParam, lParam);
}
  • 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-05-27T14:40:41+00:00Added an answer on May 27, 2026 at 2:40 pm

    you have
    wcex.lpszClassName = TEXT(“DirectX 10 Example”);

    and

    wndHandle = CreateWindow( TEXT(“DX 10 Example”),
    TEXT(“DX10 WINDOW”),

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

Sidebar

Related Questions

I'm coding a simple SDL program with VC10. The problem that I am having
I'm working on a very simple flash but having problem compiling to the swf
I'm compiling a simple program written in C and I'm using Eclipse as an
Receiving alot of these messages when compiling which is making compiling a simple program
I want to start a simple program when windows start but I don't want
I have a problem with compiling a basic and really simple example of PyGTK
I am compiling the following simple program with g++-4.6.1 --std=c++0x : #include <algorithm> struct
I'm trying to make a simple fibonacci calculator in C but when compiling gcc
I tried compiling and running this simple code but it's throwing error - (void)doSomething
After compiling a simple C++ project using Visual Studio 2008 on vista, everything runs

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.