CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2021
    Posts
    3

    Post Resize the window to a button size

    Hello, i want be able to resize the whole window to a first button size on that button click. And restore it's original size on next click. I hope that there are some implementations of this kind of functionality, but didn't find it yet.
    Could someone share an example or describe the plan how to manage it nicely.

    I thought that i should dinamicaly create all other subcontrols and remove them from the grid on button click, to be able to shrink window size to first button only.
    Or maybe i can move all controls under the first button and make them invisible, so that only one that button was shown.

    Name:  2021-08-31_11-32-23.jpg
Views: 950
Size:  4.1 KB

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Resize the window to a button size

    I have no idea how it would be implemented in WPF, however, there is a set Win32 API functions ( https://docs.microsoft.com/en-us/win...2/api/winuser/ ) that could be used to do this:
    GetWindowRect
    MoveWindow (or/and SetWindowPos)
    ClientToScreen
    ScreenToClient
    Last edited by VictorN; September 8th, 2021 at 04:00 PM.
    Victor Nijegorodov

  3. #3
    Join Date
    Aug 2021
    Posts
    3

    Re: Resize the window to a button size

    Quote Originally Posted by VictorN View Post
    I have no idea how it would be implemented in WPF, however, there is a set Win32 API functions ( https://docs.microsoft.com/en-us/win...2/api/winuser/ ) that could be used to do this:
    GetWindowRect
    MoveWindow (or/and SetWindowPos)
    ClientToScreen
    ScreenToClient
    I created a panel with only button, so on a click - i show that panel. resize window from the LEFT side (it is ease, Window.Width = btn.Width) and than move window positon on window.Width - btn.Width to the RIGHT.
    So in fact i resize from the left size, but it looks like it is right side.

  4. #4
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Resize the window to a button size

    Quote Originally Posted by Polazhenko View Post
    I created a panel with only button, so on a click - i show that panel. resize window from the LEFT side (it is ease, Window.Width = btn.Width) and than move window positon on window.Width - btn.Width to the RIGHT.
    So in fact i resize from the left size, but it looks like it is right side.
    Did you try it without "move window positon on window.Width - btn.Width to the RIGHT"?
    Victor Nijegorodov

  5. #5
    Join Date
    Aug 2021
    Posts
    3

    Re: Resize the window to a button size

    Quote Originally Posted by VictorN View Post
    Did you try it without "move window positon on window.Width - btn.Width to the RIGHT"?
    i have no clue, how to resize, moving left side of the window, resize button should be the first from the right side.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured