VC++:在文本框中插入文本,不重复
VC++: Insert text in textBox without repeat
我很难在textBox或RichtextBox中插入文本而不重复。
这是使用的代码:
#包括"windows.h"#pragma注释(lib,"user32")void actwnd(){wchar_t最后一个窗口[MAX_PATH];wchar_t当前窗口[MAX_PATH];HWND主窗口;mainwindow=GetForegroundWindow();GetWindowText(主窗口,当前窗口,sizeof(当前窗口));if(lastwindow==currentwindow){}其他的if(lastwindow!=currentwindow){strcpy((char*)lastwindow,(char*currentwindow);String^strNew=gcnew字符串(当前窗口);//String^wnd=gcnew字符串(interpret_cast(currentwindow));textBox1->Text+=strNew;}}//设置测试间隔1000msprivate:System::Void timer1_Tick(System::Object^sender,System::EventArgs^e){actwnd();}
如有任何帮助,将不胜感激
如果(lastwindow==currentwindow)不比较字符串,它会比较数组的地址,所以它们永远不会相等。使用wcscmp比较wchar_t数组。由于这些是wchar_t数组,因此使用strcpy复制它们也是无效的,strcpy仅用于char数组。请改用wcscpy。
相关文章:
- 如何从代码本身向 wxwidgets 中的文本控件插入字符?
- 如何在MFC中的静态文本控件上插入图标?
- 是否可以在原始字符串文本中插入转义序列?
- 如何在文本文件中间插入字符
- win32 c++ 我想在静态标签的文本之后直接插入一个 EDIT 控件
- 为什么插槽函数即使成功调用也无法插入文本
- 在文本文件的某些行和列上插入值
- 将文本文件插入2D矢量C
- 将文本文件单词插入 AVL
- 在文本文件中在特定行中插入线
- 读取大量文本/文本文件的更快方法?
- 将整数从文本文件插入到整数数组
- 使用 Qt - C++将文本插入标签/图像
- C++ 在文本文件中的特定字符后插入新行
- fputc在插入文本之前将第一行留空
- 将数据插入C 中的文本文件中
- 在Embarcadero Tools API中的光标位置插入文本
- QListWidget,插入换行符以获得较长的文本
- 在未格式化的文本文件中插入回车
- 检测 MFC 控件的宽度是否不足以容纳文本(文本将被截断)