terrafx / terrafx.interop.windows

Interop bindings for Windows.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Where is WS_OVERLAPPEDWINDOW?

DeafMan1983 opened this issue · comments

Hello,

I searched WS_OVERLAPPEDWINDOW in TerraFX.Interop.Windows but I can't find ....

namespace DeafMan1983.Examples.WinAPI;

using TerraFX.Interop.Windows;
using static TerraFX.Interop.Windows.Windows;
using static TerraFX.Interop.Windows.WM;
using static TerraFX.Interop.Windows.WS;
using static TerraFX.Interop.Windows.SW;
using System.Runtime.InteropServices;

unsafe class Program
{
    static int Main(string[] args)
    {
        var hInstance = GetModuleHandleW(null);
        fixed (char* lpClassName = "Sample Window Class")
        fixed (char* lpWindowName = "Sample Window")
        {
            var windowClass = new WNDCLASSEXW
            {
                cbSize = (uint)sizeof(WNDCLASSEXW),
                lpfnWndProc = &WindowProc,
                hInstance = hInstance,
                lpszClassName = lpClassName
            };

            RegisterClassExW(&windowClass);

            HWND hwnd = CreateWindowExW(
                0,
                windowClass.lpszClassName,
                lpWindowName,
                WS_OVERLAPPEDWINDOW,
                CW_USEDEFAULT,
                CW_USEDEFAULT,
                CW_USEDEFAULT,
                CW_USEDEFAULT,
                HWND.NULL,                       // We have no parent window.
                HMENU.NULL,                      // We aren't using menus.
                hInstance,
                null
            );

            return ShowWindow(hwnd, SW_SHOWDEFAULT);
        }
    }

    [UnmanagedCallersOnly]
    static LRESULT WindowProc(HWND hWnd, uint message, WPARAM wParam, LPARAM lParam)
    {
        switch (message)
        {
            case WM_CREATE:
                ShowWindow(hWnd, SW_SHOW);
                return 0;
            case WM_DESTROY:
                DestroyWindow(hWnd);
                return 0;
            default:
                return DefWindowProcW(hWnd, message, wParam, lParam);
        }
    }

}

But I have error-underline:
image

Where do I find WS_OVERLAPPEDWINDOW?

Sorry I missed "S" indeed "WC" => "WS" Thanks!

Hmmmm Window can't show up? How do I fix if Window is still showing?

https://source.terrafx.dev/#TerraFX.Interop.Windows/Windows/um/WinUser/WS.cs,2a967835d0145f41

Simply, WS.WS_OVERLAPPEDWINDOW. If you using static TerraFX.Interop.Windows.WS; then you can access it simply as WS_OVERLAPPEDWINDOW

Check I have missed WC as WS that's why I have replaced it and I have problem with opening window. But why does window not show up if I already I tested on Windows 10 .

You don't have anything running the actual message loop (typically a loop which calls getmessage/peekmessage, translate message, and dispatch message until WM_QUIT is received)

Oh I see. Sorry I am beginner for WinAPI :/ I need move to Discussion

And where is struct or class with COLOR_WINDOW?

Thanks!