Jump to content

Recommended Posts

Posted (edited)

Hello!

I'm working on a new GUI builder that I have been making great progress on! 

A helpful forum member ioa747 answered a question I had which started me on my journey, and now I'd like to present to you an alpha version of the software. As of now only Form and Button works in a rudimentary fashion.

To run this, open Guiscape.au3 and go from there!

I'd love to hear your feedback and suggestions.

 🙂

Guiscape.zip

Downloads: 35

image.png.f0a31282732765c37632f3cb5e9d2b0c.png image.png.c9c8b3a80748ea96f9a41f64312af788.png

 

Edited by jaberwacky
10/28/25 Latest version
Posted
2 minutes ago, jaberwacky said:

Not sure what you mean about the new includes.

#include <Array.au3>
;~ #include <WindowsStylesConstants.au3>
#include <ButtonConstants.au3>
#include <GuiConstantsEx.au3>
#include <AutoItConstants.au3>
#include <ColorConstants.au3>
;~ #include <WindowsSysColorConstants.au3>
#include <StructureConstants.au3>
#include <WinAPISysWin.au3>

 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted

Very pretty :)

Just FYI, the AutoitObject startup function is crashing for me when it is run as x64. I'm sure I've used it before at some point - but it would've likely been with the physical dll?? Can't really remember sorry, Its been a while!

Posted (edited)
11 hours ago, jpm said:

to be in sync with latest autoit release 3.3.18.0 and Au3Check

I update the #include

Cheers

For some reason this doesn't run for me. Says I'm missing a bunch of includes.  Seems like I'm definitely doing something wrong.

Edited by jaberwacky
Posted
12 hours ago, WildByDesign said:

It crashes for me as well on x64.

@jaberwacky Are you really running x86?

Attached is AutoItObject v1.2.8.3 which will run on 64-bit machines as well. I had this same crashing issue with AutoItObject on a Windows ACL project a while back.

AutoItObject.au3 144.4 kB · 7 downloads

I have an x64 but I think I went with use x86 when I installed AutoIt ... been awhile can't recall ...

  • jaberwacky changed the title to Guiscape -- A new GUI builder project!
Posted (edited)
7 hours ago, argumentum said:

If
#AutoIt3Wrapper_UseX64=y ; some people run 64bit by default
then I get
AutoIt3 ended. rc:-1073741819

Otherwise in 32 bit it looks good.

Thank you!  OK, something with AutoitObject ... I saw WildByDesigns post about it but I thought I fixed it by including the whole package.

Edited by jaberwacky
Posted
21 hours ago, WildByDesign said:

It crashes for me as well on x64.

@jaberwacky Are you really running x86?

Attached is AutoItObject v1.2.8.3 which will run on 64-bit machines as well. I had this same crashing issue with AutoItObject on a Windows ACL project a while back.

AutoItObject.au3 144.4 kB · 11 downloads

Nice! When I replace the autoitobject I was using with this version then x64 works too!

Posted

Apologies if I'm overstepping - but if its useful, this was something that I was playing with a little while back.  Click to place a button, then you can drag and resize it.

#include <guiConstants.au3>
#include <winapi.au3>
#include <misc.au3>
;~ #include <SendMessage.au3>

Global $hCursor_Cross = _WinAPI_LoadCursor(0, $IDC_CROSS)
Global $hGui = GUICreate("", 300, 200, 100, 100, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX))

Global $hBtnProc = DllCallbackRegister("btnProc", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr")
Global $pBtnProc = DllCallbackGetPtr($hBtnProc)
Global $hWndProc = DllCallbackRegister("WndProc", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr")
Global $pWndProc = DllCallbackGetPtr($hWndProc)

_WinAPI_SetWindowSubclass($hGui, $pWndProc, 1000)

GUISetState()

Local $iMsg
While WinExists($hGui)
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd

_WinAPI_RemoveWindowSubclass($hGui, $pWndProc, 1000)


Func WndProc($hWnd, $iMsg, $wParam, $lParam, $iIdSubclass, $dwRefData)
    Local $iRet

    Switch $iMsg

        Case $WM_SETCURSOR
            Local $iSrc = BitAND($lParam, 0xFFFF), $iEvent = BitShift($lParam, 16)
            If $iSrc = $HTCLIENT Then
                _WinAPI_SetCursor($hCursor_Cross)
                $iRet = 1
            Else
                $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
            EndIf

        Case $WM_LBUTTONDOWN
            Local $iX = BitAND($lParam, 0xFFFF), $iY = BitShift($lParam, 16)
            Local $idBtn = GUICtrlCreateButton("", $iX - 12, $iY - 12, 25, 25)
            _WinAPI_SetWindowSubclass(GUICtrlGetHandle($idBtn), $pBtnProc, $idBtn)
            $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)

        Case $WM_SIZE
            ;This prevents autoit's docking logic from moving controls around on window restore.
            $iRet = _WinAPI_DefWindowProcW($hWnd, $iMsg, $wParam, $lParam)

        Case Else
            $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)

    EndSwitch

    Return $iRet
EndFunc


Func btnProc($hWnd, $iMsg, $wParam, $lParam, $iIdSubclass, $dwRefData)
    Local $iRet

    Switch $iMsg

        Case $WM_NCHITTEST

            Local $aPoint[2] = [BitAND($lParam, 0xFFFF),  BitShift($lParam, 16)]
            ;Mouse coords can be negative on edge cases!
            If BitAND($aPoint[0], 0x8000) Then $aPoint[0] = BitOR(0xFFFF0000, $aPoint[0])
            If BitAND($aPoint[1], 0x8000) Then $aPoint[1] = BitOR(0xFFFF0000, $aPoint[1])

            Local $aPos = WinGetPos($hWnd), $iMar = 10

            $iRet = $HTCAPTION
            If $aPoint[0] - $aPos[0] < $iMar Then $iRet = $HTLEFT
            If $aPoint[0] - $aPos[0] > ($aPos[2] - $iMar) Then $iRet = $HTRIGHT

            If $aPoint[1] - $aPos[1] < $iMar Then
                Switch $iRet
                    Case $HTLEFT
                        $iRet = $HTTOPLEFT
                    Case $HTRIGHT
                        $iRet = $HTTOPRIGHT
                    Case Else
                        $iRet = $HTTOP
                EndSwitch

            ElseIf $aPoint[1] - $aPos[1] > ($aPos[3] - $iMar) Then
                Switch $iRet
                    Case $HTLEFT
                        $iRet = $HTBOTTOMLEFT
                    Case $HTRIGHT
                        $iRet = $HTBOTTOMRIGHT
                    Case Else
                        $iRet = $HTBOTTOM
                EndSwitch
            EndIf

            If $aPoint[0] < 0 Then $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
            If $aPoint[1] < 0 Then $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
            _WinAPI_RedrawWindow($hWnd)

        Case $WM_NCLBUTTONDBLCLK ;Prevent double-click maximizing in "caption"
            If $wParam <> $HTCAPTION Then $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)

        Case $WM_SETCURSOR
            Local $iSrc = BitAND($lParam, 0xFFFF), $iEvent = BitShift($lParam, 16)
            If $iSrc = $HTCAPTION And $iEvent = $WM_LBUTTONDOWN Then
                _WinAPI_SetCursor($hCursor_Cross)
                $iRet = 1
            Else
                $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
            EndIf

        Case Else
            $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)

    EndSwitch

    Return $iRet
EndFunc   ;==>btnProc
Posted (edited)
4 hours ago, MattyD said:

Apologies if I'm overstepping

Not at all! 

When I get back from work I'll look into this! Thank you!

 

Glancing over it, this is a fffffaaaarrrrr more elegant way than I've done in the past.

Edited by jaberwacky
Posted (edited)

No worries!

This one probably needs a tidy up - but here's a rough snappy-snappy version. 
If this is useful, I can probably just keep chipping away at it over the weekend if you'd like? - Just proof of concept things like click-to-select, or multi-select with shift & ctrl etc..

Edit: You need to drag out rectangles to create buttons in this example!

#include <guiConstants.au3>
#include <winapi.au3>

Global Const $MK_LBUTTON = 1
Global Const $iSnap = 15

Global $hCursor_Cross = _WinAPI_LoadCursor(0, $IDC_CROSS)
Global $hGui = GUICreate("", 300, 200, 100, 100, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX))

Global $hBtnProc = DllCallbackRegister("btnProc", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr")
Global $pBtnProc = DllCallbackGetPtr($hBtnProc)
Global $hWndProc = DllCallbackRegister("WndProc", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr")
Global $pWndProc = DllCallbackGetPtr($hWndProc)

_WinAPI_SetWindowSubclass($hGui, $pWndProc, 1000)

GUISetState()

Local $iMsg
While WinExists($hGui)
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd

_WinAPI_RemoveWindowSubclass($hGui, $pWndProc, 1000)

Func WndProc($hWnd, $iMsg, $wParam, $lParam, $iIdSubclass, $dwRefData)
    Local $iRet
    Local Static $bDrawRect, $tRect = DllStructCreate($tagRect)

    Switch $iMsg

        Case $WM_SETCURSOR
            Local $iSrc = BitAND($lParam, 0xFFFF), $iEvent = BitShift($lParam, 16)
            If $iSrc = $HTCLIENT Then
                _WinAPI_SetCursor($hCursor_Cross)
                $iRet = 1
            Else
                $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
            EndIf

        Case $WM_LBUTTONDOWN
            $tRect.Left = BitAND($lParam, 0xFFFF)
            $tRect.Top = BitShift($lParam, 16)

            $tRect.Left -= Mod($tRect.Left, $iSnap)
            $tRect.Top -= Mod($tRect.Top, $iSnap)

            $bDrawRect = True
            $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)

        Case $WM_MOUSEMOVE
;~          Local $iX = BitAND($lParam, 0xFFFF), $iY = BitShift($lParam, 16)

            If BitAND($wParam, $MK_LBUTTON) = $MK_LBUTTON Then
                _WinAPI_InvalidateRect($hWnd, $tRect, True)
                $tRect.Right = BitAND($lParam, 0xFFFF)
                $tRect.Bottom = BitShift($lParam, 16)
                $tRect.Right -= Mod($tRect.Right, $iSnap)
                $tRect.Bottom -= Mod($tRect.Bottom, $iSnap)

                _WinAPI_InvalidateRect($hWnd, $tRect, True)
                $iRet = 0
            Else
                $bDrawRect = False
                $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
            EndIf


        Case $WM_PAINT
            If $bDrawRect Then
                Local $tPaintStruct = $tagPAINTSTRUCT
                Local $hDC = _WinAPI_BeginPaint($hWnd, $tPaintStruct)
                Local $hPen = _WinAPI_CreatePen($PS_DOT, 1, _WinAPI_RGB(0, 0, 0))
                Local $hBrush = _WinAPI_GetStockObject($WHITE_BRUSH)
                _WinAPI_SelectObject($hDC, $hPen)
                _WinAPI_SelectObject($hDC, $hBrush)

                _WinAPI_Rectangle($hDC, $tRect)

                _WinAPI_DeleteObject($hPen)
                _WinAPI_DeleteObject($hBrush)
                _WinAPI_EndPaint($hWnd, $tPaintStruct)
                $iRet = 0
            Else
                $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
            EndIf

        Case $WM_LBUTTONUP
            $bDrawRect = False

            $tRect.Right = BitAND($lParam, 0xFFFF)
            $tRect.Bottom = BitShift($lParam, 16)
            $tRect.Right -= Mod($tRect.Right, $iSnap)
            $tRect.Bottom -= Mod($tRect.Bottom, $iSnap)

            _WinAPI_InvalidateRect($hWnd, $tRect, True)

            Local $idBtn = GUICtrlCreateButton("", _
                    ($tRect.Left < $tRect.Right) ? $tRect.Left : $tRect.Right, _
                    ($tRect.Top < $tRect.Bottom) ? $tRect.Top : $tRect.Bottom, _
                    Abs($tRect.Left - $tRect.Right), _
                    Abs($tRect.Top - $tRect.Bottom))
            _WinAPI_SetWindowSubclass(GUICtrlGetHandle($idBtn), $pBtnProc, $idBtn)

            $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)

        Case $WM_SIZE
            ;This prevents autoit's docking logic from moving controls around on window restore.
            $iRet = _WinAPI_DefWindowProcW($hWnd, $iMsg, $wParam, $lParam)

        Case Else
            $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)

    EndSwitch

    Return $iRet
EndFunc   ;==>WndProc


Func btnProc($hWnd, $iMsg, $wParam, $lParam, $iIdSubclass, $dwRefData)
    Local $iRet
    Local Static $iXOffset, $iYOffset

    Switch $iMsg

        Case $WM_NCHITTEST

            Local $aPoint[2] = [BitAND($lParam, 0xFFFF), BitShift($lParam, 16)]
            ;Mouse coords can be negative on edge cases!
            If BitAND($aPoint[0], 0x8000) Then $aPoint[0] = BitOR(0xFFFF0000, $aPoint[0])
            If BitAND($aPoint[1], 0x8000) Then $aPoint[1] = BitOR(0xFFFF0000, $aPoint[1])

            Local $aPos = WinGetPos($hWnd), $iMar = 10

            $iRet = $HTCAPTION
            If $aPoint[0] - $aPos[0] < $iMar Then $iRet = $HTLEFT
            If $aPoint[0] - $aPos[0] > ($aPos[2] - $iMar) Then $iRet = $HTRIGHT

            If $aPoint[1] - $aPos[1] < $iMar Then
                Switch $iRet
                    Case $HTLEFT
                        $iRet = $HTTOPLEFT
                    Case $HTRIGHT
                        $iRet = $HTTOPRIGHT
                    Case Else
                        $iRet = $HTTOP
                EndSwitch

            ElseIf $aPoint[1] - $aPos[1] > ($aPos[3] - $iMar) Then
                Switch $iRet
                    Case $HTLEFT
                        $iRet = $HTBOTTOMLEFT
                    Case $HTRIGHT
                        $iRet = $HTBOTTOMRIGHT
                    Case Else
                        $iRet = $HTBOTTOM
                EndSwitch
            EndIf

            If $aPoint[0] < 0 Then $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
            If $aPoint[1] < 0 Then $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
            _WinAPI_RedrawWindow($hWnd)

        Case $WM_NCLBUTTONDBLCLK ;Prevent double-click maximizing in "caption"
            If $wParam <> $HTCAPTION Then $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)

        Case $WM_SIZING
            Local $tRect = DllStructCreate($tagRect, $lParam)
            Local $tRect2 = _WinAPI_GetWindowRect($hWnd)

            $tRect.Left += Mod($tRect2.Left - $tRect.Left, $iSnap)
            $tRect.Top += Mod($tRect2.Top - $tRect.Top, $iSnap)
            $tRect.Right += Mod($tRect2.Right - $tRect.Right, $iSnap)
            $tRect.Bottom += Mod($tRect2.Bottom - $tRect.Bottom, $iSnap)
            $iRet = True

        Case $WM_MOVING
            Local $tRect = DllStructCreate($tagRect, $lParam)
            Local $tRect2 = _WinAPI_GetWindowRect($hWnd)

            $iXOffset += $tRect.Left - $tRect2.Left
            $iYOffset += $tRect.Top - $tRect2.Top
            Local $iSnapH = Floor($iXOffset / $iSnap) * $iSnap
            Local $iSnapV = Floor($iYOffset / $iSnap) * $iSnap
            $iXOffset -= $iSnapH
            $iYOffset -= $iSnapV

            $tRect.Left = $tRect2.Left + $iSnapH
            $tRect.Right = $tRect2.Right + $iSnapH
            $tRect.Top = $tRect2.Top + $iSnapV
            $tRect.Bottom = $tRect2.Bottom + $iSnapV

            $iRet = 0

        Case $WM_EXITSIZEMOVE
            $iXOffset = 0
            $iYOffset = 0
            $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)

        Case $WM_SETCURSOR
            Local $iSrc = BitAND($lParam, 0xFFFF), $iEvent = BitShift($lParam, 16)
            If $iSrc = $HTCAPTION And $iEvent = $WM_LBUTTONDOWN Then
                _WinAPI_SetCursor($hCursor_Cross)
                $iRet = 1
            Else
                $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
            EndIf

        Case Else
            $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)

    EndSwitch

    Return $iRet
EndFunc   ;==>btnProc
Edited by MattyD

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...