以下是C++/WinAPI中的示例,您可以如何在設置對話框中設置/取消設置VIDEO INPUT
引腳。此代碼假定,該複選框是主對話框的子元素;可能會出現這種情況,當它們嵌套在選項卡控件「自定義設置」中時,所以在這種情況下,您首先需要找到該選項卡。
#include <windows.h>
#include <string>
#include <vector>
#include <map>
#include <iostream>
int main(int, char **)
{
// Find the dialog
HWND hwnd = FindWindowA(NULL, "%Your settings dialog caption%");
if (hwnd == NULL)
{
std::cerr << "cannot find settings dialog" << std::endl;
return 1;
}
std::map<std::string, HWND> options;
// Get first dialog element
HWND h = GetWindow(hwnd, GW_CHILD);
char caption[250];
std::vector<std::string> inputs{
"1/HDMI",
"2/DVI-D",
"3/COMPONENT",
"DVI",
"4/VGA",
"SOG",
"5/SDI",
"6/COMPOSITE",
"7/S-VIDEO",
"8/AUTO"
};
while (h != NULL)
{
// Get element text
if (GetWindowTextA(h, caption, 250))
{
std::string scaption(caption);
// Check the text, if it's in the list of the option, put it into map.
if (std::find(inputs.begin(), inputs.end(), scaption) != inputs.end())
{
options[caption] = h;
}
}
h = GetWindow(h, GW_HWNDNEXT);
}
// Check the 4/VGA option.
SendMessageA(options["4/VGA"], BM_CLICK, 0, 0);
return 0;
}
你的問題是什麼? – eyllanesc
我正在尋找一種方法來讀取視頻捕獲設備的交叉開關對話框的所有輸入引腳,並設置/取消設置所需的引腳。我需要一種方法來做到這一點 – Tarek