在VC++中,我使用EnumWindows(...),GetWindow(...)和GetWindowLong()来获取窗口列表并检查窗口是否是顶部窗口(没有其他窗口作为所有者),以及窗口是否是可见的(WS_VISIBLE).然而,虽然我的桌面只显示了5个窗口,但这个EnumWindows给了我50个窗口,多么有趣!任何Windows极客都请帮我澄清一下......
我目前正在尝试获取所有打开的窗口的列表并将它们存储在一个向量中。我一直在查看代码,以至于解决方案可能非常简单,但如果没有全局变量(我想避免),我似乎无法完成它。
这是代码:
#include "stdafx.h"
#include "json.h"
#include <algorithm>
using namespace std;
vector<string> vec;
BOOL CALLBACK speichereFenster(HWND hwnd, LPARAM substring){
const DWORD TITLE_SIZE = 1024;
TCHAR windowTitle[TITLE_SIZE];
GetWindowText(hwnd, windowTitle, TITLE_SIZE);
int length = ::GetWindowTextLength(hwnd);
wstring temp(&windowTitle[0]);
string title(temp.begin(), temp.end());
if (!IsWindowVisible(hwnd) || length == 0 || title == "Program Manager") {
return TRUE;
}
vec.push_back(title);
return TRUE;
}
int main() {
EnumWindows(speichereFenster, NULL);
cin.get();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我想将所有标题存储在向量中,但我不知道如何将向量传递到函数中...
谢谢!!!
我需要在Windows应用程序(Windows窗体)C#中显示已打开的窗体的列表。谁能告诉我如何存储打开的表单名称并显示它..我需要如下显示
例如
打开表格名称
怎么做。谁能帮我...