none
How can i get the position and size of Minimize, Maximize buttons in UWP? RRS feed

  • Question

  • I want to get the position and size of Minimize, Maximize buttons. I use WM_GETTITLEBARINFOEX to get the button infos. I found that it can work correctly for non-UWP e.g. Notepad. But for UWP e.g. Skype or Microsoft Store, the position and size returned are always zero. I paste my code below. So how can i get the position and size of Minimize, Maximize buttons in UWP? I am using Win10.

    HWND hWnd;
    hWnd = FindWindow(0, _T("Microsoft Store"));
    //hWnd = FindWindow(0, _T("Skype"));
    //hWnd = FindWindow(_T("Notepad"), 0);
    TITLEBARINFOEX titlebarInfo = { 0 };
    titlebarInfo.cbSize = sizeof(titlebarInfo);

    int ret = SendMessage(hWnd, WM_GETTITLEBARINFOEX, 0, (LPARAM)&titlebarInfo);
    if (ret == 0) {
    int error = ::GetLastError();
    MessageBox(NULL, _T("failed"), _T("find"), MB_OK);
    }
    else {
    MessageBox(NULL, _T("suceed"), _T("find"), MB_OK);
    }



    Monday, July 15, 2019 7:04 AM

Answers

  • Hi,

    No, I'm sorry to say that this is by design. UWP apps could not get the button position on the title bar.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Lorence Wang Wednesday, July 17, 2019 9:14 AM
    Tuesday, July 16, 2019 3:21 AM
    Moderator

All replies

  • Hi,

    This forum is about c++ development. For your case which is more related to UWP, I will help you move thread to UWP forum for better support.

    Best Regards,

    Jeanine Zhang

    Monday, July 15, 2019 7:37 AM
  • Hi,

    No, there is not way to do that. 

    May I ask a question? Why do you want to get the buttons?

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, July 15, 2019 7:41 AM
    Moderator
  • Hi,

    So why does the api not work for UWP? Why are the position and size zero? Is it a bug for UWP?

    I need the button position. When user mouse hover the button, i need show some kind of tip.

    Best Regards,

    Lei

    Monday, July 15, 2019 10:43 AM
  • Hi,

    No, I'm sorry to say that this is by design. UWP apps could not get the button position on the title bar.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Lorence Wang Wednesday, July 17, 2019 9:14 AM
    Tuesday, July 16, 2019 3:21 AM
    Moderator