c++;进度条字幕样式不起作用 我尝试在C++中制作进度条,它成功地设置了位置,但是当我试图使它成为MouQee时,总是会有错误< /P> #include <windows.h> #include <commctrl.h> #include <tchar.h> LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); HWND hWndButton; HWND hEdit; HWND hProgress; char finalName[25]; char name[10]; int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nCmdShow){ HWND hwnd; /* This is the handle for our window */ MSG messages; /* Here messages to the application are saved */ WNDCLASS wincl; /* Data structure for the windowclass */ ZeroMemory(&wincl, sizeof(WNDCLASS)); /* The Window structure */ wincl.hInstance = hInst; wincl.lpszClassName = "Window Class"; wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; /* Register the window class, and if it fails quit the program */ if (!RegisterClass (&wincl)) return 0; /* The class is registered, let's create the program*/ hwnd = CreateWindow ( "Window Class", /* Classname */ ("Code::Blocks Template Windows App"), /* Title Text */ WS_OVERLAPPEDWINDOW, /* default window */ 433, /* Windows decides the position */ 134, /* where the window ends up on the screen */ 500, /* The programs width */ 500, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ hInst, /* Program Instance handler */ NULL /* No Window Creation data */ ); /* Make the window visible on the screen */ ShowWindow (hwnd, nCmdShow); /* Run the message loop. It will run until GetMessage() returns 0 */ while (GetMessage (&messages, NULL, 0, 0)) { /* Translate virtual-key messages into character messages */ TranslateMessage(&messages); /* Send message to WindowProcedure */ DispatchMessage(&messages); UpdateWindow(hwnd); } return 1; } /* This function is called by the Windows function DispatchMessage() */ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) /* handle the messages */ { case WM_DESTROY: PostQuitMessage (wParam); /* send a WM_QUIT to the message queue */ exit(1); break; case WM_CREATE: UpdateWindow(hwnd); hWndButton = CreateWindow("BUTTON", "Press Me!", WS_TABSTOP|WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON, 0, 25, 100, 25, hwnd, (HMENU)1, NULL, NULL); hEdit = CreateWindow("EDIT", "Write your name!", WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_AUTOVSCROLL|ES_AUTOHSCROLL, 0, 0, 200, 25, hwnd, (HMENU)2, NULL, NULL); hProgress = CreateWindow(PROGRESS_CLASS, NULL, WS_CHILD|WS_VISIBLE|PBS_MARQUEE, 0, 100, 500, 20, hwnd, (HMENU)3, NULL, NULL); SendMessage(hProgress, PBM_SETMARQUEE, 1, 1000); UpdateWindow(hwnd); break; case WM_COMMAND: if(wParam == 1){ GetWindowText(hEdit, _T(name), 10); strcpy(finalName, "Hello, "); strcat(finalName, name); MessageBox(hwnd, (LPCSTR)finalName, "Your Name", MB_OK|MB_ICONINFORMATION); } break; default: /* for messages that we don't deal with */ return DefWindowProc (hwnd, message, wParam, lParam); } } #包括 #包括 #包括 LRESULT回调窗口过程(HWND、UINT、WPARAM、LPARAM); HWND HWND按钮; HWND-hEdit; HWND-hProgress; char finalName[25]; 字符名[10]; int-WINAPI WinMain(HINSTANCE-hInst、HINSTANCE-hPrevInst、LPSTR-lpCmd、int-nCmdShow){ 这是我们窗口的手柄*/ MSG messages;/*此处保存应用程序的消息*/ windowclass的WNDCLASS wincl;/*数据结构*/ ZeroMemory(&wincl,sizeof(WNDCLASS)); /*窗口结构*/ wincl.hInstance=hInst; wincl.lpszClassName=“窗口类”; wincl.lpfnWndProc=WindowProcedure;/*此函数由windows调用*/ wincl.hbrBackground=(HBRUSH)颜色背景; /*注册窗口类,如果失败,退出程序*/ if(!寄存器类(&wincl)) 返回0; /*类已注册,让我们创建程序*/ hwnd=CreateWindow( “窗口类”,/*类名称*/ (“代码::阻止模板Windows应用程序”),/*标题文本*/ WS_OVERLAPPEDWINDOW,/*默认窗口*/ 433、/*Windows决定位置*/ 134,/*窗口在屏幕上结束的位置*/ 500,/*程序宽度*/ 500,/*和高度(以像素为单位)*/ HWND_DESKTOP,/*该窗口是桌面的子窗口*/ 空,/*无菜单*/ hInst,/*程序实例处理程序*/ NULL/*无窗口创建数据*/ ); /*使窗口在屏幕上可见*/ 显示窗口(hwnd、nCmdShow); /*运行消息循环。它将一直运行,直到GetMessage()返回0*/ while(GetMessage(&messages,NULL,0,0)) { /*将虚拟密钥消息转换为字符消息*/ 翻译消息(和消息); /*向WindowProcedure发送消息*/ DispatchMessage(&messages); 更新窗口(hwnd); } 返回1; } /*此函数由Windows函数DispatchMessage()调用*/ LRESULT回调窗口过程(HWND HWND,UINT消息,WPARAM WPARAM,LPARAM LPARAM) { 开关(消息)/*处理消息*/ { 案例WM_销毁: PostQuitMessage(wParam);/*将WM_QUIT发送到消息队列*/ 出口(1); 打破 案例WM_创建: 更新窗口(hwnd); hWndButton=CreateWindow(“按钮”,“按我!”,WS|TABSTOP|WS|U VISIBLE|WS|U CHILD|BS|U DefButton,0,25,100,25,hwnd,(HMENU)1,NULL,NULL); hEdit=CreateWindow(“编辑”,“写下你的名字!”,WS|u CHILD | WS|u VISIBLE | ES|u MULTILINE | ES|u AUTOVSCROLL | ES|u AUTOHSCROLL,0,0,200,25,hwnd,(HMENU)2,NULL,NULL); hProgress=CreateWindow(进度类,空,WS_子级,WS_可见,PBS_字幕,0,100,500,20,hwnd,(menu)3,空,空); SendMessage(hProgress,PBM_SETMARQUEE,11000); 更新窗口(hwnd); 打破 case WM_命令: if(wParam==1){ GetWindowText(hEdit,名称,10); strcpy(最终名称,“你好,”); strcat(最终名称、名称); MessageBox(hwnd,(LPCSTR)最终名称,“您的姓名”,MB|U OK | MB|U图标信息); } 打破 默认值:/*用于我们不处理的邮件*/ 返回DefWindowProc(hwnd、message、wParam、lParam); } }

c++;进度条字幕样式不起作用 我尝试在C++中制作进度条,它成功地设置了位置,但是当我试图使它成为MouQee时,总是会有错误< /P> #include <windows.h> #include <commctrl.h> #include <tchar.h> LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); HWND hWndButton; HWND hEdit; HWND hProgress; char finalName[25]; char name[10]; int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nCmdShow){ HWND hwnd; /* This is the handle for our window */ MSG messages; /* Here messages to the application are saved */ WNDCLASS wincl; /* Data structure for the windowclass */ ZeroMemory(&wincl, sizeof(WNDCLASS)); /* The Window structure */ wincl.hInstance = hInst; wincl.lpszClassName = "Window Class"; wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; /* Register the window class, and if it fails quit the program */ if (!RegisterClass (&wincl)) return 0; /* The class is registered, let's create the program*/ hwnd = CreateWindow ( "Window Class", /* Classname */ ("Code::Blocks Template Windows App"), /* Title Text */ WS_OVERLAPPEDWINDOW, /* default window */ 433, /* Windows decides the position */ 134, /* where the window ends up on the screen */ 500, /* The programs width */ 500, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ hInst, /* Program Instance handler */ NULL /* No Window Creation data */ ); /* Make the window visible on the screen */ ShowWindow (hwnd, nCmdShow); /* Run the message loop. It will run until GetMessage() returns 0 */ while (GetMessage (&messages, NULL, 0, 0)) { /* Translate virtual-key messages into character messages */ TranslateMessage(&messages); /* Send message to WindowProcedure */ DispatchMessage(&messages); UpdateWindow(hwnd); } return 1; } /* This function is called by the Windows function DispatchMessage() */ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) /* handle the messages */ { case WM_DESTROY: PostQuitMessage (wParam); /* send a WM_QUIT to the message queue */ exit(1); break; case WM_CREATE: UpdateWindow(hwnd); hWndButton = CreateWindow("BUTTON", "Press Me!", WS_TABSTOP|WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON, 0, 25, 100, 25, hwnd, (HMENU)1, NULL, NULL); hEdit = CreateWindow("EDIT", "Write your name!", WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_AUTOVSCROLL|ES_AUTOHSCROLL, 0, 0, 200, 25, hwnd, (HMENU)2, NULL, NULL); hProgress = CreateWindow(PROGRESS_CLASS, NULL, WS_CHILD|WS_VISIBLE|PBS_MARQUEE, 0, 100, 500, 20, hwnd, (HMENU)3, NULL, NULL); SendMessage(hProgress, PBM_SETMARQUEE, 1, 1000); UpdateWindow(hwnd); break; case WM_COMMAND: if(wParam == 1){ GetWindowText(hEdit, _T(name), 10); strcpy(finalName, "Hello, "); strcat(finalName, name); MessageBox(hwnd, (LPCSTR)finalName, "Your Name", MB_OK|MB_ICONINFORMATION); } break; default: /* for messages that we don't deal with */ return DefWindowProc (hwnd, message, wParam, lParam); } } #包括 #包括 #包括 LRESULT回调窗口过程(HWND、UINT、WPARAM、LPARAM); HWND HWND按钮; HWND-hEdit; HWND-hProgress; char finalName[25]; 字符名[10]; int-WINAPI WinMain(HINSTANCE-hInst、HINSTANCE-hPrevInst、LPSTR-lpCmd、int-nCmdShow){ 这是我们窗口的手柄*/ MSG messages;/*此处保存应用程序的消息*/ windowclass的WNDCLASS wincl;/*数据结构*/ ZeroMemory(&wincl,sizeof(WNDCLASS)); /*窗口结构*/ wincl.hInstance=hInst; wincl.lpszClassName=“窗口类”; wincl.lpfnWndProc=WindowProcedure;/*此函数由windows调用*/ wincl.hbrBackground=(HBRUSH)颜色背景; /*注册窗口类,如果失败,退出程序*/ if(!寄存器类(&wincl)) 返回0; /*类已注册,让我们创建程序*/ hwnd=CreateWindow( “窗口类”,/*类名称*/ (“代码::阻止模板Windows应用程序”),/*标题文本*/ WS_OVERLAPPEDWINDOW,/*默认窗口*/ 433、/*Windows决定位置*/ 134,/*窗口在屏幕上结束的位置*/ 500,/*程序宽度*/ 500,/*和高度(以像素为单位)*/ HWND_DESKTOP,/*该窗口是桌面的子窗口*/ 空,/*无菜单*/ hInst,/*程序实例处理程序*/ NULL/*无窗口创建数据*/ ); /*使窗口在屏幕上可见*/ 显示窗口(hwnd、nCmdShow); /*运行消息循环。它将一直运行,直到GetMessage()返回0*/ while(GetMessage(&messages,NULL,0,0)) { /*将虚拟密钥消息转换为字符消息*/ 翻译消息(和消息); /*向WindowProcedure发送消息*/ DispatchMessage(&messages); 更新窗口(hwnd); } 返回1; } /*此函数由Windows函数DispatchMessage()调用*/ LRESULT回调窗口过程(HWND HWND,UINT消息,WPARAM WPARAM,LPARAM LPARAM) { 开关(消息)/*处理消息*/ { 案例WM_销毁: PostQuitMessage(wParam);/*将WM_QUIT发送到消息队列*/ 出口(1); 打破 案例WM_创建: 更新窗口(hwnd); hWndButton=CreateWindow(“按钮”,“按我!”,WS|TABSTOP|WS|U VISIBLE|WS|U CHILD|BS|U DefButton,0,25,100,25,hwnd,(HMENU)1,NULL,NULL); hEdit=CreateWindow(“编辑”,“写下你的名字!”,WS|u CHILD | WS|u VISIBLE | ES|u MULTILINE | ES|u AUTOVSCROLL | ES|u AUTOHSCROLL,0,0,200,25,hwnd,(HMENU)2,NULL,NULL); hProgress=CreateWindow(进度类,空,WS_子级,WS_可见,PBS_字幕,0,100,500,20,hwnd,(menu)3,空,空); SendMessage(hProgress,PBM_SETMARQUEE,11000); 更新窗口(hwnd); 打破 case WM_命令: if(wParam==1){ GetWindowText(hEdit,名称,10); strcpy(最终名称,“你好,”); strcat(最终名称、名称); MessageBox(hwnd,(LPCSTR)最终名称,“您的姓名”,MB|U OK | MB|U图标信息); } 打破 默认值:/*用于我们不处理的邮件*/ 返回DefWindowProc(hwnd、message、wParam、lParam); } },c++,winapi,progress-bar,marquee,C++,Winapi,Progress Bar,Marquee,说PBS_MARQUEE和PBM_SETMARQUEE没有在该范围内定义,虽然我包含了commctrl.h头文件,但问题是什么呢???MARQUEE模式对于Windows XP来说是新的,所以您必须将NTDDI_VERSION定义为至少NTDDI_WINXP以包含这些常量。有关更多信息,请参阅。该代码适用于me@Axalo我认为这是一个相关的东西,但我不能理解这是关于什么,从PBS_字幕下的注释部分我怀疑,因为这是一个编译错误。那么你认为呢@Axalo我认为问题来自其他方面,但我不知道是什么问题

说PBS_MARQUEE和PBM_SETMARQUEE没有在该范围内定义,虽然我包含了commctrl.h头文件,但问题是什么呢???

MARQUEE模式对于Windows XP来说是新的,所以您必须将
NTDDI_VERSION
定义为至少
NTDDI_WINXP
以包含这些常量。有关更多信息,请参阅。

该代码适用于me@Axalo我认为这是一个相关的东西,但我不能理解这是关于什么,从PBS_字幕下的注释部分我怀疑,因为这是一个编译错误。那么你认为呢@Axalo我认为问题来自其他方面,但我不知道是什么问题。#定义NTDDI#U版本NTDDI#U WINXP,但仍然是相同的错误没有更改