#Need help creating a window

11 messages · Page 1 of 1 (latest)

woeful field
#

I am trying to create a window in c++ and I have a few errors in my script. I have no idea how to use the win32 api. Any ideas what i did wrong?

#include <iostream>
#include <windows.h>

void NewWindow(HINSTANCE hInstance, WindowProc, nCmdShow){
    // Register the window class.
    const wchar_t CLASS_NAME[]  = L"Sample Window Class";

    WNDCLASS wc = { };

    wc.lpfnWndProc   = WindowProc;
    wc.hInstance     = hInstance;
    wc.lpszClassName = CLASS_NAME;

    RegisterClass(&wc);

// Create the window.

    HWND hwnd = CreateWindowEx(
    0,                              // Optional window styles.
    CLASS_NAME,                     // Window class
    L"Learn to Program Windows",    // Window text
    WS_OVERLAPPEDWINDOW,            // Window style

    // Size and position
    CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,

    NULL,       // Parent window    
    NULL,       // Menu
    hInstance,  // Instance handle
    NULL        // Additional application data
    );

if (hwnd == NULL)
{
    return 0;
}

ShowWindow(hwnd, nCmdShow);
}
flat voidBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

hollow fable
#

I'm gonna suggest not writing WinAPI directly and instead using GLFW, SDL, or SFML

woeful field
#

why is that?

hollow fable
#

WinAPI is not beginner friendly. Those other three libraries are suited towards games and do a lot of the hard work for you. In addition, there's a lot more tutorials and such on them

#

Plus, let's say you want to go use Linux or Mac. You'd have to completely rewrite your windowing. GLFW, SDL, and SFML handle it for ya

woeful field
#

yikes i see your point 💀

woeful field
#

I need help setting up glfw. Every time i try to add a path to my include path i run into an error.

woeful field
#

how do i do this without having all this in the project?

woeful field
# patent void what error?

Cannot find: c:/Users/usr/OneDrive/MakeCraft/"C:/glfw-3.3.9.bin.WIN64/glfw-3.3.9.bin.WIN64/lib-vc2022/glfw3.lib"