I'm working on making a couple of games which run on the internet; but I wanted to make them a bit more professional looking than just the little demo which I posted with the "Click It!" game... One feature which I've incorporated is a simple little LOG IN/ REGISTER screen, which I thought I'd share independently, in case anyone would ever want to include it into one of their programs in the future. Test it out and see how it works for you, and let me know if there's anything missing which I need to add to the little function.
$COLOR:32
SCREEN _NEWIMAGE(1024, 720, 32)
CLS
result = LogIn(Detail$)
PRINT Detail$
FUNCTION LogIn (Detail$)
CONST True = -1, False = 0
DIM DC AS _UNSIGNED LONG, BGC AS _UNSIGNED LONG
D = _DEST: Disp = _AUTODISPLAY
DC = _DEFAULTCOLOR: BGC = _BACKGROUNDCOLOR
BG = _COPYIMAGE(D)
'DO
' count = count + 1
' Client = _OPENCLIENT("TCP/IP:7993:172.93.60.23") 'attempt to join as client
' _LIMIT 10
'LOOP UNTIL Client <> 0 OR count > 100
'OK$ = Verify$
'IF LEFT$(OK$, 4) <> "[OK]" THEN LogIn = 0: EXIT FUNCTION
LogInScreen = _NEWIMAGE(200, 240, 32)
_DEST LogInScreen
_KEYCLEAR 'clear the buffer before we start accepting stray input as being part of our login
Xoffset = (_WIDTH(D) - _WIDTH(LogInScreen)) / 2
Yoffset = (_HEIGHT(D) - _HEIGHT(LogInScreen)) / 2
DO
CLS , DarkGray
LINE (3, 3)-(_WIDTH - 4, _HEIGHT - 4), LightGray, BF
LINE (20, 40)-(180, 200), DarkGray, BF
LINE (23, 68)-(177, 92), DarkGray, BF
LINE (23, 128)-(172, 152), DarkGray, BF
LINE (25, 70)-(175, 90), Black, BF
LINE (25, 130)-(175, 150), Black, BF
LINE (20, 210)-(100, 230), DarkGray, BF
LINE (22, 212)-(98, 228), Green, BF
LINE (101, 210)-(180, 230), DarkGray, BF
LINE (103, 212)-(178, 228), Red, BF
COLOR DarkBlue, 0
_PRINTSTRING (100 - _PRINTWIDTH("CHECKERS") / 2, 15), "CHECKERS"
_PRINTSTRING (100 - _PRINTWIDTH("User Name") / 2, 95), "User Name"
_PRINTSTRING (100 - _PRINTWIDTH("Password") / 2, 155), "Password"
COLOR Yellow
_PRINTSTRING (60 - _PRINTWIDTH("LOG IN") / 2, 212), "LOG IN"
_PRINTSTRING (141 - _PRINTWIDTH("REGISTER") / 2, 212), "REGISTER"
count = (count + 1) MOD 30
IF count MOD 15 = 0 THEN blink = NOT blink
k = _KEYHIT
SELECT CASE k
CASE 9, 13 'tab or enter to toggle between the two fields.
S = NOT S
CASE 8 'backspace
IF S THEN p$ = LEFT$(p$, LEN(p$) - 1) ELSE n$ = LEFT$(n$, LEN(n$) - 1)
CASE 27 'Escape quits before we login
'Detail$ = "[ERROR]User Exited Log In Manually"
GOTO function_exit
CASE 32 TO 255 'visable characters
IF S THEN p$ = p$ + CHR$(k) ELSE n$ = n$ + CHR$(k)
END SELECT
COLOR White
_PRINTSTRING (27, 72), RIGHT$(n$, 18): _PRINTSTRING (27, 132), RIGHT$(p$, 18)
IF blink THEN
IF S THEN l = _PRINTWIDTH(p$) ELSE l = _PRINTWIDTH(n$)
_PRINTSTRING (27 + l, 72 - 60 * S), "_"
END IF
_PUTIMAGE (Xoffset, Yoffset), LogInScreen, D
WHILE _MOUSEINPUT: WEND
mb = _MOUSEBUTTON(1): mx = _MOUSEX - Xoffset: my = _MOUSEY - Yoffset
IF mb = True AND oldmouse = False THEN
IF my >= 210 AND my <= 230 THEN 'we're in the right X/Y position
IF mx >= 20 AND mx <= 100 THEN
'Run log in code
'Send Client, "[LOG IN]" + n$ + "," + p$ 'Register a new account
'OK$ = Verify$
'Detail$ = OK$
'IF LEFT$(OK$, 4) = "[OK]" THEN LogIn = -1: GOTO function_exit 'Success
Detail$ = "User: " + n$ + CHR$(13) + "Password: " + p$
LogIn = 0
GOTO function_exit 'Failure
END IF
IF mx >= 101 AND mx <= 180 THEN
'Run register code
'Send Client, "[REGISTER]" + n$ + "," + p$ 'Login from an existing account
'OK$ = Verify$
'Detail$ = OK$
'IF LEFT$(OK$, 4) = "[OK]" THEN LogIn = -1: GOTO function_exit
Detail$ = "User: " + n$ + CHR$(13) + "Password: " + p$
LogIn = 0
GOTO function_exit
END IF
ELSEIF my >= 70 AND my <= 90 AND mx >= 20 AND mx <= 180 THEN
S = 0
ELSEIF my >= 130 AND my <= 150 AND mx >= 20 AND mx <= 180 THEN
S = -1
END IF
END IF
'_DISPLAY
_LIMIT 30
oldmouse = mb
LOOP
function_exit: 'Safely restore our settings.
_DEST D
IF Disp THEN _AUTODISPLAY
_PUTIMAGE , BG, D 'restore the background
COLOR DC, BGC
_FREEIMAGE BG
END FUNCTION
PS: If you're not using the latest Development Builds, the $COLOR:32 version isn't going to work for you. Just replace the colors inside with whatever color scheme you'd like for the pop up to have for you. ;)