Skip to content

Commit

Permalink
Fixed "Could not get mainControlHandle" for some custom builds
Browse files Browse the repository at this point in the history
  • Loading branch information
uberhalit committed Feb 25, 2017
1 parent cb94e1e commit 0454486
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 51 deletions.
82 changes: 36 additions & 46 deletions CitraTouchControl/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,17 @@ private IntPtr GetKeyFromControl(string controlName)
if (citraMainControlHwnd == IntPtr.Zero)
{
citraMainControlHwnd = FindWindowEx(citraHwnd, IntPtr.Zero, "Qt5QWindowIcon", "centralwidgetWindow");
//citraMainControlHwnd = FindChildWindow(windowHandle, "Qt5QWindowIcon", "centralwidgetWindow");
//citraMainControlHwnd = FindChildWindow(windowHandle, "Qt5QWindowIcon", "GRenderWindowClassWindow");
//citraMainControlHwnd = FindChildWindow(windowHandle, "Qt5QWindowOwnDCIcon", null);
//citraMainControlHwnd = FindChildWindow(citraHwnd, IntPtr.Zero, "Qt5QWindowIcon", "centralwidgetWindow");
//citraMainControlHwnd = FindChildWindow(citraHwnd, IntPtr.Zero, "Qt5QWindowIcon", "GRenderWindowClassWindow");
if (citraMainControlHwnd == IntPtr.Zero)
{
MessageBox.Show(this, "ERROR: Could not get mainControlHandle!\nPlease try to restart Citra and this application.", "CitraTouchControl");
return key;
citraMainControlHwnd = FindChildWindow(citraHwnd, IntPtr.Zero, "Qt5QWindowOwnDCIcon", null);
//citraMainControlHwnd = FindChildWindow(citraHwnd, IntPtr.Zero, "Qt5QWindowOwnDCIcon", "Citra");
if (citraMainControlHwnd == IntPtr.Zero)
{
MessageBox.Show(this,"ERROR: Could not get mainControlHandle!\nPlease try to restart Citra and this application.", "CitraTouchControl");
return key;
}
}
}

Expand Down Expand Up @@ -363,6 +367,33 @@ internal static string GetProcessPath(Process process)
return MethodResult;
}

/// <summary>
/// Uses FindWindowEx() to recursively search for a child window with the given class and/or title,
/// starting after a specified child window.
/// If lpszClass is null, it will match any class name. It's not case-sensitive.
/// If lpszTitle is null, it will match any window title.
/// </summary>
public static IntPtr FindChildWindow(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszTitle)
{
// Try to find a match.
IntPtr hwnd = FindWindowEx(hwndParent, IntPtr.Zero, lpszClass, lpszTitle);
if (hwnd == IntPtr.Zero)
{
// Search inside the children.
IntPtr hwndChild = FindWindowEx(hwndParent, IntPtr.Zero, null, null);
while (hwndChild != IntPtr.Zero && hwnd == IntPtr.Zero)
{
hwnd = FindChildWindow(hwndChild, IntPtr.Zero, lpszClass, lpszTitle);
if (hwnd == IntPtr.Zero)
{
// If we didn't find it yet, check the next child.
hwndChild = FindWindowEx(hwndParent, hwndChild, null, null);
}
}
}
return hwnd;
}

#region IMPORTS

private const uint WM_KEYDOWN = 0x0100;
Expand Down Expand Up @@ -407,46 +438,5 @@ private struct RECT
}

#endregion

#region UNUSED

/*
/// <summary>
/// Uses FindWindowEx() to recursively search for a child window with the given class and/or title.
/// </summary>
public static IntPtr FindChildWindow(IntPtr hwndParent, string lpszClass, string lpszTitle)
{
return FindChildWindow(hwndParent, IntPtr.Zero, lpszClass, lpszTitle);
}
/// <summary>
/// Uses FindWindowEx() to recursively search for a child window with the given class and/or title,
/// starting after a specified child window.
/// If lpszClass is null, it will match any class name. It's not case-sensitive.
/// If lpszTitle is null, it will match any window title.
/// </summary>
public static IntPtr FindChildWindow(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszTitle)
{
// Try to find a match.
IntPtr hwnd = FindWindowEx(hwndParent, IntPtr.Zero, lpszClass, lpszTitle);
if (hwnd == IntPtr.Zero)
{
// Search inside the children.
IntPtr hwndChild = FindWindowEx(hwndParent, IntPtr.Zero, null, null);
while (hwndChild != IntPtr.Zero && hwnd == IntPtr.Zero)
{
hwnd = FindChildWindow(hwndChild, IntPtr.Zero, lpszClass, lpszTitle);
if (hwnd == IntPtr.Zero)
{
// If we didn't find it yet, check the next child.
hwndChild = FindWindowEx(hwndParent, hwndChild, null, null);
}
}
}
return hwnd;
}
*/

#endregion
}
}
6 changes: 2 additions & 4 deletions CitraTouchControl/MenuWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ private void bSave_Click(object sender, RoutedEventArgs e)
{
if (File.Exists(savePath))
{
var result = MessageBox.Show(this, "WARNING: Do you really wish to overwrite the last savegames?",
"CitraTouchControl", MessageBoxButton.YesNo);
var result = MessageBox.Show(this, "WARNING: Do you really wish to overwrite the last savegames?", "CitraTouchControl", MessageBoxButton.YesNo);
if (result == MessageBoxResult.No)
return;
File.Delete(savePath);
Expand All @@ -79,8 +78,7 @@ private void bLoad_Click(object sender, RoutedEventArgs e)
{
if (!File.Exists(savePath))
return;
var result = MessageBox.Show(this, "WARNING: Do you really wish to overwrite the current savegames?",
"CitraTouchControl", MessageBoxButton.YesNo);
var result = MessageBox.Show(this, "WARNING: Do you really wish to overwrite the current savegames?", "CitraTouchControl", MessageBoxButton.YesNo);
if (result == MessageBoxResult.No)
return;
try
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ It further features "savegame/bookmark replacement"; a very basic savestate syst
| Platform | App | Working | Information |
| ------------- | ------------- | ------------- | ------------- |
| Android | [Microsoft Remote Desktop Beta](https://play.google.com/store/apps/details?id=com.microsoft.rdc.android.beta) | **_Yes_** |
| Android | [TeamViewer](https://play.google.com/store/apps/details?id=com.teamviewer.teamviewer.market.mobile) | Yes | annoying swipe gestures, needs portrait (90° rotation) and resolution set on host-pc, distorted sound |
| Android | [AccessToGo RDP/Remote Desktop](https://play.google.com/store/apps/details?id=com.ericom.accesstogobyericom) | Yes | buggy, annoying touch-feedback, no network level auth
| Android | [Microsoft Remote Desktop](https://play.google.com/store/apps/details?id=com.microsoft.rdc.android) | no | no portrait mode |
| Android | [TeamViewer](https://play.google.com/store/apps/details?id=com.teamviewer.teamviewer.market.mobile) | no | no portrait mode, no scaling, distorted sound |
| Android | [RDP Remote Desktop aFreeRDP](https://play.google.com/store/apps/details?id=com.freerdp.afreerdp) | no | no (multi-)touch |
| Android | [RDP Remote Desktop Connection](https://play.google.com/store/apps/details?id=com.thinstuff.rdc) | no | no (multi-)touch |
| Android | [aRDP Pro: Secure RDP Client](https://play.google.com/store/apps/details?id=com.iiordanov.aRDP) | no | no (multi-)touch |
Expand Down

0 comments on commit 0454486

Please sign in to comment.