gpt4 book ai didi

C++进度条选框样式不起作用

转载 作者:行者123 更新时间:2023-11-30 05:48:35 26 4
gpt4 key购买 nike

我试图用 C++ 制作进度条,它成功地设置了位置,但是当我试图让它成为字幕时,我总是出错

#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);
}

}

尽管我包含了 commctrl.h 头文件,但说 PBS_MARQUEE 和 PBM_SETMARQUEE 未在该范围内定义,这是什么问题?

最佳答案

选取框模式是 Windows XP 的新功能,因此您必须将 NTDDI_VERSION 定义为至少 NTDDI_WINXP 以包含这些常量。参见 Using the Windows Headers获取更多信息。

关于C++进度条选框样式不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28121446/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com