提问人:Davide_24 提问时间:8/1/2022 最后编辑:Remy LebeauDavide_24 更新时间:8/1/2022 访问量:52
使用TASKDIALOG_BUTTON数组会导致 C2061
Using array of TASKDIALOG_BUTTON causes C2061
问:
我正在制作一个用于构造更高级消息框的函数。我希望能够将自定义按钮传递给函数。为此,我使用数组作为参数。唯一的问题是我遇到了一个错误,我不知道这意味着什么:TaskDialogIndirect()
TASKDIALOG_BUTTON
C2061 - 语法错误:标识符“TASKDIALOG_BUTTON”
我在互联网上找不到有关此确切问题的任何信息。
CMessageBox.hpp:
#pragma once
#include "Global.hpp"
struct TaskDialogData
{
int X;
int Y;
};
class CMessageBox
{
public:
static int MessageBoxPosL(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType, int X, int Y, PCWSTR Icon, TASKDIALOG_BUTTON CustomBtns[], TASKDIALOG_COMMON_BUTTON_FLAGS StandardBtns = NULL, TASKDIALOG_FLAGS flags = NULL);
};
CMessageBox.cpp:
#include "CMessageBox.hpp"
static HRESULT CALLBACK TaskDialogCallback(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LONG_PTR lpRefData)
{
if (msg == TDN_DIALOG_CONSTRUCTED) // This sets the position of the MessageBox
{
TaskDialogData* data = (TaskDialogData*)lpRefData;
SetWindowPos(hwnd, NULL, data->X, data->Y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
}
else if (msg == TDN_HYPERLINK_CLICKED) { // Opens all hyperlinks in default browser
LPCTSTR url = (LPCTSTR)lParam;
ShellExecute(NULL, _T("open"), url, NULL, NULL, SW_SHOW);
}
return S_OK;
}
int CMessageBox::MessageBoxPosL(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType, int X, int Y, PCWSTR Icon, TASKDIALOG_BUTTON CustomBtns[], TASKDIALOG_COMMON_BUTTON_FLAGS StandardBtns, TASKDIALOG_FLAGS flags)
{
TaskDialogData data;
data.X = X;
data.Y = Y;
TASKDIALOGCONFIG config = {};
config.cbSize = sizeof(config);
config.hwndParent = hWnd; // Parent window; SHOULD BE NORMALLY NULL!
config.pszWindowTitle = (PCWSTR)lpCaption;
config.pszContent = (PCWSTR)lpText;
config.pfCallback = &TaskDialogCallback; // Callback function
config.lpCallbackData = (LONG_PTR)&data; // Data sent to callback function
config.dwFlags = TDF_ENABLE_HYPERLINKS | flags;
config.dwCommonButtons = StandardBtns;
config.pButtons = CustomBtns;
config.cButtons = _ARRAYSIZE(CustomBtns);
config.pszMainIcon = Icon;
int button = 0;
TaskDialogIndirect(&config, &button, NULL, NULL);
return button; //This returns the Button that was clicked in the TaskDialog
}
答: 暂无答案
评论
(PCWSTR)
UNICODE
LPCTSTR
PCWSTR
UNICODE
LPCTSTR
LPCWSTR
TASKDIALOGCONFIG
LPCSTR
LPCTSTR