- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个关于 ATL(C++) VS2010 的项目。我创建了一个对话框类。有两个按钮,想要添加文本框之类的东西。我读到负责此组件 CEdit。
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT1);
<强>1。但无处引用资源声明 IDC_EDIT1。
<强>2。有必要连接 afxwin.h。我在顶部的 stdafx.h 中插入了库。
它给我一个错误:
Building MFC application with /MD[d] (CRT dll version) requires MFC
shared dll version. Please #define _AFXDLL or do not use /MD[d]
然后我得到一个错误:
#error directive: WINDOWS.H already included. MFC apps must not #include
我删除了所有对WINDOWS.H的引用,但错误依旧。
有没有不使用CEdit的解决方案。
CWindow textBox(GetDlgItem(IDC_EDIT1));
textBox.SetWindowTextW(L"hello");
但问题依然存在。 作为指定 IDC_EDIT1 的资源?总的来说,应该具体说明的地方,如前所述,有没有例子。我找不到任何东西。可能是因为我的英语不好。
我在Resource.h中添加
#define IDC_EDIT1 113
在 .rc 文件中我有两个按钮:
DEFPUSHBUTTON "OK",IDOK,209,179,50,14
PUSHBUTTON "Cancel",IDCANCEL,263,179,50,14
如何在文件.rc 中添加我的IDC_EDIT1?
???? "text",IDC_EDIT1,263,179,50,14
最佳答案
根据 stackoverflow How to get text from CEdit control CEdit 不是 Microsoft 标准 ATL 的一部分,而是一个 Windows Template Library (WTL) extension .
看来 listview
和 treeview
通用控件确实具有 Microsoft 的 ATL 支持。
从您提到的错误来看,听起来您正在将 MFC 组件连同解决方案中的 MFC 相关属性一起拉入您的构建中。您需要检查您是否只在构建中使用 ATL 包含、属性和库。检查您的标准包含文件 stdafx.h
正在使用 ATL 包含。
这里是一些要考虑的源代码。这是我使用 ATL 所做的一个示例应用程序,它显示一个简单的对话框,其中有一个 ListView 控件,其中两列显示来自 Windows 注册表中的键的数据。该对话框允许用户双击 listview
的特定行。控件,然后它获取与字符串值键关联的值,并允许编辑字符串值值。
我正在使用 wchar_t
和 std::wstring
来保存我的文本数据,因为 Windows API 都是宽字符。
.rc 文件包含以下对话框模板。我使用 Visual Studio 的资源 View 中提供的标准对话框设计工具将控件放在对话框上并修改它们的属性。我还使用对话框设计工具为按钮单击和其他事件添加事件处理程序。该工具会将事件处理框架添加到源文件并更新消息映射。
IDD_PROVDIALOG DIALOGEX 0, 0, 224, 209
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Provision control"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,167,7,50,16
PUSHBUTTON "Cancel",IDCANCEL,167,26,50,16
CONTROL "",IDC_LIST1,"SysListView32",LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,154,155
EDITTEXT IDC_EDIT_PROP,7,179,154,23,ES_MULTILINE | ES_AUTOHSCROLL
PUSHBUTTON "Save",IDC_BUTTON_SAVE,179,180,38,22
END
listview
填写对话框的内容并将对话框呈现给用户。然后我有以下两个事件处理程序。第一个事件处理程序用于单击“保存”按钮时。第二个事件处理程序用于用户双击 listview
的一行,实际上是第一列。控制。
数据存储在 ATL 简单 map 中,当创建对话框时,我们提供指向 map 的指针。所以对话框有一个指向注册表数据的指针 CSimpleMap <std::wstring, std::wstring> *m_RegistryData;
这是保存按钮单击事件处理程序,它从编辑控件中提取文本并更新数据映射。更新数据映射后,我们告诉 listview
self 更新。
LRESULT CProvDialog::OnBnClickedButtonSave(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled)
{
CWindow pEdit = GetDlgItem (IDC_EDIT_PROP);
int iTextSize = pEdit.GetWindowTextLength ();
if (iTextSize > 0 && m_EditKey.length () > 0) {
wchar_t myText[128];
pEdit.GetWindowText(myText, 127);
m_RegistryData->SetAt (m_EditKey, myText);
m_EditKey.clear(); // clear the key area since we have done an update
pEdit.SetWindowText (L""); // clear the edit box before returning for user feedback.
CWindow pListView = GetDlgItem(IDC_LIST1); // Get the listview control window handle
pListView.RedrawWindow(NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
}
bHandled = TRUE;
return 1;
}
此处要完成的是 listview
中双击的处理程序控制。这会进行基本的健全性检查以确保双击有效,然后使用双击行的行号,这是一个从零开始的值,我们从 map 数据结构的相应行中提取键和值。我们保存 key 以便稍后进行更新,并将与 key 关联的值放入编辑框中。
使用reinterpret_cast
来自使用 Microsoft MSDN 库示例中的示例。关于 reinterpret_cast
的讨论参见计算器 When to use reinterpret_cast?
LRESULT CProvDialog::OnNMDblclkList1(int idCtrl, LPNMHDR pNMHDR, BOOL & bHandled)
{
// Handle a double click in the listview control.
// "The iItem, iSubItem, and ptAction members of this
// structure [NMITEMACTIVATE] contain information about the item."
LPNMITEMACTIVATE plvdi = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
if (plvdi->iItem >= 0) {
// we have a valid listview row number so lets update our edit box
CWindow pEdit = GetDlgItem (IDC_EDIT_PROP);
pEdit.SetWindowText (m_RegistryData->GetValueAt(plvdi->iItem).c_str());
m_EditKey = m_RegistryData->GetKeyAt(plvdi->iItem);
}
bHandled = TRUE;
return 1;
}
作为旁注,这里有一些允许显示多列 listview
所需的源代码.该控件需要打开详细信息 View ,因此为了确保启用多列 View ,我在对话框及其组件的初始化过程中使用了以下代码。
// First of all lets make sure that the listview is in Details or Report style.
// If the control is not in Details or Report style then even though we add columns
// only the first column will be displayed. Multiple columns only available in Details view.
ULONG ulWinStyle = pListView.GetWindowLong (GWL_STYLE);
ulWinStyle |= LVS_REPORT;
pListView.SetWindowLong (GWL_STYLE, ulWinStyle);
listview
控件由对话框初始化中的以下源代码创建。我们正在使用 LPSTR_TEXTCALLBACK
以及 NMLVDISPINFOW
的处理程序消息填充 listview
控制。
// Initialize LVITEM members that are common to all items.
LVITEM lvI = {0};
lvI.pszText = LPSTR_TEXTCALLBACK; // Sends an LVN_GETDISPINFO message.
lvI.mask = LVIF_TEXT | LVIF_STATE | LVCF_SUBITEM;
lvI.stateMask = 0;
lvI.state = 0;
// Initialize LVITEM members that are different for each item.
int iCount = m_RegistryData->GetSize();
for (int index = 0; index < iCount; index++)
{
// Insert the item row with the first column into the list.
lvI.iItem = index;
lvI.iSubItem = 0;
if (ListView_InsertItem (pListView.m_hWnd, &lvI) != -1) {
// insert the second column into the listview.
lvI.iSubItem = 1;
ListView_SetItem (pListView.m_hWnd, &lvI);
}
}
关于c++ - 在 CAxDialogImpl 中使用 ATL CEdit 将编辑框添加到 ATL 对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31250201/
我添加了编辑按钮 self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButto
我试图在运行时“干净地”更改 UIBarButtonItem 文本,以便可以切换编辑/完成模式。然而,每次我在运行时更改 title 属性时,动画看起来都很笨拙。我正在寻找模拟联系人应用程序中“编辑/
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
我想更改 INI 文件中的一些值。不幸的是,我在 2 个不同的部分有键,它们共享相同的名称但需要不同的值。我的代码使用 Get-IniContent函数来自 PsIni . 示例 INI 文件: [P
是否有通知或委托(delegate)方法可用于检测表格 View 何时进入编辑状态? 我想要做的是检测表正在编辑,然后显示一个额外的行,上面写着“添加新项目”或类似的东西。 我尝试在加载 View C
例如,我试图从 svg 读取样式块,我可以获取类型但不能获取字符串。 $svgTemplate = new SimpleXMLElement($_POST['SvgTemplateImport']);
我可以使用 self.navigationItem.leftBarButtonItem = self.editButtonItem; 通过按下导航面板上的编辑按钮让 UITableViewContro
我正在使用markitup!作为 Markdown 编辑器( example )。 目前,我需要按预览按钮(绿色勾号)来显示预览面板。 我希望自动显示预览 - 我怎样才能实现这一点? 最佳答案 我没有
我的处境非常糟糕。我丢失了源代码,客户需要在应用程序中进行一些更改。想想一个编辑程序集的例子:Test.dll,然后添加代码行,最后重新编译它 所以我的问题是: -可以这样做吗? -如果可能的话,什么
我使用了一些 JavaScript 来通过按钮更改段落元素的内容。它工作正常,但我还想让按钮控制标题和附图。给我指明正确的方向吗? 这是我用来更改段落的代码 .... 谢谢! 最佳答案 尝试将 Ja
是否有任何 Emacs lisp 插件可以让我轻松地在 yaml 文件中编辑或输入数据。 例如: --- sample yaml file ---Name : Addr :City :State:Zi
新手Java问题,我确定已经解决了,但是在任何地方都找不到解决方案:( 我想使用这里包含的java程序http://sourceforge.net/projects/ant-tibco/files/
在我的网页中,我使用了 gridview。在这个 GridView 中,它显示了一组用户信息。我刚刚从智能标签菜单中添加了一个按钮。我的要求是当我点击每个用户对应的按钮时,它会重定向到另一个页面并显示
我想在没有任何框架的情况下直接在 JS 中编辑一个 SVG 文件。 基本上我有一个 SVG 主文件,其中应该包含一些子 SVG。 我已经在 Ajax 中检索了这些子项的内容,但我想将它们插入到 SVG
我有我的 ViewModel,我有我的 Controller 可以从 ViewModel 正确显示,但是我不确定如何使 ViewModel 可编辑,以便将编辑后的数据发送回模型。我只想编辑 Order
我不确定我的做法是否正确。 IplImage *dog_1 = cvCreateImage(cvGetSize(oriImg), oriImg->depth, oriImg->nChannels);
我有一个创建二维码的网络服务器。在此过程中,我得到一个 BarcodeQRCode 对象,我可以从中获取图像 (.getImage())。 我不确定如何将这张图片发回给客户。我不想将它保存在文件中,而
已编辑:我的第一个问题解决了,但又出现了另一个问题,只提供了一个用户 ID。这是修改后的代码的屏幕截图。 回到表格,用户将按下编辑按钮,这样他就可以编辑问题并给出适当的操作.. 我的上表代码是这样的:
据我了解,我无法通过重新启动服务器来清除 MySQL 查询缓存。 每次运行 sql 时,我都试图获得与第一个代码块类似的结果 1-这是在重新启动 Apache 和 MySQL 之前(第一次使用这些查询
我正在创建一个页面来搜索项目,然后能够编辑/更新它。当它只返回一个结果时我能够做到这一点,但当它给我多个结果时我只能编辑最后一项。下面是我的代码: ....... $dj =$_POST[djnum]
我是一名优秀的程序员,十分优秀!