Results 1 to 11 of 11

Thread: How to make a form in twinBASIC, with a minimize button, with BorderStyle = 1 or 3

  1. #1

    Thread Starter
    Hyperactive Member HackerVlad's Avatar
    Join Date
    Nov 2023
    Posts
    427

    How to make a form in twinBASIC, with a minimize button, with BorderStyle = 1 or 3

    I very often create projects on VB6 where they do not allow the user to change the size of the form, but at the same time I make it possible to minimize the form.

    This is such a simple thing that doesn't work in Twin Basic, which disappointed me very much. If you set BorderStyle = 1 and at the same time set MinButton = True, the minimizing button does not appear, unlike the vb6 project.

    Why is this happening in Twin Basic? Help me understand and fix this.
    Last edited by HackerVlad; Dec 6th, 2024 at 09:59 AM.

  2. #2
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,626

    Re: How to make a form in twinBASIC, with a minimize button, with BorderStyle = 1 or

    Known bug; temp fix,in Form_Load

    Code:
            Dim dwStyle As WindowStyles = CLng(GetWindowLong(Me.hWnd, GWL_STYLE))
            dwStyle = dwStyle Or WS_MINIMIZEBOX
            SetWindowLong Me.hWnd, GWL_STYLE, dwStyle

  3. #3

    Thread Starter
    Hyperactive Member HackerVlad's Avatar
    Join Date
    Nov 2023
    Posts
    427

    Re: How to make a form in twinBASIC, with a minimize button, with BorderStyle = 1 or

    "WindowStyles" emphasizes and does not find such

  4. #4

    Thread Starter
    Hyperactive Member HackerVlad's Avatar
    Join Date
    Nov 2023
    Posts
    427

    Re: How to make a form in twinBASIC, with a minimize button, with BorderStyle = 1 or

    I rewrote it like this and it worked for me.
    Code:
            Dim dwStyle As Long = CLng(GetWindowLong(Me.hWnd, GWL_STYLE))
            dwStyle = dwStyle Or WS_MINIMIZEBOX
            SetWindowLong Me.hWnd, GWL_STYLE, dwStyle

  5. #5

    Thread Starter
    Hyperactive Member HackerVlad's Avatar
    Join Date
    Nov 2023
    Posts
    427

    Re: How to make a form in twinBASIC, with a minimize button, with BorderStyle = 1 or

    Full program code:

    Code:
    Class Form1
        Private Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongW" ( _
            ByVal hWnd As Long, _
            ByVal nIndex As Long) As Long
        Private Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongW" ( _
            ByVal hWnd As Long, _
            ByVal nIndex As Long, _
            ByVal dwNewLong As Long) As Long
        
        Private Const WS_MINIMIZEBOX = &H20000
        Private Const GWL_STYLE = -16
        
        Private Sub Form_Load()
            Dim dwStyle As Long = CLng(GetWindowLong(Me.hWnd, GWL_STYLE))
            dwStyle = dwStyle Or WS_MINIMIZEBOX
            SetWindowLong Me.hWnd, GWL_STYLE, dwStyle
        End Sub
    End Class

  6. #6
    Hyperactive Member
    Join Date
    Dec 2020
    Posts
    258

    Smile Re: How to make a form in twinBASIC, with a minimize button, with BorderStyle = 1 or

    This is such a simple thing that doesn't work in Twin Basic, which disappointed me very much
    I deeply regret the trauma caused by this oversight. Rest assured, this has already been fixed in the upcoming release.

  7. #7
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,787

    Re: How to make a form in twinBASIC, with a minimize button, with BorderStyle = 1 or

    Boo Hoo! Vlad the misery guts. There used to be a Vlad the Impaler who was much more frightening to upset.

    Vlad, if TB does not do something in particular, first of all look at the issues list on github and see if your problem is already known, don't let it disappoint you as there are bigger things in the world to worry about.

    Secondly, if a feature is missing from TwinBasic, then it is to be 'expected'. It is Beta grade software and we should only really be using TB to test and report our findings. If it works for you, then all well and good but otherwise do understand the concept of 'beta'.

    Your job Vlad is to raise bugs on github and not complain about them.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  8. #8
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,625

    Re: How to make a form in twinBASIC, with a minimize button, with BorderStyle = 1 or

    Quote Originally Posted by WaynePhillipsEA View Post
    I deeply regret the trauma caused by this oversight. Rest assured, this has already been fixed in the upcoming release.
    At long last! Please don't keep users disappointed for too much, please. Is this a BETA software or what? :-))

    cheers,
    </wqw>

  9. #9
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,626

    Re: How to make a form in twinBASIC, with a minimize button, with BorderStyle = 1 or

    Quote Originally Posted by HackerVlad View Post
    Full program code:

    Code:
    Class Form1
        Private Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongW" ( _
            ByVal hWnd As Long, _
            ByVal nIndex As Long) As Long
        Private Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongW" ( _
            ByVal hWnd As Long, _
            ByVal nIndex As Long, _
            ByVal dwNewLong As Long) As Long
        
        Private Const WS_MINIMIZEBOX = &H20000
        Private Const GWL_STYLE = -16
        
        Private Sub Form_Load()
            Dim dwStyle As Long = CLng(GetWindowLong(Me.hWnd, GWL_STYLE))
            dwStyle = dwStyle Or WS_MINIMIZEBOX
            SetWindowLong Me.hWnd, GWL_STYLE, dwStyle
        End Sub
    End Class
    See I don't like having to find all the API declares and individually copy and paste them every time for everything, so wrote code using WinDevLib... no more Windows API declares!

    And also your declares are specific only to your code and are wrong for x64 because hWnd should be LongPtr, but even after fixing that, not good as generic defs for those functions for all uses so you'd potentially need entirely different versions for other code- hope it's in a different module. On x64 Get and Set WindowLong should be aliased to _WindowLongPtr, which is why there's a CLng() around GWL. WDL resolves this transparently and automatically with the same aliasing setup as the SDK.

    That's why it's good to use WDL to avoid x64 mistakes too since I've re-done everything from scratch to restore 64bit types.


  10. #10

    Thread Starter
    Hyperactive Member HackerVlad's Avatar
    Join Date
    Nov 2023
    Posts
    427

    Re: How to make a form in twinBASIC, with a minimize button, with BorderStyle = 1 or

    Thanks)))

  11. #11

    Thread Starter
    Hyperactive Member HackerVlad's Avatar
    Join Date
    Nov 2023
    Posts
    427

    Re: How to make a form in twinBASIC, with a minimize button, with BorderStyle = 1 or

    WaynePhillipsEA, thank you so much for fixing this error. I have now downloaded the new version and was pleasantly surprised that this error has already been fixed. Thank you so much for what you are doing, I am incredibly grateful to you.

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