1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| #include <iostream>
#include <Windows.h>
using namespace std;
int main()
{
static LPCTSTR szWindowClass = TEXT("CalcFrame");
HWND calc = FindWindow(szWindowClass, NULL);
static LPCTSTR szWindowClass2 = TEXT("Notepad");
HWND notepad = FindWindow(szWindowClass2, NULL);
static LPCTSTR szWindowClass3 = TEXT("Desktop");
HWND desk = FindWindow(szWindowClass3, NULL);
cout << "desk : " << desk << endl;
cout << "calc : " << calc << endl;
cout << "notepad : " << notepad << endl;
cout << "parent calc : " << GetParent(calc) << endl;
cout << "GetWindow(calc, GW_OWNER) : " << GetWindow(calc, GW_OWNER) << endl;
cout << "GetAncestor(calc, GA_PARENT) : " << GetAncestor(calc, GA_PARENT) << endl;
cout << "parent notepad : " << GetParent(notepad) << endl;
cout << "GetWindow(notepad, GW_OWNER) : " << GetWindow(notepad, GW_OWNER) << endl;
cout << "GetAncestor(notepad, GA_PARENT) : " << GetAncestor(notepad, GA_PARENT) << endl;
cout << "------------" << endl;
HWND res = SetParent(notepad, calc);
cout << "res (SetParent(notepad, calc) : " << res << endl;
cout << "parent notepad : " << GetParent(notepad) << endl;
cout << "GetWindow(notepad, GW_OWNER) : " << GetWindow(notepad, GW_OWNER) << endl;
cout << "GetAncestor(notepad, GA_PARENT) : " << GetAncestor(notepad, GA_PARENT) << endl;
cout << "IsChild(calc, notepad) : " << IsChild(calc, notepad) << endl;
cout << "------------" << endl;
HWND newRes = SetParent(notepad, desk);
cout << "newRes (SetParent(notepad, desk) : " << newRes << endl;
cout << "GetAncestor(notepad, GA_PARENT) : " << GetAncestor(notepad, GA_PARENT) << endl;
return 0;
} |
Partager