RE: _TITLE and extended ASCII characters. - Pete - 11-15-2022
@Spriggsy
Yep, we've now come full circle. That's what I was getting by using...
Code: (Select All) _TITLE CHR$(240) + " Foo"
A real puzzle, this one.
mn might be on to something here as well. Since your code prints the power of 2 symbol in the IDE, we may be needing to also map to a different code page. Too many rabbit holes for this one operation. https://www.codetable.net/decimal/8801 is a perfect symbol for "MENU" as it is often seen on mobile HTML pages. I'll probably settle for the box symbol I get with CHR$(4) instead.
Pete
RE: _TITLE and extended ASCII characters. - Pete - 11-15-2022
Anyway, I'll give you an example of how I'm using it...
Click the transparent box symbol and just pretend it's three horizontal lines for now.
Code: (Select All) 101
$RESIZE:ON
_DELAY .1
DIM SHARED idx, sam_mode
WIDTH 50, 25
_DELAY .1
a = _DESKTOPWIDTH - (_FONTWIDTH * _WIDTH)
_SCREENMOVE a, 0
fontsize% = 12
style$ = "monospace"
fontpath$ = ENVIRON$("SYSTEMROOT") + "\fonts\lucon.ttf"
font& = _LOADFONT(fontpath$, fontsize%, style$)
_FONT font&
CONST HWND_TOPMOST%& = -1
CONST SWP_NOSIZE%& = &H1
CONST SWP_NOMOVE%& = &H2
CONST SWP_SHOWWINDOW%& = &H40
CONST KEYEVENTF_KEYUP = &H2
CONST VK_ALT = &H12 'Alt key
REDIM SHARED Hold AS POINTAPI
TYPE POINTAPI
X_Pos AS LONG
Y_Pos AS LONG
END TYPE
DECLARE DYNAMIC LIBRARY "user32"
FUNCTION GetAsyncKeyState% (BYVAL vkey AS LONG)
FUNCTION GetCursorPos (lpPoint AS POINTAPI)
FUNCTION FindWindowA& (BYVAL ClassName AS _OFFSET, WindowName$) 'handle by title
FUNCTION ShowWindow& (BYVAL hwnd AS _OFFSET, BYVAL nCmdShow AS LONG) 'maximize process
FUNCTION GetForegroundWindow& 'Find currently focused process handle
FUNCTION SetWindowPos& (BYVAL hWnd AS LONG, BYVAL hWndInsertAfter AS _OFFSET, BYVAL X AS INTEGER, BYVAL Y AS INTEGER, BYVAL cx AS INTEGER, BYVAL cy AS INTEGER, BYVAL uFlags AS _OFFSET)
SUB SENDKEYS ALIAS keybd_event (BYVAL bVk AS LONG, BYVAL bScan AS LONG, BYVAL dwFlags AS LONG, BYVAL dwExtraInfo AS LONG)
END DECLARE
_CONTROLCHR OFF
title$ = CHR$(4) + " Sam-Clip"
_TITLE (title$)
_DELAY .1
DIM SHARED hWnd AS LONG
hWnd = _WINDOWHANDLE
TYPE ClipType
clip AS STRING
fil AS STRING
cnt AS INTEGER
var AS INTEGER
mrgn AS INTEGER ' margins left and right
END TYPE
DIM SHARED AS ClipType a, c, placement, paste, header, lt, rt, tp, bt, myfile, hlght, menu
REDIM SHARED clipper$(_HEIGHT * 2), clipper%(_HEIGHT * 2)
rt.mrgn = 5: lt.mrgn = 5: tp.mrgn = 3: bt.mrgn = 2
IF lt.mrgn = 0 THEN lt.mrgn = 1 ' Default.
IF tp.mrgn = 0 THEN tp.mrgn = 1 ' Default.
DO: LOOP UNTIL _RESIZE = 0
DO
_LIMIT 60
IF _SCREENICON THEN _DELAY .2: _CONTINUE ' Disable when minimized.
z = GetCursorPos(Hold)
FGwin& = GetForegroundWindow&
IF hWnd <> FGwin& THEN ' QB64 no longer in focus.
y& = SetWindowPos&(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE + SWP_SHOWWINDOW)
END IF
' Title bar.
IF Hold.Y_Pos >= _SCREENY AND Hold.Y_Pos <= _SCREENY + 24 AND Hold.X_Pos >= _SCREENX + 36 AND Hold.X_Pos <= _SCREENX + 48 THEN
IF GetAsyncKeyState(1) < 0 THEN
IF menu.var = 0 THEN CALL sam_menu ' Isolated sub.
END IF
END IF
LOOP
END
SUB keypress (b$)
b$ = INKEY$
END SUB
SUB sam_menu
y = CSRLIN: x = POS(0)
LOCATE , , 0 ' Hide cursor
DO: _LIMIT 10: LOOP UNTIL GetAsyncKeyState(1) = 0
DO
z = GetCursorPos(Hold)
_LIMIT 30
IF Hold.Y_Pos >= _SCREENY AND Hold.Y_Pos <= _SCREENY + 24 AND Hold.X_Pos >= _SCREENX + 36 AND Hold.X_Pos <= _SCREENX + 48 THEN
IF GetAsyncKeyState(1) < 0 THEN
EXIT DO
END IF
END IF
CALL keypress(b$)
IF b$ = CHR$(27) THEN EXIT DO
IF menu.var = 0 THEN
menu.var = -1 ' Menu open.
PCOPY 0, 1
PALETTE 3, 56
COLOR 1, 7
LOCATE 1, 1
PRINT CHR$(218) + STRING$(18, 196) + CHR$(191)
FOR i = 1 TO 14
PRINT CHR$(179); SPACE$(18) + CHR$(179);
COLOR 7, 3: PRINT CHR$(SCREEN(CSRLIN, POS(0))) + CHR$(SCREEN(CSRLIN, POS(0) + 1)): COLOR 1, 7
NEXT
PRINT CHR$(192) + STRING$(18, 196) + CHR$(217);: COLOR 7, 3: PRINT CHR$(SCREEN(CSRLIN, POS(0))) + CHR$(SCREEN(CSRLIN, POS(0) + 1))
LOCATE , 3:
FOR i = 1 TO 20
PRINT CHR$(SCREEN(CSRLIN, POS(0)));
NEXT
COLOR 7, 0
END IF
LOOP
menu.var = 0
PCOPY 1, 0
LOCATE y, x
_KEYCLEAR
DO: _LIMIT 10: LOOP UNTIL GetAsyncKeyState(1) = 0
END SUB
Pete
RE: _TITLE and extended ASCII characters. - SpriggsySpriggs - 11-15-2022
(11-15-2022, 09:05 PM)Pete Wrote: Anyway, I'll give you an example of how I'm using it...
Click the transparent box symbol and just pretend it's three horizontal lines for now.
Code: (Select All) 101
$RESIZE:ON
_DELAY .1
DIM SHARED idx, sam_mode
WIDTH 50, 25
_DELAY .1
a = _DESKTOPWIDTH - (_FONTWIDTH * _WIDTH)
_SCREENMOVE a, 0
fontsize% = 12
style$ = "monospace"
fontpath$ = ENVIRON$("SYSTEMROOT") + "\fonts\lucon.ttf"
font& = _LOADFONT(fontpath$, fontsize%, style$)
_FONT font&
CONST HWND_TOPMOST%& = -1
CONST SWP_NOSIZE%& = &H1
CONST SWP_NOMOVE%& = &H2
CONST SWP_SHOWWINDOW%& = &H40
CONST KEYEVENTF_KEYUP = &H2
CONST VK_ALT = &H12 'Alt key
REDIM SHARED Hold AS POINTAPI
TYPE POINTAPI
X_Pos AS LONG
Y_Pos AS LONG
END TYPE
DECLARE DYNAMIC LIBRARY "user32"
FUNCTION GetAsyncKeyState% (BYVAL vkey AS LONG)
FUNCTION GetCursorPos (lpPoint AS POINTAPI)
FUNCTION FindWindowA& (BYVAL ClassName AS _OFFSET, WindowName$) 'handle by title
FUNCTION ShowWindow& (BYVAL hwnd AS _OFFSET, BYVAL nCmdShow AS LONG) 'maximize process
FUNCTION GetForegroundWindow& 'Find currently focused process handle
FUNCTION SetWindowPos& (BYVAL hWnd AS LONG, BYVAL hWndInsertAfter AS _OFFSET, BYVAL X AS INTEGER, BYVAL Y AS INTEGER, BYVAL cx AS INTEGER, BYVAL cy AS INTEGER, BYVAL uFlags AS _OFFSET)
SUB SENDKEYS ALIAS keybd_event (BYVAL bVk AS LONG, BYVAL bScan AS LONG, BYVAL dwFlags AS LONG, BYVAL dwExtraInfo AS LONG)
END DECLARE
_CONTROLCHR OFF
title$ = CHR$(4) + " Sam-Clip"
_TITLE (title$)
_DELAY .1
DIM SHARED hWnd AS LONG
hWnd = _WINDOWHANDLE
TYPE ClipType
clip AS STRING
fil AS STRING
cnt AS INTEGER
var AS INTEGER
mrgn AS INTEGER ' margins left and right
END TYPE
DIM SHARED AS ClipType a, c, placement, paste, header, lt, rt, tp, bt, myfile, hlght, menu
REDIM SHARED clipper$(_HEIGHT * 2), clipper%(_HEIGHT * 2)
rt.mrgn = 5: lt.mrgn = 5: tp.mrgn = 3: bt.mrgn = 2
IF lt.mrgn = 0 THEN lt.mrgn = 1 ' Default.
IF tp.mrgn = 0 THEN tp.mrgn = 1 ' Default.
DO: LOOP UNTIL _RESIZE = 0
DO
_LIMIT 60
IF _SCREENICON THEN _DELAY .2: _CONTINUE ' Disable when minimized.
z = GetCursorPos(Hold)
FGwin& = GetForegroundWindow&
IF hWnd <> FGwin& THEN ' QB64 no longer in focus.
y& = SetWindowPos&(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE + SWP_SHOWWINDOW)
END IF
' Title bar.
IF Hold.Y_Pos >= _SCREENY AND Hold.Y_Pos <= _SCREENY + 24 AND Hold.X_Pos >= _SCREENX + 36 AND Hold.X_Pos <= _SCREENX + 48 THEN
IF GetAsyncKeyState(1) < 0 THEN
IF menu.var = 0 THEN CALL sam_menu ' Isolated sub.
END IF
END IF
LOOP
END
SUB keypress (b$)
b$ = INKEY$
END SUB
SUB sam_menu
y = CSRLIN: x = POS(0)
LOCATE , , 0 ' Hide cursor
DO: _LIMIT 10: LOOP UNTIL GetAsyncKeyState(1) = 0
DO
z = GetCursorPos(Hold)
_LIMIT 30
IF Hold.Y_Pos >= _SCREENY AND Hold.Y_Pos <= _SCREENY + 24 AND Hold.X_Pos >= _SCREENX + 36 AND Hold.X_Pos <= _SCREENX + 48 THEN
IF GetAsyncKeyState(1) < 0 THEN
EXIT DO
END IF
END IF
CALL keypress(b$)
IF b$ = CHR$(27) THEN EXIT DO
IF menu.var = 0 THEN
menu.var = -1 ' Menu open.
PCOPY 0, 1
PALETTE 3, 56
COLOR 1, 7
LOCATE 1, 1
PRINT CHR$(218) + STRING$(18, 196) + CHR$(191)
FOR i = 1 TO 14
PRINT CHR$(179); SPACE$(18) + CHR$(179);
COLOR 7, 3: PRINT CHR$(SCREEN(CSRLIN, POS(0))) + CHR$(SCREEN(CSRLIN, POS(0) + 1)): COLOR 1, 7
NEXT
PRINT CHR$(192) + STRING$(18, 196) + CHR$(217);: COLOR 7, 3: PRINT CHR$(SCREEN(CSRLIN, POS(0))) + CHR$(SCREEN(CSRLIN, POS(0) + 1))
LOCATE , 3:
FOR i = 1 TO 20
PRINT CHR$(SCREEN(CSRLIN, POS(0)));
NEXT
COLOR 7, 0
END IF
LOOP
menu.var = 0
PCOPY 1, 0
LOCATE y, x
_KEYCLEAR
DO: _LIMIT 10: LOOP UNTIL GetAsyncKeyState(1) = 0
END SUB
Pete
Does the code only work on 32 bit? I ran it on my computer and didn't see anything to click. Just a black screen.
RE: _TITLE and extended ASCII characters. - Pete - 11-15-2022
Right, but look at the title bar and click the little square to the left of "Sam-Clip"
Unconventional...
Pete
RE: _TITLE and extended ASCII characters. - SpriggsySpriggs - 11-15-2022
I think something got lost in pasting because I don't get any square. However, clicking on the "S" in "Sam-Clip" works.
RE: _TITLE and extended ASCII characters. - Pete - 11-15-2022
Okay then, Houston we have another anomaly.
So my 64-bit Win 10 shows the box symbol. It was added to the title bar by using CHR$(4), the diamond symbol in QB64. Conclusion, _TITLE doesn't like a lot of non-alphabetical / noon-numeric characters. Booooooo!
Pete
RE: _TITLE and extended ASCII characters. - SpriggsySpriggs - 11-15-2022
(11-15-2022, 09:46 PM)Pete Wrote: Okay then, Houston we have another anomaly.
So my 64-bit Win 10 shows the box symbol. It was added to the title bar by using CHR$(4), the diamond symbol in QB64. Conclusion, _TITLE doesn't like a lot of non-alphabetical / noon-numeric characters. Booooooo!
Pete Very, very odd. All I did was copy your code and paste it into my IDE. Never saw any little box. I wonder what happened.
RE: _TITLE and extended ASCII characters. - mnrvovrfc - 11-15-2022
If Windows allows the "systemwide" font to be changed, even if it could look ugly, it might be crazy enough to produce an Unicode character. What sucks is trying to determine which font. Also get it to cooperate displaying title bars and stuff like that, not just File Explorer display or dialog box content.
This is the main reason why an extension of OpenGL offers a toolkit for creating dialog boxes, windows, buttons, menus etc. which don't call on any "native" operating system function, but the programmer has to handle all the drawing and event handling. The "characters" have to be drawn like any other shapes, or a font has to be created like the "Roman" one that comes with OpenGL that I saw somewhere in the library creation while building QB64PE executable. Now I'm not sure about this but at least one game library has it.
RE: _TITLE and extended ASCII characters. - Pete - 11-15-2022
One thing I find interesting is that when I add the CHR$(4) in the front of the _TITLE to produce that box symbol, the Task Manager completely ignores it, and just lists the program as Sam-Clip.exe
Pete
RE: _TITLE and extended ASCII characters. - SMcNeill - 11-15-2022
One thing which I haven't seen anyone address at all yet -- Is the font used by windows for the title A UNICODE FONT?? It's impossible to print unicode 8801 when your default font only has 256 characters stored in it, for example.
What we have may work just peachy fine -- as long as you swap over to the proper font to display the character for you.
|