It's not exactly a glitch, more like how DB was coded (I think). When it was written I think the most common mouse had 2 buttons and for DBC to read a third button, they coded the result as
button1 | button2
That means if button1=1 and button2=2, then the result is 3 if both are pressed at the same time. I think this carried over as a stand in for button 3. Anyway, with a middle mouse button, the result is 4 so it doesn't jive well with 3 being returned from the DBC function mouseclick().
The solution, the windows api - works in both fullscreen and windowed mode:
set window on
sync on
sync rate 0
user32=1
load dll "user32.dll",user32
do
cls
mc=mouse_click(user32)
text 50,50,str$(mc)
sync
loop
function mouse_click(user32)
mc=0
leftclick = Call Dll(user32,"GetAsyncKeyState",01)
rightclick = Call Dll(user32,"GetAsyncKeyState",02)
middleclick = Call Dll(user32,"GetAsyncKeyState",04)
if leftclick then exitfunction 1
if rightclick then exitfunction 2
if middleclick then exitfunction 4
endfunction mc
Enjoy your day.