为了创建一个窗口,您需要与操作系统上当前存在的任何窗口系统进行交互。如果窗口管理器在内核空间中运行(如 Windows 中的情况),则这将需要系统调用,或者用户空间窗口管理器(如 X)需要某种进程间通信。要从头开始创建窗口,您需要了解这些窗口管理器的工作原理以及它们使用的协议。就 X 而言,找到有关该协议如何工作的资源应该不会太难。对于 Windows,您唯一的选择可能是使用 API,因为窗口管理器的内部结构是专有的。
In order to create a window you'll need to interface with whatever windowing system is currently present on your operating system. This will either require system calls if the window manager runs in kernel space (as is the case in Windows) or some sort of interprocess communication for user space window managers (like X). To create the window from scratch, you'll need to read up on how these window managers work and what protocols they use. In the case of X, it shouldn't be too hard to find resources on how the protocol works. In the case of Windows, your only option might be to use the API, since the internals of the window manager are proprietary.
您可以尝试仔细阅读 MenuetOS 的源代码 - 我相信它完全是用汇编语言编写的,并且有一个 GUI。当然,如果您尝试编写一个在 Windows、Linux 等上运行的程序,这将不起作用。但是如果您想避免所有外部库,包括与 Windows 的接口,则必须在裸机上运行。
You could try perusing the source code to MenuetOS - I believe it's written entirely in assembly and it has a GUI. Of course, this won't work if you're trying to write a program that runs on Windows, Linux, etc. But if you want to avoid all external libraries, including interfacing with Windows, you will have to run on the bare metal.
发布评论
评论(4)
为了创建一个窗口,您需要与操作系统上当前存在的任何窗口系统进行交互。如果窗口管理器在内核空间中运行(如 Windows 中的情况),则这将需要系统调用,或者用户空间窗口管理器(如 X)需要某种进程间通信。要从头开始创建窗口,您需要了解这些窗口管理器的工作原理以及它们使用的协议。就 X 而言,找到有关该协议如何工作的资源应该不会太难。对于 Windows,您唯一的选择可能是使用 API,因为窗口管理器的内部结构是专有的。
In order to create a window you'll need to interface with whatever windowing system is currently present on your operating system. This will either require system calls if the window manager runs in kernel space (as is the case in Windows) or some sort of interprocess communication for user space window managers (like X). To create the window from scratch, you'll need to read up on how these window managers work and what protocols they use. In the case of X, it shouldn't be too hard to find resources on how the protocol works. In the case of Windows, your only option might be to use the API, since the internals of the window manager are proprietary.
您可以尝试仔细阅读 MenuetOS 的源代码 - 我相信它完全是用汇编语言编写的,并且有一个 GUI。当然,如果您尝试编写一个在 Windows、Linux 等上运行的程序,这将不起作用。但是如果您想避免所有外部库,包括与 Windows 的接口,则必须在裸机上运行。
You could try perusing the source code to MenuetOS - I believe it's written entirely in assembly and it has a GUI. Of course, this won't work if you're trying to write a program that runs on Windows, Linux, etc. But if you want to avoid all external libraries, including interfacing with Windows, you will have to run on the bare metal.
如果你足够疯狂,想在汇编中做这件事,请继续安装 masm32 ,它可以像 Windows 一样执行基本的 GUI /消息框等
If you are crazy enough to do this thing in assembly go ahead and install masm32 , it can do basic GUIs like windows/messageboxes etc.
您可以通过调用“CreateWindowEx”Win32 API 在 Windows 上“从头开始”创建一个窗口。
You create a window "from scratch" on windows, by calling the "CreateWindowEx" Win32 API.