简体   繁体   English

如何使用 C++ 使用下拉菜单制作简单的 GUI

[英]How to Make a Simple GUI with DropDown Menus with C++

I am really struggling how to make a window with three selections of options.我真的很努力如何制作一个带有三个选项的窗口。 I currently have a setup that uses a CFileDialog object and have successfully implemented two dropdown menus and multiple check items.我目前有一个使用CFileDialog对象的设置,并成功实现了两个下拉菜单和多个检查项。

What I want is to implement a pop up window that has the two drop down menus and the check boxes.我想要的是实现一个具有两个下拉菜单和复选框的弹出窗口。 If a certain item is selected in one of the dropdown menus then the file dialog is opened.如果在其中一个下拉菜单中选择了某个项目,则会打开文件对话框。

Currently I am trying to make a CWnd object and try to write code for it there.目前我正在尝试制作一个CWnd对象并尝试在那里为其编写代码。

    CWnd myWindow;

    BOOL VALUE = myWindow.Create(_T("DesktopApp"), _T("test"), WS_VISIBLE | WS_BORDER | WS_CAPTION,
        RECT{ 100,100,400,400 },
        myWindow.GetDesktopWindow(), 12);
    
    myWindow.ShowWindow(SW_SHOWNORMAL);
    

    if (VALUE == FALSE) {
        return 0;
    }

Every time I run this, it prematurely returns ( VALUE == FALSE ).每次我运行它时,它都会过早地返回( VALUE == FALSE )。 Did I do something wrong?我做错什么了吗? Is there a simpler way to create a window?有没有更简单的方法来创建窗口?

The first argument to CWnd::Create is the window class name. CWnd::Create的第一个参数是窗口类名。 A class with the requested name must have been registered before it can be created.必须先注册具有请求名称的类,然后才能创建它。

It is common to register an application local class for the application's main window.为应用程序的主窗口注册一个应用程序本地类是很常见的。 MFC provides a convenient wrapper function ( AfxRegisterWndClass ) to register a window class. MFC 提供了一个方便的包装函数( AfxRegisterWndClass )来注册一个窗口类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM