c++ - 窗口结构体赋值不匹配 不存在从 "UINT" 转换到 "_WNDCLASS" 的适当构造函数

 个信2502857367 发布于 2022-11-01 01:11

(小白)我想在自己的“命令行程序”进行到一定时候,创建一个蓝背景的窗口(之后用于画曲线)赋值就卡住了:

//状态机二
int state2th(int atypes2th)
{
    typedef struct _WNDCLASS {
        UINT style;                    //定义窗口的风格 
        WNDPROC lpfnWndProc;   //指向窗口过程函数的指针
        int cbClsExtra;                //为窗口类结构体,确定需要额外分配多少字符数的空间,默认为0
        int cbWndExtra;                //为实例窗口,确定需要额外分配多少字符数的空间,默认为0
        HANDLE hInstance;              //指向实例窗口的句柄
        HICON hIcon;                   //窗口的图标
        HCURSOR hCursor;               //窗口的光标
        HBRUSH hbrBackground;  //指向画刷的句柄
        LPCTSTR lpszMenuName;  //指向菜单名称的指针
        LPCTSTR lpszClassName;         //指向窗口名称的指针

    } WNDCLASS;
    WNDCLASS.style =UINT( CS_HREDRAW | CS_VREDRAW);

    return 0;
}

完整程序:


#include "stdafx.h"
#include
#include
#include
#include  //用到了time函数 
using namespace std;

 //声明用来处理消息的函数
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);  

//窗口类对象

//函数功能:产生一个窗口


//函数功能:产生随机数
int stochastic()
{
    int sto=0;//随机数
    srand((unsigned)time(NULL)); //用时间做种,每次产生随机数不一样
    sto= rand() % 4;  //产生0-3的随机数
    
    /*测试随机数生成的代码    
        int testone = 0;
        cout <> testone;
    */

    
    return sto;
}

//函数功能:让用户输入数字完成选择目标机型
int getinair_type(int atype)
{
    cout << "请输入数字选择目标类型"<> atype;
    while (atype > 4 || atype < 1)
    {
        cout << "输入有误,重新输入" << endl;
        system("cls");
        atype=getinair_type(atype);
    }
    return atype;

}

//函数功能:在随机状态下 完成对机型的赋值
int FUNCaircraft()
{
    int aircraft_type = 0;
    int stoc = stochastic();
    aircraft_type = stoc + 1;
    return aircraft_type;
}

//状态机一 
int stateone()
{
    int choice_model = 0;//choice_model代表用户选择是否完全随机 1是完全随机 2是指定目标类型
    int aircraft_typw = 0;//aircraft_typw代表飞行目标类型

    cout << "请输入数字代表想定生成方式" << endl << "1.完全随机    2.制定目标类型" << endl;
    cin >> choice_model;
    if (choice_model == 1)
    {
        cout << "选择完全随机"<>nextkey;

    /*  测试代码 没啥用
        int testone = 0;
        cin >> testone;
        if(testone==1)
    */
    
    state2th(airtp);
    while (1);
    return 0;
}

几个额外问题:

1.之后我还想继续在上面曲线,曲线上点的位置我已经想好怎么算了,用什么函数 或者 组件好用?GDI?
2.等我再搞几个这样的程序后,应该用c++,c#?还是其他的编,感觉win32根本跟不上了

1 个回答
  • 好吧 我很逗比的把标准的申明有粘了一遍

    2022-11-01 01:22 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有