Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 308
» Latest member: Donaldvem
» Forum threads: 1,741
» Forum posts: 17,901

Full Statistics

Latest Threads
The QB64 IDE shell
Forum: Utilities
Last Post: JasonPag
09-16-2024, 05:37 PM
» Replies: 9
» Views: 762
Importance regarding Ches...
Forum: Utilities
Last Post: JasonPag
09-01-2024, 06:34 PM
» Replies: 0
» Views: 31
Chess and Analysis and En...
Forum: Utilities
Last Post: JasonPag
08-28-2024, 02:37 PM
» Replies: 0
» Views: 32
DAY 009:_PutImage
Forum: Keyword of the Day!
Last Post: grymmjack
09-02-2023, 02:57 PM
» Replies: 54
» Views: 2,034
Fall Banner Contest?
Forum: Site Suggestions
Last Post: grymmjack
08-31-2023, 11:50 PM
» Replies: 36
» Views: 1,261
ColorPicker - Function th...
Forum: Dav
Last Post: Dav
08-31-2023, 11:04 PM
» Replies: 3
» Views: 315
Goals(1) = New Tile()
Forum: Works in Progress
Last Post: RhoSigma
08-31-2023, 09:45 PM
» Replies: 3
» Views: 127
micro(A)v11
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:14 PM
» Replies: 90
» Views: 3,589
Updating The Single Most ...
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:13 PM
» Replies: 7
» Views: 254
QBJS Image Question
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 05:49 PM
» Replies: 5
» Views: 155

 
  QB64 0.8.1 - File call error message.
Posted by: Kernelpanic - 06-11-2022, 10:07 PM - Forum: General Discussion - Replies (2)

I downloaded and installed version 0.8.1 from Github. I already get an error message when I want to call up a BAS file, see screenshot. I can't get any further. One error message comes after the other.

In the picture you can see how I have it installed. There are no problems with V 2.0.2 and 0.7.1.


[Image: QB64-81-Fehler2022-06-11-22.jpg]

Print this item

  Announcing QB64 Phoenix Edition v0.8.2 Release!
Posted by: DSMan195276 - 06-11-2022, 05:35 PM - Forum: Announcements - Replies (21)

QB64 Phoenix Edition v0.8.2!
https://github.com/QB64-Phoenix-Edition/...tag/v0.8.2

Bug fixes
  - The

C++ Compiler Settings...
menu now opens correctly.

Full Changelog: https://github.com/QB64-Phoenix-Edition/...1...v0.8.2

Print this item

  InForm, a GUI toolkit for QB64
Posted by: mpgcan - 06-11-2022, 09:38 AM - Forum: General Discussion - Replies (12)

You will be pleased to know InForm is compatible with QB64 Phoenix Edition.
Although no longer maintained by Fellippe, it is worth downloading and having a play.

Download using this link:  https://github.com/FellippeHeitor/InForm...s/v1.3.zip
Wiki InForm reference : https://github.com/FellippeHeitor/InForm/wiki

Install (Instructions for Windows only):
1) Extract file v1.3.zip to any folder.
2) Copy the entire contents of this folder to your qb64 folder.

InForm is a Rapid Application Development tool for QB64. It allows you to create graphical user interfaces (GUIs) for your applications.

InForm Designer's interface consists of a toolbox with all the controls you can add to your form, a list of properties that are dynamically updated according to the currently selected control and a color mixer, which you use to send color data to the preview.

The preview is loaded side-by-side with the editor and allows you to see in real time how your form is going to look after being compiled.

The following controls are implemented:
    MenuBar
  ContextMenu
    Button
    Label
    Textbox
    Numeric Textbox
    Checkbox
    Radio button
    ListBox
    Dropdown list
    Track bar/Slider
    Progress bar
    Picture box
    Frame
    Toggle switch

The above is provided to get new QB64 Phoenix users up and running with a GUI interface.

Is this video worth a  look?
https://www.youtube.com/watch?v=437GhtLsND4

Print this item

  Quaternion Rotation
Posted by: dcromley - 06-11-2022, 03:28 AM - Forum: Programs - Replies (5)

[Image: z2.jpg]

[ image changed, minor program improvements ] This comes from a long fascination with quaternions.  I wanted to see them work. 

I need to get into OpenGL/QB64.  I have gone through the great tutorials of Ashish ( https://ashishkingdom.github.io/OpenGL-Tutorials/intro/ ) but he hasn't gotten to rotations.  I was surprised that looking at the QB64 Wiki, that there are 7 _gl statements with "matrix" but none with "quaternion".  I assume that means that OpenGL does not use quaternions?

Lord Kelvin: "Although beautiful and of ingenious origin, they have been a curse on anyone who has come into contact with them in any way."
But I had a good time.

I hope the output is somewhat obvious: there are 5 points in the figure which are rotated using the quaternion.  I added the extraction of the Euler Angles at the bottom. 

The program is intended to work, not to be fast.  Still, I was surprised that the framerate is well above 100/sec.  A credit to QB64.

Code: (Select All)
_Title "Quaternion Rotation" ' dcromley
Option _Explicit
DefSng A-Z: DefLng I-N: DefStr S
Const TRUE = -1, FALSE = 0
Dim Shared mx, my, m1Clk, m1Rpt, m1Dn, m1End, m2Clk, m2Dn ' for MouseCk
Dim Shared Img1, Img2
Img1 = _NewImage(1024, 768, 256)
Img2 = _NewImage(1024, 768, 256)
_Dest Img2: Color 0, 15: Cls
_Dest Img1: Color 0, 15: Cls

' == MAIN start ==

Type type4f ' 4 floats for quaternions, points, triangles
  w As Single ' 0 for points; color for triangles
  x As Single ' pt1 for triangles
  y As Single ' pt2 for triangles
  z As Single ' pt3 for triangles
End Type

Const x0 = 384, y0 = 384, kxy = 200, z0 = 200 ' center, scale
Dim Shared As type4f T, aPts(5), aPts0(5), aTris(4), QMain, QSlew, va, vb
Dim Shared nPts, nTris ' # of Points, Triangles
Dim As type4f Qxp, Qxm, Qyp, Qym, Qzp, Qzm ' +- 1 deg Q's
Dim i, x, y, z, s, p1, p2, p3, icolor, nloop
Dim EuAngX, EuAngY, EuAngZ, fcos, fsin ' Euler angles
Dim az(4), ndx(4), time0, iSlew, xa, ya

' -- Points - x,y,z,/ (# ends)
Data 0,1,0,/,-1,-1,-1,/,-1,-1,1,/,1,-1,1,/,1,-1,-1,#
' -- Triangles - p1,p2,p3,color,/ (# ends)
Data 1,2,3,9,/,1,3,4,10,/,1,4,5,12,/,1,5,2,14,#

Do ' -- load aPoints
  nPts = nPts + 1 ' read point x,y,z
  Read aPts0(nPts).x, aPts0(nPts).y, aPts0(nPts).z, s ' s is / or # to end
Loop Until s = "#"
Do ' -- load aTriangles
  nTris = nTris + 1 ' read triangle p1,p2,p3,color
  Read aTris(nTris).x, aTris(nTris).y, aTris(nTris).z, aTris(nTris).w, s
Loop Until s = "#"
' --  load 1 deg quaternions
fcos = Cos(1 * _Pi / 360): fsin = Sin(1 * _Pi / 360) ' half angle
Qxp.w = fcos: Qxp.x = fsin: Qxm.w = fcos: Qxm.x = -fsin
Qyp.w = fcos: Qyp.y = fsin: Qym.w = fcos: Qym.y = -fsin
Qzp.w = fcos: Qzp.z = fsin: Qzm.w = fcos: Qzm.z = -fsin
QMain.w = 1 ' start with null rotation
QSlew = QMain

time0 = Timer - 1 ' prevent div by 0
Do ' ======== MAIN LOOP ========
  nloop = nloop + 1 ' nloop + 1 and print
  If nloop Mod 2 = 1 Then _Dest Img1: screen img1 _
  Else _Dest Img2: Screen Img2 ' swap screens
  Cls ' simplicity, not performance
  Line (768, 0)-(768, 752), _RGB(192, 192, 192) ' vertical
  MouseCk ' get mouse data
  ' -- check controls
  If iBox(110, 12, " Up") Then Qmult Qxm, QMain, QMain ' nudge orientation
  If iBox(106, 13, "Lft") Then Qmult Qym, QMain, QMain
  If iBox(114, 13, "Rht") Then Qmult Qyp, QMain, QMain
  If iBox(110, 14, " Dn") Then Qmult Qxp, QMain, QMain
  If iBox(106, 15, "CCW") Then Qmult Qzp, QMain, QMain
  If iBox(114, 15, " CW") Then Qmult Qzm, QMain, QMain
  ' -- check for mouse dragging (slewing)
  vb.x = mx - x0: vb.y = y0 - my: vb.z = z0 ' new mouse data
  If m1Dn And isIn(mx, 0, 767) And isIn(my, 0, 767) Then ' yes
    QVtoV va, vb, T ' need to smooth out the mouse data
    QSlew.x = QSlew.x * .9 + T.x * .1: QSlew.y = QSlew.y * .9 + T.y * .1: QSlew.z = QSlew.z * .9 + T.z * .1
    Qnorm QSlew ' this is what slews
  Else
    Const k = .99 ' make the slewing decay
    QSlew.x = QSlew.x * k: QSlew.y = QSlew.y * k: QSlew.z = QSlew.z * k
    QSlew.w = Sqr(1 - QSlew.x * QSlew.x - QSlew.y * QSlew.y - QSlew.z * QSlew.z)
  End If
  Qmult QSlew, QMain, QMain ' add slew to QMain
  va = vb ' new becomes old mouse data
  ' -- quaternion to Euler
  EuAngX = _Atan2(2 * QMain.x * QMain.w - 2 * QMain.y * QMain.z, 1 - 2 * QMain.x * QMain.x - 2 * QMain.z * QMain.z)
  EuAngY = _Atan2(2 * QMain.y * QMain.w - 2 * QMain.x * QMain.z, 1 - 2 * QMain.y * QMain.y - 2 * QMain.z * QMain.z)
  EuAngZ = _Asin(2 * QMain.x * QMain.y + 2 * QMain.z * QMain.w)
  ' -- rotate points
  For i = 1 To nPts
    aPts(i) = aPts0(i) ' reset to original
    T = QMain
    T.x = -T.x: T.y = -T.y: T.z = -T.z: ' << Q' >> conjugate
    Qmult aPts(i), T, T '                 << PQ' >>
    Qmult QMain, T, aPts(i) '             << QPQ' >>
  Next i
  For i = 1 To 4 ' get center Z's into a(4)
    T = aTris(i)
    az(i) = aPts(T.x).z + aPts(T.y).z + aPts(T.z).z ' p1.z+p2.z+p3.z
  Next i
  zSortIndexF az(), ndx() ' getting z-order
  For i = 1 To nTris ' this draws the triangles
    drawTri (ndx(i)) ' in z-order
  Next i
  ' -- print stuff
  Locate 2, 101: Print Using "nloops:#,###,###,###"; nloop
  Locate , 101: Print Using "fps:          ####.#"; nloop / (Timer - time0)
  Locate , 104: Print
  Locate , 104: Print "-- To rotate --"
  Locate , 104: Print "1) Click boxes"
  Locate , 104: Print "2) Press boxes"
  Locate , 104: Print "3) Drag mouse"
  Locate , 104: Print "ESC to end"
  Locate 19, 102: Print " -- Quaternion --"
  Locate , 99: Print Using " ##.#####"; QMain.w
  Locate , 99: Print Using " ##.#####"; QMain.x; QMain.y; QMain.z
  '  Locate , 99: Print Using " ##.#####"; QSlew.w
  '  Locate , 99: Print Using " ##.#####"; QSlew.x; QSlew.y; QSlew.z
  Locate , 100: Print ""
  Locate , 102: Print " -- Points --"
  For i = 1 To nPts
    Locate , 99: Print Using " ##.#####"; aPts(i).x; aPts(i).y; aPts(i).z
  Next i
  Locate , 100: Print ""
  Locate , 102: Print " -- Euler Angles --"
  Locate , 100: Print Using "EuAngX: ###"; (EuAngX * 180 / _Pi + 360) Mod 360
  Locate , 100: Print Using "EuAngY: ###"; (EuAngY * 180 / _Pi + 360) Mod 360
  Locate , 100: Print Using "EuAngZ: ###"; (EuAngZ * 180 / _Pi + 360) Mod 360
  _Display
Loop Until InKey$ = Chr$(27)
System

' == ROUTINES start ==

Function iBox (iCol, iRow, s3) ' simple control
  Dim ix, iy
  Locate iRow, iCol: Color 0, 14: Print s3;: Color 0, 15
  ix = iCol * 8 - 11
  iy = iRow * 16 - 1
  Line (ix, iy)-(ix + 3 * 8 + 4, iy - 16), , B ' rectangle
  If m1Rpt And isIn(mx, ix, ix + 28) And isIn(my, iy - 16, iy) Then iBox = TRUE
End Function

Sub Qmult (qa As type4f, qb As type4f, qab As type4f) ' Q multiplication
  Dim w, x, y, z
  w = qa.w * qb.w - qa.x * qb.x - qa.y * qb.y - qa.z * qb.z
  x = qa.w * qb.x + qa.x * qb.w + qa.y * qb.z - qa.z * qb.y
  y = qa.w * qb.y - qa.x * qb.z + qa.y * qb.w + qa.z * qb.x
  z = qa.w * qb.z + qa.x * qb.y - qa.y * qb.x + qa.z * qb.w
  qab.w = w: qab.x = x: qab.y = y: qab.z = z
End Sub

Sub QVtoV (v1 As type4f, v2 As type4f, Q As type4f) ' get Q from v1 to v2
  Dim v1dv2, v1xv2 As type4f ' dot, cross
  v1dv2 = VdotV(v1, v2) ' dot
  VcrossV v1, v2, Q ' cross
  Q.w = v1dv2 + Sqr(v1dv2 * v1dv2 + VdotV(Q, Q)) ' from the book
  Qnorm Q
End Sub

Function VdotV (v1 As type4f, v2 As type4f) ' dot product
  VdotV = v1.x * v2.x + v1.y * v2.y + v1.z * v2.z
End Function

Sub VcrossV (v1 As type4f, v2 As type4f, v As type4f) ' cross product
  v.x = v1.y * v2.z - v1.z * v2.y
  v.y = v1.z * v2.x - v1.x * v2.z
  v.z = v1.x * v2.y - v1.y * v2.x
End Sub

Sub Qnorm (q As type4f) ' normalize
  Dim d
  d = Sqr(q.w * q.w + q.x * q.x + q.y * q.y + q.z * q.z)
  q.w = q.w / d: q.x = q.x / d: q.y = q.y / d: q.z = q.z / d
End Sub

Sub drawTri (iTri) ' draw Triangle
  Dim ip1, ip2, ip3, icolor
  Dim ixc, iyc, x1, y1, x2, y2, x3, y3
  T = aTris(iTri) ' the triangle
  ip1 = T.x: ip2 = T.y: ip3 = T.z: icolor = T.w ' the points, color
  x1 = 386 + kxy * aPts(ip1).x: y1 = 386 - kxy * aPts(ip1).y
  x2 = 386 + kxy * aPts(ip2).x: y2 = 386 - kxy * aPts(ip2).y
  x3 = 386 + kxy * aPts(ip3).x: y3 = 386 - kxy * aPts(ip3).y
  Line (x1, y1)-(x2, y2), icolor
  Line (x2, y2)-(x3, y3), icolor
  Line (x3, y3)-(x1, y1), icolor
  ' don't paint if points are colinear
  If Abs(x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) < 1000 Then Exit Sub
  ixc = (x1 + x2 + x3) / 3: iyc = (y1 + y2 + y3) / 3 ' center
  Paint (ixc, iyc), icolor ' paint
End Sub

' -- LIBRARY ROUTINES --

' -- need Dim Shared mx,my,m1Clk,m1Rpt,m1Dn,m1End,m2Clk,m2Dn
Sub MouseCk () ' get mouse info
  Static m1Prev, m2Prev, m1Time ' for getting edges (Clk,End) and Repeating
  m1Clk = 0: m1Rpt = 0: m1End = 0: m2Clk = 0
  While _MouseInput: Wend ' bplus
  mx = _MouseX: my = _MouseY: m1Dn = _MouseButton(1): m2Dn = _MouseButton(2)
  If m1Dn Then ' Btn 1 down
    If Not m1Prev Then ' got a Clk (& Rpt), now look for repeats
      m1Clk = TRUE: m1Rpt = TRUE: m1Time = iMsecs + 250 ' delay 1/4 sec for repeats
    Else ' has been down, ck for repeat
      If iMsecs > m1Time Then m1Rpt = TRUE: m1Time = iMsecs + 50 ' repeat 20/sec
    End If
    m1Prev = TRUE
  Else ' Btn 1 up
    If m1Prev Then m1End = TRUE ' end of downtime (upedge)
    m1Prev = FALSE ' for next time
  End If
  If m2Dn Then ' Btn 2 down
    If Not m2Prev Then m2Clk = TRUE ' click (downedge)
    m2Prev = TRUE
  Else
    m2Prev = FALSE
  End If
End Sub

Function isIn (x, a, b) ' ck between
  If x >= a And x <= b Then isIn = TRUE
End Function

Sub zSortIndexF (a(), ndx()) ' make index to a()
  Dim i, j, t
  For i = 1 To UBound(a) ' add one at a time
    t = a(i) ' to be added
    For j = i To 2 Step -1 ' merge in
      If a(ndx(j - 1)) <= t Then Exit For
      ndx(j) = ndx(j - 1)
    Next j
    ndx(j) = i
  Next i
End Sub

Function iMsecs () ' milliseconds since midnight UTC
  iMsecs = Int(Timer(.001) * 1000 + .5)
End Function

___________________________________________________
"I don't understand all I know about quaternions."

Print this item

  Old Games
Posted by: johnno56 - 06-11-2022, 02:02 AM - Forum: General Discussion - Replies (6)

Hey guys,

I am looking for some old "text based" games in Basic that do not use "goto"... (some goto's I can convert but not all...)

Such as Mastermind; Yahtzee; Farkle etc

Thank you.

J

ps: Sucker for the classics... lol

Print this item

  Trojan in 0.8?
Posted by: James D Jarvis - 06-11-2022, 01:05 AM - Forum: General Discussion - Replies (9)

I just had QB64 phoenix 0.8 throw an alert about an internal IDE error and windows threw up a Trojan alert at the same time. I was creating a simple screen mode 0 program at the time. I was using the 0.8 build that came with the  download.

Print this item

  Announcing QB64 Phoenix Edition v0.8.1 Release!
Posted by: DSMan195276 - 06-10-2022, 11:45 PM - Forum: Announcements - Replies (7)

QB64 Phoenix Edition v0.8.1!

Bug fixes
  - Source files with $ in the name or path will now compile correctly.
  - The 'C++ Compiler Settings...' menu entry now uses the 'm' shortcut key rather than 'o'
  - Programs that use joystick input ('_DEVICES', 'Stick', etc...) will now compile correctly.

Known issues
  - There is an issue with the 'C++ Compiler Settings.' menu. It is recommended to use v0.8.2 which has a fix for this issue.

Full Changelog: https://github.com/QB64-Phoenix-Edition/...0...v0.8.1

Print this item

  Compiler settings
Posted by: BG 7 - 06-10-2022, 12:05 PM - Forum: Help Me! - Replies (1)

Last time the size of our freeware backgammon program 
compiled with QB64 v.2.01 was 20.972.544
compiled with QB64pe v.0.80 was 20.987.902

Although the exe-file is a little bit bigger I believe that the time for compilation
was shorter with QB64pe v.0.80.

Concerning QB64 Phoenix Edition 0.80:
are there any (new) settings in order to optimize compiling
resulting in smaller (or faster) exe-files ?

Where can I find any pieces of information about compiler settings ?

Thanks !

Print this item

  using libpari
Posted by: Jack - 06-10-2022, 04:03 AM - Forum: Programs - No Replies

here's small demo on how you can use libpari http://pari.math.u-bordeaux.fr/
this demo show but a tiny bit of what you can do with the lib
note, some functions will only work on a real console window hence my use of $Console:Only and _Dest _Console
attached below is the libpari dll if you don't want to install Pari/gp

Code: (Select All)
_Title "libpari-demo"
$Console:Only
_Dest _Console

Declare Dynamic Library "libpari"
    Sub pari_init (ByVal parisize~&&, Byval maxprime~&&)
    Sub pari_close()
    Sub pari_print_version ()
    Function setdefault~&& (s As String, v As String, Byval flag&&)
    Function strtoGENstr~&& (s As String)
    Function setrealprecision&& (ByVal n&&, prec&&)
    Function GENtostr$ (ByVal x~&&)
    Function geval~&& (ByVal x~&&)
    Sub outmat (ByVal x~&&)
    Function gp_input~&& ()
    Function stoi~&& (ByVal x&&)
    Function abscmpiu& (ByVal x~&&, Byval y As _Unsigned _Integer64)
    Function abscmpui& (ByVal x As _Unsigned _Integer64, Byval y~&&)
    Function absequaliu& (ByVal x~&&, Byval y As _Unsigned _Integer64)
    Function gequal& (ByVal x~&&, Byval y~&&)
    Function gcmp& (ByVal x~&&, Byval y~&&)
End Declare

Dim As _Unsigned _Integer64 a, b, c, d, e, f
Dim As String s1, s2, s3
Dim As _Integer64 flag, prec

pari_init 80000000, 500000
pari_print_version
Print
prec = setrealprecision(50, prec)
s1 = "seriesprecision" + Chr$(0): s2 = "12" + Chr$(0)
f = setdefault(s1, s2, flag)
s1 = "fibonacci(300)" + Chr$(0)
a = strtoGENstr(s1) 'convert to GEN string
b = geval(a) 'eval the string in a
'outmat b
s3 = GENtostr(b) 'convert GEN to string
Print "fibonacci(300) = "; s3

s1 = "50!" + Chr$(0)
a = strtoGENstr(s1) 'convert to GEN string
b = geval(a) 'eval the string in a
'outmat b
s3 = GENtostr(b) 'convert GEN to string
Print "50! = "; s3

s1 = "sin(x)" + Chr$(0)
a = strtoGENstr(s1) 'convert to GEN string
b = geval(a) 'eval the string in a
'outmat b
s3 = GENtostr(b)
Print "sin(x) = "; s3

Print "evaluate a tiny program: for(i=2, 10, print(sqrt(i)))"
s1 = "for(i=2, 10, print(sqrt(i)))" + Chr$(0)
a = strtoGENstr(s1)
c = geval(a)
Print
Print "enter an expression or simply press return to exit the loop"

s1 = " "
While s1 <> ""
    Input "enter an expression ", s1
    s2 = s1 + Chr$(0)
    c = strtoGENstr(s2)
    a = geval(c)
    outmat a
Wend

'Print "enter an A ";: a = gp_input
'Print "enter an B ";: b = gp_input
'Print gequal(a, b)
'Print gcmp(a, b)
'Print abscmpiu(a, 0)
'Print abscmpui(0, a)
'Print absequaliu(a, 0)

s1 = "plot(x=-Pi,Pi,sin(x))" + Chr$(0)
a = strtoGENstr(s1) 'convert to GEN string
Print "sin(x) = ";
b = geval(a) 'eval the string in a

pari_close
output
Code: (Select All)
                                      GP/PARI CALCULATOR Version 2.13.4 (released)
                              amd64 running mingw (x86-64/GMP-6.1.2 kernel) 64-bit version
                              compiled: Mar 25 2022, gcc version 8.3-posix 20190406 (GCC)
                                                threading engine: single
                                    (readline v8.0 disabled, extended help enabled)

fibonacci(300) = 222232244629420445529739893461909967206666939096499764990979600
50! = 30414093201713378043612608166064768844377641568960512000000000000
sin(x) = x - 1/6*x^3 + 1/120*x^5 - 1/5040*x^7 + 1/362880*x^9 - 1/39916800*x^11 + O(x^13)
evaluate a tiny program: for(i=2, 10, print(sqrt(i)))
1.4142135623730950488016887242096980785696718753769
1.7320508075688772935274463415058723669428052538104
2.0000000000000000000000000000000000000000000000000
2.2360679774997896964091736687312762354406183596115
2.4494897427831780981972840747058913919659474806567
2.6457513110645905905016157536392604257102591830825
2.8284271247461900976033774484193961571393437507539
3.0000000000000000000000000000000000000000000000000
3.1622776601683793319988935444327185337195551393252
[edit] the plot looked real bad in the post



Attached Files
.zip   libpari.zip (Size: 4.33 MB / Downloads: 41)
Print this item

  Well this was fun. Wndows hotkeys...
Posted by: Pete - 06-09-2022, 10:34 PM - Forum: General Discussion - No Replies

I expanded a bit on one of Dav's old programs, that used Shift + A to restore an automatically minimized window.

This demo uses the F3 key. It has (3) effects. The usual min and restore effect, which shows a shadow effect as the window changes to minimized and restored, a method that eliminates that effect, and one that merely hides the window and restores it. Use TAB to select which effect to use.

Obviously, this works on Windows platforms, only....

Code: (Select All)
REM Based on the "Cheapo Windows Hotkey" program coded by Dav.

DECLARE DYNAMIC LIBRARY "user32"
    REM FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process handle by title
    FUNCTION GetKeyState% (BYVAL nVirtKey AS LONG) 'Windows virtual key presses
    FUNCTION ShowWindow& (BYVAL hwnd AS _OFFSET, BYVAL nCmdShow AS LONG) 'maximize process
    FUNCTION GetForegroundWindow%& 'find currently focused process handle
    FUNCTION SetForegroundWindow& (BYVAL hwnd AS _OFFSET) 'set foreground window process(focus)
END DECLARE

title$ = "Minimize-Restore Windows Demo" 'title of program window
_TITLE title$

DO
    i = i + 1
    _LIMIT 10
    REM hwnd%& = FindWindowA(0, title$ + CHR$(0)) 'find this program's process handle
    hwnd%& = _WINDOWHANDLE
    IF i > 100000 THEN PRINT "Cannot obtain window handle.": END
LOOP UNTIL hwnd%&

keyact = 114
status = 0 ' Regular window.
DO
    _LIMIT 30

    SELECT CASE status

        CASE 0

            IF msg = 0 THEN
                CLS
                PRINT "Press F3 to toggle minimize / restore window.": PRINT
                msg = 1
                y% = CSRLIN
                GOSUB menu
            END IF

            IF GetKeyState(9) < 0 THEN
                LOCATE y%, 1: PRINT SPACE$(_WIDTH);: LOCATE y%, 1
                demo = demo + 1: IF demo > 2 THEN demo = 0
                GOSUB menu
                DO: _LIMIT 30: LOOP UNTIL GetKeyState(9) >= 0
            END IF

            IF GetKeyState(keyact) < 0 THEN '<==== F3

                SELECT CASE demo
                    CASE 0 ' Minimize with effect.
                        x& = ShowWindow&(hwnd%&, 2)
                    CASE 1 ' Minimize without effect.
                        x& = ShowWindow&(hwnd%&, 0)
                        _DELAY .33
                        x& = ShowWindow&(hwnd%&, 2)
                        x& = ShowWindow&(hwnd%&, 5)
                    CASE 2 ' Hide window only.
                        y& = ShowWindow&(hwnd%&, 0)
                END SELECT

                DO: _LIMIT 30: LOOP UNTIL GetKeyState(keyact) >= 0

                status = 1

            END IF

        CASE 1
            IF GetKeyState(keyact) < 0 THEN '<==== F3
                FGwin%& = GetForegroundWindow%& 'get current process in focus

                LOCATE _HEIGHT - 2, 1
                PRINT SPACE$(_WIDTH);
                LOCATE _HEIGHT - 2, 1
                PRINT "Program Handle:"; hwnd%&; "Focus handle:"; FGwin%&;

                SELECT CASE demo
                    CASE 0 ' Restore with effect.
                        y& = ShowWindow&(hwnd%&, 9) ' Restore to original state.
                    CASE 1 ' Restore without effect.
                        y& = ShowWindow&(hwnd%&, 0)
                        _DELAY .3
                        y& = ShowWindow&(hwnd%&, 9)
                        y& = ShowWindow&(hwnd%&, 5)
                    CASE 2 ' Show window only.
                        DO
                            y& = ShowWindow&(hwnd%&, 5)
                        LOOP UNTIL y&
                END SELECT

                IF FGwin%& <> hwnd%& THEN z& = SetForegroundWindow&(hwnd%&) 'set focus when necessary

                LOCATE _HEIGHT, 1
                PRINT "Return Values:"; " Was/Is Minimized/Hidden"; x&; " Was/Is Restored"; y&; " Reactivated"; z&;

                DO: _LIMIT 30: LOOP UNTIL GetKeyState(keyact) >= 0

                status = 0
            END IF

    END SELECT

LOOP UNTIL INKEY$ = CHR$(27) AND status = 0
SYSTEM

menu:
SELECT CASE demo
    CASE 0
        PRINT "Tab Menu: Show screen on transition and minimize.": PRINT
    CASE 1
        PRINT "Tab Menu: Hide screen on transition and minimize.": PRINT
    CASE 2
        PRINT "Tab Menu: Hide window on transition.": PRINT
END SELECT
RETURN

REM ============================== VALUES ===================================

$IF  THEN
        SW_HIDE
        0           Hides the window and activates another window.
        ---------------------------------------------------------------------------------------------
        SW_SHOWNORMAL
        SW_NORMAL
        1           Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position.            An application should specify this flag when displaying the window for the first time.
        ---------------------------------------------------------------------------------------------
        SW_SHOWMINIMIZED
        2           Activates the window and displays it as a minimized window.
        ---------------------------------------------------------------------------------------------
        SW_SHOWMAXIMIZED
        SW_MAXIMIZE
        3           Activates the window and displays it as a maximized window.
        ---------------------------------------------------------------------------------------------
        SW_SHOWNOACTIVATE
        4           Displays a window in its most recent size and position. This value is similar to SW_SHOWNORMAL, except that the window is not activated.
        ---------------------------------------------------------------------------------------------
        SW_SHOW
        5           Activates the window and displays it in its current size and position.
        ---------------------------------------------------------------------------------------------
        SW_MINIMIZE
        6           Minimizes the specified window and activates the next top-level window in the Z order.
        ---------------------------------------------------------------------------------------------
        SW_SHOWMINNOACTIVE
        7           Displays the window as a minimized window. This value is similar to SW_SHOWMINIMIZED, except the window is not activated.
        ---------------------------------------------------------------------------------------------
        SW_SHOWNA
        8           Displays the window in its current size and position. This value is similar to SW_SHOW, except that the window is not activated.
        ---------------------------------------------------------------------------------------------
        SW_RESTORE
        9           Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
        ---------------------------------------------------------------------------------------------
        SW_SHOWDEFAULT
        10          Sets the show state based on the SW_ value specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application.
        ---------------------------------------------------------------------------------------------
        SW_FORCEMINIMIZE
        11          Minimizes a window, even if the thread that owns the window is not responding. This flag should only be used when minimizing windows from a different thread.
        ---------------------------------------------------------------------------------------------
$END IF

Pete

Print this item