Creating a splash screen in Visual Studio

LP 20 Reputation points
2023-10-26T20:19:35.98+00:00

Hello, I am a game and software developer. I am planning on making a game in C++ possibly with Java in it too. I was working on making a game launcher and I opened Photoshop to make a logo. I saw the splash screen-loading screen thing when I opened it up(For context: When you open Photoshop or other Adobe apps the window that pops up but is not recognized as a window) I wanted to try and make something like this that would work on windows and mac. If you have any suggestions, please help

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,103 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,323 questions
0 comments No comments
{count} votes

Accepted answer
  1. Minxin Yu 8,186 Reputation points Microsoft Vendor
    2023-10-27T06:14:40.82+00:00

    Hi, @LP

    For Windows project, you could set WS_EX_TOOLWINDOW style to achieve window that pops up but is not recognized as a window.

    Currently Q&A C++ does not support development for mac, and Visual Studio for mac does not have a C++ component. If you need mac solutions, please go to mac development related forums such as https://stackoverflow.com/questions/tagged/macos.
    User's image

    #include <windows.h>
    #include <tchar.h>
    
    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    {
        
        WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("MyWindowClass"), NULL };
        RegisterClassEx(&wc);
      
        HWND hwnd = CreateWindow(wc.lpszClassName, _T("My Window"), WS_OVERLAPPEDWINDOW, 100, 100, 640, 480, NULL, NULL, wc.hInstance, NULL);
    
       
        SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_TOOLWINDOW);
        ShowWindow(hwnd, SW_SHOW);
    
       
        MSG msg;
        while (GetMessage(&msg, NULL, 0, 0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    
        return 0;
    }
    
    LRESULT CALLBACK WndProc(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;
    }
    
    

    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful