Sorting output of Dir()

New to FreeBASIC? Post your questions here.
UEZ
Posts: 1079
Joined: May 05, 2017 19:59
Location: Germany

Re: Sorting output of Dir()

Post by UEZ »

dodicat wrote: Apr 10, 2025 8:06 OK- UEZ
I assumed that all .rpm should be hex files.
Any non hex will have a val of 0, thus appear at the beginning after a sort.
But it is strange that the var things don't work with you.
eg.

Code: Select all

 dim as long c
 start: c+=1
 Var pst=Instr("FREEBASIC","BA"),var1="a",var2="b"
 print pst,var1,var2,c
 if c<10 then goto start
 sleep
  
PS.
"Just wondering why I writing this at all..."
I am a bit zombified just now, my old border collie Bob died on Monday, he was about 15, but it is so sad to say goodbye forever.
I am sorry for your loss. :cry: but that's life, we've all drawn our ticket and are waiting to leave.

I'm getting

Code: Select all

...Test03.bas(3) error 24: Invalid data types, before ','
dodicat
Posts: 8267
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Sorting output of Dir()

Post by dodicat »

Hi UEZ
I tested with a version of fb 10.20 and I get no errors.
Have you got some compiler flags active in your ide.
Some ides add flags without your permission!
Check your log report if you have one.
Thanks for your comment about Bob.
I have just had a longish walk in the countryside, but it didn't help much.

You would think that running some basic routines in #lang "qb" would be transferable to #lang "fb" without too much trouble. Barring of course line numbers and spaghetti code
But not the case when using data.
viz:

Code: Select all


#lang "qb"
#macro setdata(z...)
data z
#endmacro

setdata(_
102.rpm,_
103.rpm,_
104.rpm,_
105.rpm,_
106.rpm,_
108.rpm,_
109.rpm,_
11.rpm,_
1100.rpm,_
1101.rpm,_
1121.rpm,_
115.rpm,_
116.rpm,_
118.rpm,_
119.rpm,_
120.rpm,_
1205.rpm,_
121.rpm,_
122.rpm,_
123.rpm,_
124.rpm,_
125.rpm,_
126.rpm,_
127.rpm,_
128.rpm,_
12A.rpm,_
12B.rpm,_
12D.rpm,_
12E.rpm,_
132.rpm,_
13F5.rpm,_
147.rpm,_
149.rpm,_
14A.rpm,_
1500.rpm,_
1501.rpm,_
1502.rpm,_
1503.rpm,_
1504.rpm,_
1505.rpm,_
1506.rpm,_
1507.rpm,_
1508.rpm,_
1509.rpm,_
150A.rpm,_
150B.rpm,_
150C.rpm,_
150D.rpm,_
150E.rpm,_
150F.rpm,_
16F.rpm,_
1903.rpm,_
191.rpm,_
1B.rpm)

Sub bubblesortHEX(g() As String)
    For n1 As Long=Lbound(g) To Ubound(g)-1
        For n2 As Long=n1+1 To Ubound(g)
            If Val("&h"+g(n1)) > val("&h"+g(n2))Then Swap g(n1),g(n2)
        Next
    Next
End Sub

redim as string i()
dim as integer c
print "Original"
do
    c+=1
    redim preserve i(1 to c)
    read i(c)
    if i(c)="" then redim preserve i(1 to c-1):exit do
    print i(c);",";
loop 
print
print
print "sorted"
bubblesortHEX(i())
for n as long=lbound(i) to ubound(i)
    print i(n);",";
    next

sleep
 
UEZ
Posts: 1079
Joined: May 05, 2017 19:59
Location: Germany

Re: Sorting output of Dir()

Post by UEZ »

Code: Select all

 Dim As Long c
 start: c+=1
 Var pst=InStr("FREEBASIC","BA"),var1="a",var2="b"
 Print pst,var1,var2,c
 If c<10 Then Goto start
 Sleep
I'm using the latest official release 1.10.1.

When I try to compile (x64 or x86) it in CMD with fbc -s console Test03.bas I get the em: Test03.bas(3) error 24: Invalid data types, before ','
dodicat
Posts: 8267
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Sorting output of Dir()

Post by dodicat »

Is it an assembler error on your cpu.
try renaming pst and var1 and var2, because using var for three variables on the same line with commas is allowed.
I was a bit dubious of start: c+=1 on the same line, but it seems OK here.
My result:

Code: Select all

 5            a             b              1
 5            a             b              2
 5            a             b              3
 5            a             b              4
 5            a             b              5
 5            a             b              6
 5            a             b              7
 5            a             b              8
 5            a             b              9
 5            a             b              10
 
srvaldez
Posts: 3648
Joined: Sep 25, 2005 21:54

Re: Sorting output of Dir()

Post by srvaldez »

var arrrggghhh 😂
dodicat
Posts: 8267
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Sorting output of Dir()

Post by dodicat »

Could you expand on that srvaldez.

Code: Select all

 var arrrggghhh= "explorer """"https://cdn.jsdelivr.net/gh/twitter/twemoji@latest/assets/svg/1f602.svg"""""
shell arrrggghhh
sleep
UEZ
Posts: 1079
Joined: May 05, 2017 19:59
Location: Germany

Re: Sorting output of Dir()

Post by UEZ »

The problem seems to be with Var which fails on my system when you assign a string to a variable.

Code: Select all

Var a = Chr(84, 101, 115, 116) 'ok
Var b = "Test" 'nok -> Error: Invalid data types, before '''

? a, b

Sleep
Seems to be a bug.
dodicat
Posts: 8267
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Sorting output of Dir()

Post by dodicat »

Here is my freebasic distribution download folder
FreeBASIC-1.10.1-winlibs-gcc-9.3.0
No problems with var something="string literal" here.

Strange bug for you there|
Xusinboy Bekchanov
Posts: 880
Joined: Jul 26, 2018 18:28

Re: Sorting output of Dir()

Post by Xusinboy Bekchanov »

UEZ wrote: Apr 11, 2025 7:21 The problem seems to be with Var which fails on my system when you assign a string to a variable.

Code: Select all

Var a = Chr(84, 101, 115, 116) 'ok
Var b = "Test" 'nok -> Error: Invalid data types, before '''

? a, b

Sleep
Seems to be a bug.
You can do this:

Code: Select all

Var a = Str("fdfdf")
Or you can make the file format Plain text, then your code works too.
UEZ
Posts: 1079
Joined: May 05, 2017 19:59
Location: Germany

Re: Sorting output of Dir()

Post by UEZ »

Xusinboy Bekchanov wrote: Apr 11, 2025 8:52
UEZ wrote: Apr 11, 2025 7:21 The problem seems to be with Var which fails on my system when you assign a string to a variable.

Code: Select all

Var a = Chr(84, 101, 115, 116) 'ok
Var b = "Test" 'nok -> Error: Invalid data types, before '''

? a, b

Sleep
Seems to be a bug.
You can do this:

Code: Select all

Var a = Str("fdfdf")
Or you can make the file format Plain text, then your code works too.
Yes, it is an issue with the UTF-8 format - thx. Btw, using UTF-8 is also problematic when creating text for GUI controls, e.g. Combobox. The text is then cut.
Xusinboy Bekchanov
Posts: 880
Joined: Jul 26, 2018 18:28

Re: Sorting output of Dir()

Post by Xusinboy Bekchanov »

UEZ wrote: Apr 11, 2025 11:11
Xusinboy Bekchanov wrote: Apr 11, 2025 8:52
UEZ wrote: Apr 11, 2025 7:21 The problem seems to be with Var which fails on my system when you assign a string to a variable.

Code: Select all

Var a = Chr(84, 101, 115, 116) 'ok
Var b = "Test" 'nok -> Error: Invalid data types, before '''

? a, b

Sleep
Seems to be a bug.
You can do this:

Code: Select all

Var a = Str("fdfdf")
Or you can make the file format Plain text, then your code works too.
Yes, it is an issue with the UTF-8 format - thx. Btw, using UTF-8 is also problematic when creating text for GUI controls, e.g. Combobox. The text is then cut.
I haven't had this problem, can you give me an example?
UEZ
Posts: 1079
Joined: May 05, 2017 19:59
Location: Germany

Re: Sorting output of Dir()

Post by UEZ »

Sure, all combo strings are trimmed to first char.

Code: Select all

#include "windows.bi"
#include "win\commctrl.bi"
#include "win\windowsx.bi"


Declare Function WndProc(hWnd As HWND, uMsg As UINT, wParam As WPARAM, lParam As LPARAM) As Integer

Const As Long iBgColor = &h606060
Const As Integer idComboBox = 2000
Dim Shared As HWND hWND_EQ, hCombobox_EQ, hCheckBox_EQ, aSlider_EQ(9)
Dim Shared As WndProc oldSliderProc
Dim Shared As Single aEQ_Freq(9) = {80, 120, 250, 500, 1000, 1800, 3500, 7000, 10000, 14000}
Dim Shared As Single aEQ_Bandwith(9) = {14, 12, 12, 12, 12, 12, 12, 12, 10, 10}
Dim Shared As Single aEQ_Pop(9) = {3, 2, 0, -2, -1, 0, 2, 3, 4, 3}
'Dim Shared As Single aEQ_Pop(9) = {9, 6, 0, -6, -3, 0, 6, 9, 12, 9}
Dim Shared As Single aEQ_Rock(9) = {4, 3, 2, 1, 2, 3, 4, 2, 2, 0}
'Dim Shared As Single aEQ_Rock(9) = {12, 9, 6, 3, 6, 9, 12, 6, 6, 0}
Dim Shared As Single aEQ_Jazz(9) = {3, 2, 1, 0, 1, 0, 2, 1, -1, -2}
'Dim Shared As Single aEQ_Jazz(9) = {9, 6, 3, 0, 3, 0, 6, 3, -3, -6}
Dim Shared As Single aEQ_Classical(9) = {2, 1, 0, -1, 1, 2, 3, 2, 1, 0}
'Dim Shared As Single aEQ_Classical(9) = {6, 3, 0, -3, 3, 6, 9, 6, 3, 0}
Dim Shared As Single aEQ_Bass(9) = {6, 5, 4, 0, -2, -2, -2, 0, 0, 0}
'Dim Shared As Single aEQ_Bass(9) = {15, 12, 9, 0, -6, -6, -6, 0, 0, 0}
Dim Shared As Single aEQ_VocalBoost(9) = {-3, -2, 0, 1, 3, 4, 5, 4, 2, 1}
'Dim Shared As Single aEQ_VocalBoost(9) = {-9, -6, 0, 3, 9, 12, 15, 12, 6, 3}
Dim Shared As Single aEQ_Electronic(9) = {5, 4, 3, -1, -2, 1, 2, 3, 5, 4}
'Dim Shared As Single aEQ_Electronic(9) = {15, 12, 9, -3, -6, 3, 6, 9, 15, 12}
Dim Shared As Single aEQ_Flat(9) = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}



Sub Equalizer()
	Dim wc As WNDCLASSEX
	Dim msg As MSG
	Dim As Integer sW, sH
	ScreenInfo(sW, sH)
	
	Dim szAppName As ZString * 30 => "FB GUI"
	Dim As String sTitle = "Equalizer GUI"
	Dim As ULong iW, iH
	iW = 640
	iH = Int(iW * 9 / 16) + 50
	Dim As String aLables(9) = {"80 ", "120", "250", "500", "1k ", "1.8k", "3.5k", "7k ", "10k", "14k"}
	
	With wc
		.style         = CS_HREDRAW Or CS_VREDRAW
		.lpfnWndProc   = @WndProc
		.cbClsExtra    = NULL
		.cbWndExtra    = NULL
		.hInstance     = GetModuleHandle(NULL)
		.hIcon         = LoadIcon(NULL, IDI_APPLICATION)
		.hCursor       = LoadCursor(NULL, IDC_ARROW)
		.hbrBackground = CreateSolidBrush(iBgColor)
		.lpszMenuName  = NULL
		.lpszClassName = @szAppName
		.cbSize			= SizeOf(WNDCLASSEX)
	End With
	 
	RegisterClassEx(@wc)
	Dim As Long iStyle = WS_OVERLAPPEDWINDOW Or WS_VISIBLE Or WS_BORDER
	iStyle Xor = (WS_SIZEBOX Or WS_MAXIMIZEBOX)
	hWND_EQ = CreateWindowEx(WS_EX_WINDOWEDGE, wc.lpszClassName, sTitle, _
								  iStyle, _
								  (sW - iW) / 2, (sH - iH) / 2, _
								  iW, iH, _
								  NULL, NULL, wc.hInstance, NULL)

	Dim As Any Ptr hDC = GetDC(NULL)
	Dim As Integer iHeight = MulDiv(16, GetDeviceCaps(hDC, LOGPIXELSY), 72)
	ReleaseDC(NULL, hDC)
	Dim As HFONT hFont = CreateFont(iHeight, 0, 0, 0, 400, False, False, False, _
									1, OUT_DEFAULT_PRECIS, _
									CLIP_DEFAULT_PRECIS, _
									DEFAULT_QUALITY, _
									DEFAULT_PITCH, _
									"Comic Sans MS")
	
	hCheckBox_EQ = CreateWindowEx(0, "BUTTON", "On", _
													WS_TABSTOP Or WS_VISIBLE Or WS_CHILD Or BS_AUTOCHECKBOX, _
													35, 22, 50, 20,	hWND_EQ, 0, 0, 0 )
	CheckDlgButton(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ), BST_CHECKED)
											
	hCombobox_EQ = CreateWindowEx(WS_EX_CLIENTEDGE, WC_COMBOBOX, NULL, _
							   WS_CHILD Or WS_VISIBLE Or CBS_DROPDOWNLIST Or CBS_AUTOHSCROLL, _
							   (iW - 250) / 2, 20, 250, 512, hWND_EQ, Cast(HMENU, Cast(LONG_PTR, idComboBox)), GetModuleHandle(NULL), NULL)
		
	SendMessage(hCombobox_EQ, WM_SETREDRAW, Cast(WPARAM, False), Cast(LPARAM, 0))
	'https://docs.microsoft.com/en-us/windows/win32/controls/bumper-combobox-control-reference-macros
	ComboBox_AddString(hCombobox_EQ, StrPtr("Flat"))
	ComboBox_AddString(hCombobox_EQ, StrPtr("Pop"))
	ComboBox_AddString(hCombobox_EQ, StrPtr("Rock"))
	ComboBox_AddString(hCombobox_EQ, StrPtr("Jazz"))
	ComboBox_AddString(hCombobox_EQ, StrPtr("Classical"))
	ComboBox_AddString(hCombobox_EQ, StrPtr("Bass"))
	ComboBox_AddString(hCombobox_EQ, StrPtr("Vocal Boost"))
	ComboBox_AddString(hCombobox_EQ, StrPtr("Electronic"))
	SendMessage(hCombobox_EQ, WM_SETREDRAW, Cast(WPARAM, True), Cast(LPARAM, 0))
	SendMessage(hCombobox_EQ, CB_SETCURSEL, Cast(WPARAM, 0), Cast(LPARAM, 0))
	SendMessage(hCombobox_EQ, WM_SETFONT, Cast(WPARAM, hFont), Cast(LPARAM, True))
	
	Dim As Byte i, iGain_Min = -6, iGain_Max = 6
	
	For i = 0 To 9
		CreateWindowEx(0, "STATIC", aLables(i), SS_CENTER Or WS_VISIBLE Or WS_CHILD, 95 + i * 50, 270, 40, 20, hWND_EQ, 0, 0, 0)
		aSlider_EQ(i) = CreateWindowEx(NULL, TRACKBAR_CLASS, "Trackbar Control",  WS_VISIBLE Or WS_CHILD Or TBS_VERT Or TBS_BOTH Or TBS_AUTOTICKS Or TBS_ENABLESELRANGE Or TBS_TOP, _
						 			   95 + i * 50, 65, 40, 200, hWND_EQ, NULL, NULL, NULL)
		SendMessage(aSlider_EQ(i), TBM_SETRANGE, Cast(WPARAM, True), MAKELONG(iGain_Min, iGain_Max))
		SendMessage(aSlider_EQ(i), TBM_SETPOS, Cast(WPARAM, True), Cast(LPARAM, 0))
		SendMessage(aSlider_EQ(i), TBM_SETTICFREQ, Cast(WPARAM, 1), Cast(LPARAM, 0))
		SendMessage(aSlider_EQ(i), WM_CHANGEUISTATE, Cast(WPARAM, MAKELONG(UISF_HIDEFOCUS, UIS_SET)), Cast(LPARAM, 0)) 'remove focused lines
	Next

	CreateWindowEx(0, "STATIC", "+" & iGain_Max & " dB", SS_CENTER Or WS_VISIBLE Or WS_CHILD, 35, 70, 50, 15, hWND_EQ, 0, 0, 0)
	CreateWindowEx(0, "STATIC", "0 dB", SS_CENTER Or WS_VISIBLE Or WS_CHILD, 35, 157, 50, 15, hWND_EQ, 0, 0, 0)
	CreateWindowEx(0, "STATIC", iGain_Min & " dB", SS_CENTER Or WS_VISIBLE Or WS_CHILD, 35, 243, 50, 15, hWND_EQ, 0, 0, 0)
	CreateWindowEx(0, "STATIC", "Hz", SS_CENTER Or WS_VISIBLE Or WS_CHILD, 47, 270, 25, 15, hWND_EQ, 0, 0, 0)
	
	ShowWindow(hWND_EQ, SW_SHOW)
	
	While GetMessage(@msg, 0, 0, 0)
		TranslateMessage(@msg)
		DispatchMessage(@msg)
	Wend
End Sub

Sub UpdateSliders(aSettings() As Single)
	For i As Byte = 0 To 9
		SendMessage(aSlider_EQ(i), TBM_SETPOS, Cast(WPARAM, True), Cast(LPARAM, -aSettings(i)))
		If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then 
		End If
	Next
End Sub


Sub UpdateEQ(b As Integer, v As Single = 0)
    If (b < 10) Then
    End If
End Sub

Function WndProc(hWnd As HWND, uMsg As UINT, wParam As WPARAM, lParam As LPARAM) As Integer
	If hWnd = hWND_EQ Then
		Select Case uMsg
			Case WM_CLOSE
				PostQuitMessage(0)
			Case WM_CREATE
			Case WM_CTLCOLORSTATIC
				Dim As HDC hdcStatic = Cast(HDC, wParam)
				SetTextColor(hdcStatic, &hF0F0F0)
				SetBkColor(hdcStatic, iBgColor)
				Static As HBRUSH hbrBkgnd
				If hbrBkgnd = 0 Then hbrBkgnd = CreateSolidBrush(iBgColor)
				Return Cast(INT_PTR, hbrBkgnd)
			Case WM_COMMAND
				Select Case LoWord (wParam)
					Case idComboBox '...'
						Select Case HiWord(wParam)
							Case CBN_SELCHANGE
								Dim As ZString * 512 sComboCurrSel
								ComboBox_GetLBText(hCombobox_EQ, ComboBox_GetCurSel(hCombobox_EQ), @sComboCurrSel)
								Select Case sComboCurrSel
									Case "Flat"
										UpdateSliders(aEQ_Flat())
									Case "Pop"
										UpdateSliders(aEQ_Pop())
									Case "Rock"
										UpdateSliders(aEQ_Rock())
									Case "Jazz"
										UpdateSliders(aEQ_Jazz())
									Case "Classical"
										UpdateSliders(aEQ_Classical())
									Case "Bass"
										UpdateSliders(aEQ_Bass())
									Case "Vocal Boost"
										UpdateSliders(aEQ_VocalBoost())
									Case "Electronic"
										UpdateSliders(aEQ_Electronic())
								End Select
						End Select
				End Select
			Case WM_VSCROLL '''TRACKBARS
				Dim As Long iSliderPos
				Select Case lParam '...'
					Case aSlider_EQ(0)
						iSliderPos = -SendMessage(aSlider_EQ(0), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(0, iSliderPos)
						EndIf
					Case aSlider_EQ(1)
						iSliderPos = -SendMessage(aSlider_EQ(1), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(1, iSliderPos)
						EndIf
					Case aSlider_EQ(2)
						iSliderPos = -SendMessage(aSlider_EQ(2), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(2, iSliderPos)
						EndIf
					Case aSlider_EQ(3)
						iSliderPos = -SendMessage(aSlider_EQ(3), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(3, iSliderPos)
						EndIf
					Case aSlider_EQ(4)
						iSliderPos = -SendMessage(aSlider_EQ(4), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(4, iSliderPos)
						EndIf
					Case aSlider_EQ(5)
						iSliderPos = -SendMessage(aSlider_EQ(5), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(5, iSliderPos)
						EndIf
					Case aSlider_EQ(6)
						iSliderPos = -SendMessage(aSlider_EQ(6), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(6, iSliderPos)
						EndIf
					Case aSlider_EQ(7)
						iSliderPos = -SendMessage(aSlider_EQ(7), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(7, iSliderPos)
						EndIf
					Case aSlider_EQ(8)
						iSliderPos = -SendMessage(aSlider_EQ(8), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(8, iSliderPos)
						EndIf
					Case aSlider_EQ(9)
						iSliderPos = -SendMessage(aSlider_EQ(9), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(9, iSliderPos)
						EndIf
				End Select
			End Select
		End If
		Return DefWindowProc(hWnd, uMsg, wParam, lParam)
End Function

Equalizer()
UTF-8:
Image

Text:
Image
Xusinboy Bekchanov
Posts: 880
Joined: Jul 26, 2018 18:28

Re: Sorting output of Dir()

Post by Xusinboy Bekchanov »

UEZ wrote: Apr 11, 2025 17:25 Sure, all combo strings are trimmed to first char.

Code: Select all

#include "windows.bi"
#include "win\commctrl.bi"
#include "win\windowsx.bi"


Declare Function WndProc(hWnd As HWND, uMsg As UINT, wParam As WPARAM, lParam As LPARAM) As Integer

Const As Long iBgColor = &h606060
Const As Integer idComboBox = 2000
Dim Shared As HWND hWND_EQ, hCombobox_EQ, hCheckBox_EQ, aSlider_EQ(9)
Dim Shared As WndProc oldSliderProc
Dim Shared As Single aEQ_Freq(9) = {80, 120, 250, 500, 1000, 1800, 3500, 7000, 10000, 14000}
Dim Shared As Single aEQ_Bandwith(9) = {14, 12, 12, 12, 12, 12, 12, 12, 10, 10}
Dim Shared As Single aEQ_Pop(9) = {3, 2, 0, -2, -1, 0, 2, 3, 4, 3}
'Dim Shared As Single aEQ_Pop(9) = {9, 6, 0, -6, -3, 0, 6, 9, 12, 9}
Dim Shared As Single aEQ_Rock(9) = {4, 3, 2, 1, 2, 3, 4, 2, 2, 0}
'Dim Shared As Single aEQ_Rock(9) = {12, 9, 6, 3, 6, 9, 12, 6, 6, 0}
Dim Shared As Single aEQ_Jazz(9) = {3, 2, 1, 0, 1, 0, 2, 1, -1, -2}
'Dim Shared As Single aEQ_Jazz(9) = {9, 6, 3, 0, 3, 0, 6, 3, -3, -6}
Dim Shared As Single aEQ_Classical(9) = {2, 1, 0, -1, 1, 2, 3, 2, 1, 0}
'Dim Shared As Single aEQ_Classical(9) = {6, 3, 0, -3, 3, 6, 9, 6, 3, 0}
Dim Shared As Single aEQ_Bass(9) = {6, 5, 4, 0, -2, -2, -2, 0, 0, 0}
'Dim Shared As Single aEQ_Bass(9) = {15, 12, 9, 0, -6, -6, -6, 0, 0, 0}
Dim Shared As Single aEQ_VocalBoost(9) = {-3, -2, 0, 1, 3, 4, 5, 4, 2, 1}
'Dim Shared As Single aEQ_VocalBoost(9) = {-9, -6, 0, 3, 9, 12, 15, 12, 6, 3}
Dim Shared As Single aEQ_Electronic(9) = {5, 4, 3, -1, -2, 1, 2, 3, 5, 4}
'Dim Shared As Single aEQ_Electronic(9) = {15, 12, 9, -3, -6, 3, 6, 9, 15, 12}
Dim Shared As Single aEQ_Flat(9) = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}



Sub Equalizer()
	Dim wc As WNDCLASSEX
	Dim msg As MSG
	Dim As Integer sW, sH
	ScreenInfo(sW, sH)
	
	Dim szAppName As ZString * 30 => "FB GUI"
	Dim As String sTitle = "Equalizer GUI"
	Dim As ULong iW, iH
	iW = 640
	iH = Int(iW * 9 / 16) + 50
	Dim As String aLables(9) = {"80 ", "120", "250", "500", "1k ", "1.8k", "3.5k", "7k ", "10k", "14k"}
	
	With wc
		.style         = CS_HREDRAW Or CS_VREDRAW
		.lpfnWndProc   = @WndProc
		.cbClsExtra    = NULL
		.cbWndExtra    = NULL
		.hInstance     = GetModuleHandle(NULL)
		.hIcon         = LoadIcon(NULL, IDI_APPLICATION)
		.hCursor       = LoadCursor(NULL, IDC_ARROW)
		.hbrBackground = CreateSolidBrush(iBgColor)
		.lpszMenuName  = NULL
		.lpszClassName = @szAppName
		.cbSize			= SizeOf(WNDCLASSEX)
	End With
	 
	RegisterClassEx(@wc)
	Dim As Long iStyle = WS_OVERLAPPEDWINDOW Or WS_VISIBLE Or WS_BORDER
	iStyle Xor = (WS_SIZEBOX Or WS_MAXIMIZEBOX)
	hWND_EQ = CreateWindowEx(WS_EX_WINDOWEDGE, wc.lpszClassName, sTitle, _
								  iStyle, _
								  (sW - iW) / 2, (sH - iH) / 2, _
								  iW, iH, _
								  NULL, NULL, wc.hInstance, NULL)

	Dim As Any Ptr hDC = GetDC(NULL)
	Dim As Integer iHeight = MulDiv(16, GetDeviceCaps(hDC, LOGPIXELSY), 72)
	ReleaseDC(NULL, hDC)
	Dim As HFONT hFont = CreateFont(iHeight, 0, 0, 0, 400, False, False, False, _
									1, OUT_DEFAULT_PRECIS, _
									CLIP_DEFAULT_PRECIS, _
									DEFAULT_QUALITY, _
									DEFAULT_PITCH, _
									"Comic Sans MS")
	
	hCheckBox_EQ = CreateWindowEx(0, "BUTTON", "On", _
													WS_TABSTOP Or WS_VISIBLE Or WS_CHILD Or BS_AUTOCHECKBOX, _
													35, 22, 50, 20,	hWND_EQ, 0, 0, 0 )
	CheckDlgButton(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ), BST_CHECKED)
											
	hCombobox_EQ = CreateWindowEx(WS_EX_CLIENTEDGE, WC_COMBOBOX, NULL, _
							   WS_CHILD Or WS_VISIBLE Or CBS_DROPDOWNLIST Or CBS_AUTOHSCROLL, _
							   (iW - 250) / 2, 20, 250, 512, hWND_EQ, Cast(HMENU, Cast(LONG_PTR, idComboBox)), GetModuleHandle(NULL), NULL)
		
	SendMessage(hCombobox_EQ, WM_SETREDRAW, Cast(WPARAM, False), Cast(LPARAM, 0))
	'https://docs.microsoft.com/en-us/windows/win32/controls/bumper-combobox-control-reference-macros
	ComboBox_AddString(hCombobox_EQ, StrPtr("Flat"))
	ComboBox_AddString(hCombobox_EQ, StrPtr("Pop"))
	ComboBox_AddString(hCombobox_EQ, StrPtr("Rock"))
	ComboBox_AddString(hCombobox_EQ, StrPtr("Jazz"))
	ComboBox_AddString(hCombobox_EQ, StrPtr("Classical"))
	ComboBox_AddString(hCombobox_EQ, StrPtr("Bass"))
	ComboBox_AddString(hCombobox_EQ, StrPtr("Vocal Boost"))
	ComboBox_AddString(hCombobox_EQ, StrPtr("Electronic"))
	SendMessage(hCombobox_EQ, WM_SETREDRAW, Cast(WPARAM, True), Cast(LPARAM, 0))
	SendMessage(hCombobox_EQ, CB_SETCURSEL, Cast(WPARAM, 0), Cast(LPARAM, 0))
	SendMessage(hCombobox_EQ, WM_SETFONT, Cast(WPARAM, hFont), Cast(LPARAM, True))
	
	Dim As Byte i, iGain_Min = -6, iGain_Max = 6
	
	For i = 0 To 9
		CreateWindowEx(0, "STATIC", aLables(i), SS_CENTER Or WS_VISIBLE Or WS_CHILD, 95 + i * 50, 270, 40, 20, hWND_EQ, 0, 0, 0)
		aSlider_EQ(i) = CreateWindowEx(NULL, TRACKBAR_CLASS, "Trackbar Control",  WS_VISIBLE Or WS_CHILD Or TBS_VERT Or TBS_BOTH Or TBS_AUTOTICKS Or TBS_ENABLESELRANGE Or TBS_TOP, _
						 			   95 + i * 50, 65, 40, 200, hWND_EQ, NULL, NULL, NULL)
		SendMessage(aSlider_EQ(i), TBM_SETRANGE, Cast(WPARAM, True), MAKELONG(iGain_Min, iGain_Max))
		SendMessage(aSlider_EQ(i), TBM_SETPOS, Cast(WPARAM, True), Cast(LPARAM, 0))
		SendMessage(aSlider_EQ(i), TBM_SETTICFREQ, Cast(WPARAM, 1), Cast(LPARAM, 0))
		SendMessage(aSlider_EQ(i), WM_CHANGEUISTATE, Cast(WPARAM, MAKELONG(UISF_HIDEFOCUS, UIS_SET)), Cast(LPARAM, 0)) 'remove focused lines
	Next

	CreateWindowEx(0, "STATIC", "+" & iGain_Max & " dB", SS_CENTER Or WS_VISIBLE Or WS_CHILD, 35, 70, 50, 15, hWND_EQ, 0, 0, 0)
	CreateWindowEx(0, "STATIC", "0 dB", SS_CENTER Or WS_VISIBLE Or WS_CHILD, 35, 157, 50, 15, hWND_EQ, 0, 0, 0)
	CreateWindowEx(0, "STATIC", iGain_Min & " dB", SS_CENTER Or WS_VISIBLE Or WS_CHILD, 35, 243, 50, 15, hWND_EQ, 0, 0, 0)
	CreateWindowEx(0, "STATIC", "Hz", SS_CENTER Or WS_VISIBLE Or WS_CHILD, 47, 270, 25, 15, hWND_EQ, 0, 0, 0)
	
	ShowWindow(hWND_EQ, SW_SHOW)
	
	While GetMessage(@msg, 0, 0, 0)
		TranslateMessage(@msg)
		DispatchMessage(@msg)
	Wend
End Sub

Sub UpdateSliders(aSettings() As Single)
	For i As Byte = 0 To 9
		SendMessage(aSlider_EQ(i), TBM_SETPOS, Cast(WPARAM, True), Cast(LPARAM, -aSettings(i)))
		If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then 
		End If
	Next
End Sub


Sub UpdateEQ(b As Integer, v As Single = 0)
    If (b < 10) Then
    End If
End Sub

Function WndProc(hWnd As HWND, uMsg As UINT, wParam As WPARAM, lParam As LPARAM) As Integer
	If hWnd = hWND_EQ Then
		Select Case uMsg
			Case WM_CLOSE
				PostQuitMessage(0)
			Case WM_CREATE
			Case WM_CTLCOLORSTATIC
				Dim As HDC hdcStatic = Cast(HDC, wParam)
				SetTextColor(hdcStatic, &hF0F0F0)
				SetBkColor(hdcStatic, iBgColor)
				Static As HBRUSH hbrBkgnd
				If hbrBkgnd = 0 Then hbrBkgnd = CreateSolidBrush(iBgColor)
				Return Cast(INT_PTR, hbrBkgnd)
			Case WM_COMMAND
				Select Case LoWord (wParam)
					Case idComboBox '...'
						Select Case HiWord(wParam)
							Case CBN_SELCHANGE
								Dim As ZString * 512 sComboCurrSel
								ComboBox_GetLBText(hCombobox_EQ, ComboBox_GetCurSel(hCombobox_EQ), @sComboCurrSel)
								Select Case sComboCurrSel
									Case "Flat"
										UpdateSliders(aEQ_Flat())
									Case "Pop"
										UpdateSliders(aEQ_Pop())
									Case "Rock"
										UpdateSliders(aEQ_Rock())
									Case "Jazz"
										UpdateSliders(aEQ_Jazz())
									Case "Classical"
										UpdateSliders(aEQ_Classical())
									Case "Bass"
										UpdateSliders(aEQ_Bass())
									Case "Vocal Boost"
										UpdateSliders(aEQ_VocalBoost())
									Case "Electronic"
										UpdateSliders(aEQ_Electronic())
								End Select
						End Select
				End Select
			Case WM_VSCROLL '''TRACKBARS
				Dim As Long iSliderPos
				Select Case lParam '...'
					Case aSlider_EQ(0)
						iSliderPos = -SendMessage(aSlider_EQ(0), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(0, iSliderPos)
						EndIf
					Case aSlider_EQ(1)
						iSliderPos = -SendMessage(aSlider_EQ(1), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(1, iSliderPos)
						EndIf
					Case aSlider_EQ(2)
						iSliderPos = -SendMessage(aSlider_EQ(2), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(2, iSliderPos)
						EndIf
					Case aSlider_EQ(3)
						iSliderPos = -SendMessage(aSlider_EQ(3), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(3, iSliderPos)
						EndIf
					Case aSlider_EQ(4)
						iSliderPos = -SendMessage(aSlider_EQ(4), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(4, iSliderPos)
						EndIf
					Case aSlider_EQ(5)
						iSliderPos = -SendMessage(aSlider_EQ(5), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(5, iSliderPos)
						EndIf
					Case aSlider_EQ(6)
						iSliderPos = -SendMessage(aSlider_EQ(6), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(6, iSliderPos)
						EndIf
					Case aSlider_EQ(7)
						iSliderPos = -SendMessage(aSlider_EQ(7), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(7, iSliderPos)
						EndIf
					Case aSlider_EQ(8)
						iSliderPos = -SendMessage(aSlider_EQ(8), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(8, iSliderPos)
						EndIf
					Case aSlider_EQ(9)
						iSliderPos = -SendMessage(aSlider_EQ(9), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(9, iSliderPos)
						EndIf
				End Select
			End Select
		End If
		Return DefWindowProc(hWnd, uMsg, wParam, lParam)
End Function

Equalizer()
UTF-8:
Image

Text:
Image
This is how it works:

Code: Select all

#include "windows.bi"
#include "win\commctrl.bi"
#include "win\windowsx.bi"


Declare Function WndProc(hWnd As HWND, uMsg As UINT, wParam As WPARAM, lParam As LPARAM) As Integer

Const As Long iBgColor = &h606060
Const As Integer idComboBox = 2000
Dim Shared As HWND hWND_EQ, hCombobox_EQ, hCheckBox_EQ, aSlider_EQ(9)
Dim Shared As WndProc oldSliderProc
Dim Shared As Single aEQ_Freq(9) = {80, 120, 250, 500, 1000, 1800, 3500, 7000, 10000, 14000}
Dim Shared As Single aEQ_Bandwith(9) = {14, 12, 12, 12, 12, 12, 12, 12, 10, 10}
Dim Shared As Single aEQ_Pop(9) = {3, 2, 0, -2, -1, 0, 2, 3, 4, 3}
'Dim Shared As Single aEQ_Pop(9) = {9, 6, 0, -6, -3, 0, 6, 9, 12, 9}
Dim Shared As Single aEQ_Rock(9) = {4, 3, 2, 1, 2, 3, 4, 2, 2, 0}
'Dim Shared As Single aEQ_Rock(9) = {12, 9, 6, 3, 6, 9, 12, 6, 6, 0}
Dim Shared As Single aEQ_Jazz(9) = {3, 2, 1, 0, 1, 0, 2, 1, -1, -2}
'Dim Shared As Single aEQ_Jazz(9) = {9, 6, 3, 0, 3, 0, 6, 3, -3, -6}
Dim Shared As Single aEQ_Classical(9) = {2, 1, 0, -1, 1, 2, 3, 2, 1, 0}
'Dim Shared As Single aEQ_Classical(9) = {6, 3, 0, -3, 3, 6, 9, 6, 3, 0}
Dim Shared As Single aEQ_Bass(9) = {6, 5, 4, 0, -2, -2, -2, 0, 0, 0}
'Dim Shared As Single aEQ_Bass(9) = {15, 12, 9, 0, -6, -6, -6, 0, 0, 0}
Dim Shared As Single aEQ_VocalBoost(9) = {-3, -2, 0, 1, 3, 4, 5, 4, 2, 1}
'Dim Shared As Single aEQ_VocalBoost(9) = {-9, -6, 0, 3, 9, 12, 15, 12, 6, 3}
Dim Shared As Single aEQ_Electronic(9) = {5, 4, 3, -1, -2, 1, 2, 3, 5, 4}
'Dim Shared As Single aEQ_Electronic(9) = {15, 12, 9, -3, -6, 3, 6, 9, 15, 12}
Dim Shared As Single aEQ_Flat(9) = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}



Sub Equalizer()
	Dim wc As WNDCLASSEX
	Dim msg As MSG
	Dim As Integer sW, sH
	ScreenInfo(sW, sH)
	
	Dim szAppName As ZString * 30 => "FB GUI"
	Dim As String sTitle = "Equalizer GUI"
	Dim As ULong iW, iH
	iW = 640
	iH = Int(iW * 9 / 16) + 50
	Dim As String aLables(9) = {"80 ", "120", "250", "500", "1k ", "1.8k", "3.5k", "7k ", "10k", "14k"}
	
	With wc
		.style         = CS_HREDRAW Or CS_VREDRAW
		.lpfnWndProc   = @WndProc
		.cbClsExtra    = NULL
		.cbWndExtra    = NULL
		.hInstance     = GetModuleHandle(NULL)
		.hIcon         = LoadIcon(NULL, IDI_APPLICATION)
		.hCursor       = LoadCursor(NULL, IDC_ARROW)
		.hbrBackground = CreateSolidBrush(iBgColor)
		.lpszMenuName  = NULL
		.lpszClassName = @szAppName
		.cbSize			= SizeOf(WNDCLASSEX)
	End With
	 
	RegisterClassEx(@wc)
	Dim As Long iStyle = WS_OVERLAPPEDWINDOW Or WS_VISIBLE Or WS_BORDER
	iStyle Xor = (WS_SIZEBOX Or WS_MAXIMIZEBOX)
	hWND_EQ = CreateWindowEx(WS_EX_WINDOWEDGE, wc.lpszClassName, sTitle, _
								  iStyle, _
								  (sW - iW) / 2, (sH - iH) / 2, _
								  iW, iH, _
								  NULL, NULL, wc.hInstance, NULL)

	Dim As Any Ptr hDC = GetDC(NULL)
	Dim As Integer iHeight = MulDiv(16, GetDeviceCaps(hDC, LOGPIXELSY), 72)
	ReleaseDC(NULL, hDC)
	Dim As HFONT hFont = CreateFont(iHeight, 0, 0, 0, 400, False, False, False, _
									1, OUT_DEFAULT_PRECIS, _
									CLIP_DEFAULT_PRECIS, _
									DEFAULT_QUALITY, _
									DEFAULT_PITCH, _
									"Comic Sans MS")
	
	hCheckBox_EQ = CreateWindowEx(0, "BUTTON", "On", _
													WS_TABSTOP Or WS_VISIBLE Or WS_CHILD Or BS_AUTOCHECKBOX, _
													35, 22, 50, 20,	hWND_EQ, 0, 0, 0 )
	CheckDlgButton(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ), BST_CHECKED)
											
	hCombobox_EQ = CreateWindowEx(WS_EX_CLIENTEDGE, WC_COMBOBOX, NULL, _
							   WS_CHILD Or WS_VISIBLE Or CBS_DROPDOWNLIST Or CBS_AUTOHSCROLL, _
							   (iW - 250) / 2, 20, 250, 512, hWND_EQ, Cast(HMENU, Cast(LONG_PTR, idComboBox)), GetModuleHandle(NULL), NULL)
		
	SendMessage(hCombobox_EQ, WM_SETREDRAW, Cast(WPARAM, False), Cast(LPARAM, 0))
	'https://docs.microsoft.com/en-us/windows/win32/controls/bumper-combobox-control-reference-macros
	ComboBox_AddString(hCombobox_EQ, StrPtr(Str("Flat")))
	ComboBox_AddString(hCombobox_EQ, StrPtr(Str("Pop")))
	ComboBox_AddString(hCombobox_EQ, StrPtr(Str("Rock")))
	ComboBox_AddString(hCombobox_EQ, StrPtr(Str("Jazz")))
	ComboBox_AddString(hCombobox_EQ, StrPtr(Str("Classical")))
	ComboBox_AddString(hCombobox_EQ, StrPtr(Str("Bass")))
	ComboBox_AddString(hCombobox_EQ, StrPtr(Str("Vocal Boost")))
	ComboBox_AddString(hCombobox_EQ, StrPtr(Str("Electronic")))
	SendMessage(hCombobox_EQ, WM_SETREDRAW, Cast(WPARAM, True), Cast(LPARAM, 0))
	SendMessage(hCombobox_EQ, CB_SETCURSEL, Cast(WPARAM, 0), Cast(LPARAM, 0))
	SendMessage(hCombobox_EQ, WM_SETFONT, Cast(WPARAM, hFont), Cast(LPARAM, True))
	
	Dim As Byte i, iGain_Min = -6, iGain_Max = 6
	
	For i = 0 To 9
		CreateWindowEx(0, "STATIC", aLables(i), SS_CENTER Or WS_VISIBLE Or WS_CHILD, 95 + i * 50, 270, 40, 20, hWND_EQ, 0, 0, 0)
		aSlider_EQ(i) = CreateWindowEx(NULL, TRACKBAR_CLASS, "Trackbar Control",  WS_VISIBLE Or WS_CHILD Or TBS_VERT Or TBS_BOTH Or TBS_AUTOTICKS Or TBS_ENABLESELRANGE Or TBS_TOP, _
						 			   95 + i * 50, 65, 40, 200, hWND_EQ, NULL, NULL, NULL)
		SendMessage(aSlider_EQ(i), TBM_SETRANGE, Cast(WPARAM, True), MAKELONG(iGain_Min, iGain_Max))
		SendMessage(aSlider_EQ(i), TBM_SETPOS, Cast(WPARAM, True), Cast(LPARAM, 0))
		SendMessage(aSlider_EQ(i), TBM_SETTICFREQ, Cast(WPARAM, 1), Cast(LPARAM, 0))
		SendMessage(aSlider_EQ(i), WM_CHANGEUISTATE, Cast(WPARAM, MAKELONG(UISF_HIDEFOCUS, UIS_SET)), Cast(LPARAM, 0)) 'remove focused lines
	Next

	CreateWindowEx(0, "STATIC", "+" & iGain_Max & " dB", SS_CENTER Or WS_VISIBLE Or WS_CHILD, 35, 70, 50, 15, hWND_EQ, 0, 0, 0)
	CreateWindowEx(0, "STATIC", "0 dB", SS_CENTER Or WS_VISIBLE Or WS_CHILD, 35, 157, 50, 15, hWND_EQ, 0, 0, 0)
	CreateWindowEx(0, "STATIC", iGain_Min & " dB", SS_CENTER Or WS_VISIBLE Or WS_CHILD, 35, 243, 50, 15, hWND_EQ, 0, 0, 0)
	CreateWindowEx(0, "STATIC", "Hz", SS_CENTER Or WS_VISIBLE Or WS_CHILD, 47, 270, 25, 15, hWND_EQ, 0, 0, 0)
	
	ShowWindow(hWND_EQ, SW_SHOW)
	
	While GetMessage(@msg, 0, 0, 0)
		TranslateMessage(@msg)
		DispatchMessage(@msg)
	Wend
End Sub

Sub UpdateSliders(aSettings() As Single)
	For i As Byte = 0 To 9
		SendMessage(aSlider_EQ(i), TBM_SETPOS, Cast(WPARAM, True), Cast(LPARAM, -aSettings(i)))
		If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then 
		End If
	Next
End Sub


Sub UpdateEQ(b As Integer, v As Single = 0)
    If (b < 10) Then
    End If
End Sub

Function WndProc(hWnd As HWND, uMsg As UINT, wParam As WPARAM, lParam As LPARAM) As Integer
	If hWnd = hWND_EQ Then
		Select Case uMsg
			Case WM_CLOSE
				PostQuitMessage(0)
			Case WM_CREATE
			Case WM_CTLCOLORSTATIC
				Dim As HDC hdcStatic = Cast(HDC, wParam)
				SetTextColor(hdcStatic, &hF0F0F0)
				SetBkColor(hdcStatic, iBgColor)
				Static As HBRUSH hbrBkgnd
				If hbrBkgnd = 0 Then hbrBkgnd = CreateSolidBrush(iBgColor)
				Return Cast(INT_PTR, hbrBkgnd)
			Case WM_COMMAND
				Select Case LoWord (wParam)
					Case idComboBox '...'
						Select Case HiWord(wParam)
							Case CBN_SELCHANGE
								Dim As ZString * 512 sComboCurrSel
								ComboBox_GetLBText(hCombobox_EQ, ComboBox_GetCurSel(hCombobox_EQ), @sComboCurrSel)
								Select Case sComboCurrSel
									Case "Flat"
										UpdateSliders(aEQ_Flat())
									Case "Pop"
										UpdateSliders(aEQ_Pop())
									Case "Rock"
										UpdateSliders(aEQ_Rock())
									Case "Jazz"
										UpdateSliders(aEQ_Jazz())
									Case "Classical"
										UpdateSliders(aEQ_Classical())
									Case "Bass"
										UpdateSliders(aEQ_Bass())
									Case "Vocal Boost"
										UpdateSliders(aEQ_VocalBoost())
									Case "Electronic"
										UpdateSliders(aEQ_Electronic())
								End Select
						End Select
				End Select
			Case WM_VSCROLL '''TRACKBARS
				Dim As Long iSliderPos
				Select Case lParam '...'
					Case aSlider_EQ(0)
						iSliderPos = -SendMessage(aSlider_EQ(0), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(0, iSliderPos)
						EndIf
					Case aSlider_EQ(1)
						iSliderPos = -SendMessage(aSlider_EQ(1), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(1, iSliderPos)
						EndIf
					Case aSlider_EQ(2)
						iSliderPos = -SendMessage(aSlider_EQ(2), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(2, iSliderPos)
						EndIf
					Case aSlider_EQ(3)
						iSliderPos = -SendMessage(aSlider_EQ(3), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(3, iSliderPos)
						EndIf
					Case aSlider_EQ(4)
						iSliderPos = -SendMessage(aSlider_EQ(4), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(4, iSliderPos)
						EndIf
					Case aSlider_EQ(5)
						iSliderPos = -SendMessage(aSlider_EQ(5), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(5, iSliderPos)
						EndIf
					Case aSlider_EQ(6)
						iSliderPos = -SendMessage(aSlider_EQ(6), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(6, iSliderPos)
						EndIf
					Case aSlider_EQ(7)
						iSliderPos = -SendMessage(aSlider_EQ(7), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(7, iSliderPos)
						EndIf
					Case aSlider_EQ(8)
						iSliderPos = -SendMessage(aSlider_EQ(8), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(8, iSliderPos)
						EndIf
					Case aSlider_EQ(9)
						iSliderPos = -SendMessage(aSlider_EQ(9), TBM_GETPOS, 0, 0)
						If IsDlgButtonChecked(hWND_EQ, GetDlgCtrlID(hCheckBox_EQ)) Then
							UpdateEQ(9, iSliderPos)
						EndIf
				End Select
			End Select
		End If
		Return DefWindowProc(hWnd, uMsg, wParam, lParam)
End Function

Equalizer()
Because you get the address of a WString string using StrPtr, then the String string is: "F", Chr(0), "l", Chr(0), "a", Chr(0), "t", Chr(0). The String string runs up to the first Chr(0) and the resulting String string is "F".
dodicat
Posts: 8267
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Sorting output of Dir()

Post by dodicat »

So you are saying that on UEZ's computer, literal strings like "abc" become wstr("abc") after a var, which is not allowed for var.
To convert you must do str("abc").
Is this because the German keyboard has ä, ü, ö, ß, which are not ascii and the windows registry is thus set differently to (all ascii) keyboards?
But why just after var?
Xusinboy Bekchanov
Posts: 880
Joined: Jul 26, 2018 18:28

Re: Sorting output of Dir()

Post by Xusinboy Bekchanov »

dodicat wrote: Apr 12, 2025 8:16 So you are saying that on UEZ's computer, literal strings like "abc" become wstr("abc") after a var, which is not allowed for var.
To convert you must do str("abc").
Is this because the German keyboard has ä, ü, ö, ß, which are not ascii and the windows registry is thus set differently to (all ascii) keyboards?
But why just after var?
If you save a file in UTF8 (BOM) format, and in other Unicode formats, all constant strings are WString, and if you save a file in ANSI format then all constant strings are String. Because UTF8 (BOM) format can save Unicode strings, and ANSI format can not. If you save in ANSI format anyway, all Unicode strings are converted to a question mark.
Post Reply