pywebview icon indicating copy to clipboard operation
pywebview copied to clipboard

suggestion: Frameless Resize function (native). with demo.

Open DizzyduckAR opened this issue 3 years ago • 2 comments

demo was recorded on 4k with 300% zoom

explorer_ljJSnag00W

from ctypes import windll, Structure, c_long, byref

class POINT(Structure):
    _fields_ = [("x", c_long), ("y", c_long)]

### Get mouse X Y
def queryMousePosition():
    pt = POINT()
    windll.user32.GetCursorPos(byref(pt))
    return { "x": pt.x, "y": pt.y}

### calc window pos , size , mouse pos, mouse movement
def doresize(window):
    state_left =  windll.user32.GetKeyState(0x01)  # Left button down = 0 or 1. Button up = -127 or -128
    winWbefore=window.width
    winHbefore=window.height

    mouseactive=queryMousePosition()
    beforex= mouseactive['x']
    beforey=mouseactive['y']

    while True:
        a =  windll.user32.GetKeyState(0x01)
        if a != state_left:  # Button state changed
            state_left = a
            print(a)
            if a < 0:
                print('Left Button Pressed')
                break
            else:
                print('Left Button Released')
                break

        mouseactive=queryMousePosition()
        afterx= mouseactive['x']
        aftery=mouseactive['y']
        try:
            totalx=int(beforex)-int(afterx)
            totaly=int(beforey)-int(aftery)
        except:
            print('fail')
        if totalx > 0:
            changerx=winWbefore+(totalx*-1)
        else:
            changerx=winWbefore+(totalx*-1)        
        if totaly > 0:
            changerY=winHbefore+(totaly*-1)
        else:
            changerY=winHbefore+(totaly*-1)
       
        window.resize(changerx, changerY)
        time.sleep(0.01)

DizzyduckAR avatar Jul 30 '22 11:07 DizzyduckAR

I am not sure about this. Frameless windows are not resizable by default in Windows if I am not mistaken. Is this feature needed?

r0x0r avatar Aug 09 '22 07:08 r0x0r

if the Developer want to build custom app header (under Frameless=True) he will lose the ability to resize the target window. its a mini solution to provide resize handler for them. (while staying on native libs)

you will see the issue on all apps with webview and frameless.

not sure how much it is needed because i have no idea how many people use "Frameless" but if they do that's the way to resize :D

by the way. thank you for the amazing job you did on the project mate.

Demo custom app header handler Code_GX0fxZb0rv

DizzyduckAR avatar Aug 10 '22 08:08 DizzyduckAR

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Sep 10 '22 04:09 github-actions[bot]

The message to post on the issue when closing it. If none provided, will not comment when closing an issue.

github-actions[bot] avatar Sep 15 '22 04:09 github-actions[bot]

Thank you @DizzyduckAR for the solution :) Can plz help me with how to implement it?

MrLeafster avatar Oct 02 '22 00:10 MrLeafster

Thank you @DizzyduckAR for the solution :) Can plz help me with how to implement it?

I need help how to implement it too!!

Wehaveall avatar Jul 07 '23 16:07 Wehaveall