Menu
I am working on it !
Announcement
Collapse
No announcement yet.
End of the 80x25 Console
Collapse
X
-
Scrolling window
Hi Rick,
I was just about to post my last code as I found my answer in MSDN Web Site by reading on API call instructions about mouse handling.
I found a neat way to add Scroll simply by using GRAPHIC COPY to move all or part of the window up, down and sideway.
Try this last demo and tell me what you think about it.
Thanks all the same for your hint but my trick is much simpler for me.
Code:'A small Graphic 1024x768 input screen demo with #CONSOLE OFF to test the new GRAPHIC INKEY$ and GRAPHIC SET FONT 'Full keyboard and mouse handling including the middle button and scroll wheel 'Set X2 to PixW and Y2 to PixH for full screen window 'The left top Heading will show mouse position and wheel move up or down. The cursor will also move at the same time 'The center will show all three button clicks 'The right one the number of Rows and Columns possible with the chosen font plus the caracter grid size 'Enter text and hit Return for next line or move anywhere with the arrows. 'Home and End move at line beginning and end. PgUp and PgDn scroll whole page. 'Click anywhere on screen to position cursor with left or right button and enter text 'Move mouse over green EXIT Button for MouseOver effect. 'Program will end with Esc or Exit button or closing window #COMPILE EXE #CONSOLE OFF #INCLUDE "Win32Api.inc" DEFLNG a-z GLOBAL GrDialogProc AS LONG GLOBAL GrStaticProc AS LONG GLOBAL mx AS LONG,my AS LONG ' Mouse x and y GLOBAL lb AS LONG,rb AS LONG ' Left and right mouse button GLOBAL mm AS LONG ' Detect mouse movements GLOBAL bg AS LONG,fg AS LONG ' Background and foreground colors GLOBAL wm AS LONG,mb AS LONG ' Wheel mouse and middle button FUNCTION GrDlgProc(BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG FUNCTION = CallWindowProc(GrDialogProc, hWnd, wMsg, wParam, lParam) END FUNCTION FUNCTION GrProc(BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG LOCAL p AS pointapi SELECT CASE wMsg CASE %WM_MOUSEMOVE mm=1: mx=LO(WORD,lParam): my=HI(WORD,lParam) ' Current Mouse X and Y Position in the graphic window CASE %WM_LBUTTONDOWN lb=1: FUNCTION=0: EXIT FUNCTION ' Left button pressed CASE %WM_RBUTTONDOWN rb=1: FUNCTION=0: EXIT FUNCTION ' Right button pressed CASE %WM_MBUTTONDOWN mb=1: FUNCTION=0: EXIT FUNCTION ' Middle button pressed CASE %WM_MOUSEWHEEL wm=HI(WORD,wParam): IF wm>32768 THEN wm=-1 ELSE wm=1 ' Wheel turned (+)=up (-)=down FUNCTION=0: EXIT FUNCTION END SELECT FUNCTION = CallWindowProc(GrStaticProc, hWnd, wMsg, wParam, lParam) END FUNCTION FUNCTION PBMAIN () AS LONG LOCAL hGraphicWindow AS LONG DESKTOP GET CLIENT TO PixW,PixH x=0: y=2: x1=0: y1=0: x2=1024: y2=768 ' Set X2=PixW and Y2=PixH for full screen 'x2=pixw: y2=pixh x1=PixW-x2 FONT NEW "Lucida Console",12,1,0,0,0 TO f1 ' 12=79x36 bold font 12=85x36 regular font FONT NEW "Lucida console",9,1,0,0,0 TO f2 ' 9=51x102 bold font 9=51x114 regular font caption$="Graphic console input test Enter text and hit Return or Click Mouse to next input position Esc to end" GRAPHIC WINDOW caption$,x1,y1,x2,y2 TO hGraphicWindow ' Start Graphic Window hStatic = GetWindow(hGraphicWindow, %GW_CHILD) ' Retrieve static handle of graphic window GrStaticProc = SetWindowLong(hStatic, %GWL_WNDPROC, CODEPTR(GrProc)) ' Subclasses Graphic control GRAPHIC ATTACH hGraphicWindow,0,REDRAW GRAPHIC SET FONT f2: GRAPHIC CHR SIZE TO carw2!,carh2! ' Find pixel width and height of f2 graphic font GRAPHIC SET FONT f1: GRAPHIC CHR SIZE TO carw!,carh! ' Find pixel width and height of f1 graphic font GRAPHIC CLEAR %BLACK,%GREEN: GRAPHIC COLOR %GREEN,%BLACK ' Black background with Green text like old time MaxCol=x2/CarW!: MaxRow=y2/CarH! ' Maximums will depend on number of pixels on desktop GRAPHIC WIDTH 1 GRAPHIC REDRAW ' Show screen background instantly GOSUB TopHeading: GRAPHIC COLOR %GREEN,%BLACK ' Show mouse result csr=-2 ' Empty box cursor not masking caracters KeyMouse:REM Keyboard and Mouse input GRAPHIC GET DC TO hwin: IF hwin=0 THEN END ' Window has been closed by mouse GRAPHIC GET PIXEL (x!+1,y!+1) TO bg: GRAPHIC GET PIXEL (x!+1,y!+1) TO fg ' Store previous colors GRAPHIC INKEY$ TO ink$: SLEEP 1: ink%=0: GOSUB CursorOn ' Place cursor at next input 'Mouse section IF lb THEN GOSUB CursorOff: x=mx/CarW!-1: y=my/CarH!-1: GOSUB CursorOn: IF mo=1 THEN END ' Left Button IF rb THEN GOSUB CursorOff: x=mx/CarW!-1: y=my/CarH!-1: GOSUB CursorOn: IF mo=1 THEN END ' Right Button IF wm THEN GOSUB CursorOff: y=y-wm: GOSUB CursorOn: IF mo=1 THEN END ' Wheel mouse IF lb OR rb OR mm OR wm OR mb THEN GOSUB prompt ' Show mouse movements and where both button are clicked IF ink$="" THEN KeyMouse 'Keyboard special key section IF LEN(ink$)=2 THEN ink%=ASC(RIGHT$(ink$,1)): ink$="" IF ink%=71 THEN GOSUB CursorOff: x=0 ' End IF ink%=72 THEN GOSUB CursorOff: IF y>2 THEN y=y-1 ELSE BEEP ' Up arrow IF ink%=75 THEN GOSUB CurSorOff: IF x>0 THEN x=x-1 ELSE BEEP ' Left arrow IF ink%=77 THEN GOSUB CurSorOff: IF x<MaxCol-1 THEN x=x+1 ELSE BEEP ' Right arrow IF ink%=80 THEN GOSUB CursorOff: IF y<MaxRow-2 THEN y=y+1 ELSE BEEP: y=MaxRow ' Down arrow IF ink%=79 THEN GOSUB CursorOff: x=MaxCol-1 ' Home 'Keyboard scrolling section 'Insert one space and move line right IF ink%=82 THEN GOSUB CursorOff: GRAPHIC COPY hGraphicWindow, 0,(x*CarW!,y*CarH!)-((MaxCol)*CarW!,y*CarH!+CarH!) TO ((x+1)*CarW!,y*CarH!): ink$=" ": GOSUB ScrnPrint 'Delete one space and move line left IF ink%=83 THEN GOSUB CursorOff: GRAPHIC COPY hGraphicWindow, 0,(x*CarW!+CarW!,y*CarH!)-((MaxCol)*CarW!,y*CarH!+CarH!) TO (x*CarW!,y*CarH!): ink$=" ": x0=x: x=MaxCol-1: GOSUB ScrnPrint: x=x0 'Scroll whole screen up IF ink%=73 THEN GOSUB CursorOff: GRAPHIC COPY hGraphicWindow, 0,(0,3*CarH!)-(MaxCol*CarW!,MaxRow*CarH!) TO (0,2*CarH!): ink$="": x=0: y=2: GOSUB ScrnPrint 'Scrool whole screen down IF ink%=81 THEN GOSUB CursorOff: GRAPHIC COPY hGraphicWindow, 0,(0,2*CarH!)-(MaxCol*CarW!,MaxRow*CarH!) TO (0,3*CarH!): ink$=STRING$(MaxCol,32): x=0: y=2: GOSUB ScrnPrint GOTO KeyMouse END IF 'Keyboard regular key section IF ink$=CHR$(27) THEN END IF ink$=CHR$(8) AND x>0 THEN ink$=" ": GOSUB CursorOff: x=x-1: GOSUB ScrnPrint: ink$="" IF ink$=CHR$(13) THEN GOSUB CursorOff: x=0: IF y<MaxRow-1 THEN y=y+1 ELSE BEEP IF ink$>CHR$(31) THEN GOSUB CursorOff: GOSUB ScrnPrint: IF x<MaxCol-1 THEN x=x+1 ELSE BEEP GOTO KeyMouse ScrnPrint:REM Set position and print graphic caracters on screen winh big font F1 GRAPHIC SET POS (x*CarW!,y*CarH!): GRAPHIC PRINT ink$: GRAPHIC REDRAW RETURN CursorOn:REM Simple non blinking empty cursor size of caracter box IF y>1 AND csr <>0 THEN GRAPHIC BOX (x*CarW!,y*CarH!)-(x*CarW!+CarW!,y*CarH!+CarH!),0,%WHITE,csr: csr=-2: GRAPHIC REDRAW RETURN CursorOff:REM erase cursor at end of line CR or mouse click and redraw at next position IF y>1 THEN GRAPHIC BOX (x*CarW!,y*CarH!)-(x*CarW!+CarW!,y*CarH!+CarH!),0,%BLACK,csr: GRAPHIC REDRAW RETURN TopHeading:REM Top box to display mouse results with small font GRAPHIC SET FONT f2 GRAPHIC BOX (0,y1)-(x2-2,CarH2!*2+3),25,%WHITE,%WHITE ' Outer box GRAPHIC BOX (3,y1+3)-(x2-5,CarH2!*2),25,%BLACK,%YELLOW ' Inner box GRAPHIC BOX (x2-CarW!*6+5,y1+6)-(x2-8,CarH2!*2-3),25,%BLACK,%GREEN ' Exit box GRAPHIC COLOR %BLACK,%GREEN GRAPHIC SET POS (x2-CarW2!*37,CarH2!*.6): GRAPHIC PRINT STR$(MaxRow)+" Rows by"+STR$(MaxCol)+" Columns " GRAPHIC SET POS (x2-CarW2!*7,CarH2!*.6): GRAPHIC PRINT" Exit " GRAPHIC SET POS (x2-CarW2!*15,CarH2!*.6): GRAPHIC PRINT STR$(carw!)+"x"+LTRIM$(STR$(carh!))+" " ' Show size of caracter box GRAPHIC REDRAW GRAPHIC SET FONT f1 RETURN Prompt:REM Show mouse events with small font GRAPHIC SET FONT f2 GRAPHIC COLOR %BLACK,%YELLOW IF mm THEN GRAPHIC SET POS (1*CarW2!,1*CarH2!*.6): GRAPHIC PRINT"Mouse move"+STR$(mx)+","+LTRIM$(STR$(my))+" " IF wm=1 THEN GRAPHIC SET POS (1*CarW2!,1*CarH2!*.6): GRAPHIC PRINT"Wheel mouse up " IF wm=-1 THEN GRAPHIC SET POS (1*CarW2!,1*CarH2!*.6): GRAPHIC PRINT"Wheel mouse down " IF lb THEN GRAPHIC SET POS (28*CarW2!,1*CarH2!*.6): GRAPHIC PRINT"Left button clicked at"+STR$(mx)+","+LTRIM$(STR$(my))+" " IF mb THEN GRAPHIC SET POS (28*CarW2!,1*CarH2!*.6): GRAPHIC PRINT"Middle button clicked at"+STR$(mx)+","+LTRIM$(STR$(my))+" " IF rb THEN GRAPHIC SET POS (28*CarW2!,1*CarH2!*.6): GRAPHIC PRINT"Right button clicked at"+ STR$(mx)+","+LTRIM$(STR$(my))+" " IF mo=0 AND mx>x2-CarW!*6+5 AND my<CarH!*2-12 THEN mo=1: GRAPHIC COLOR %BLACK,%RED: GOSUB MouseOver ' Button on IF mo=1 AND mx<x2-CarW!*6+5 OR my>CarH!*2-12 THEN mo=0: GRAPHIC COLOR %BLACK,%GREEN: GOSUB MouseOver ' Button off lb=0: rb=0: mm=0: mb=0: wm=0: GRAPHIC REDRAW: GRAPHIC COLOR %GREEN,%BLACK GRAPHIC SET FONT f1 RETURN MouseOver:REM Show Mouse Over event with small font GRAPHIC SET FONT f2 GRAPHIC SET POS (x2-CarW2!*7,CarH2!*.6): GRAPHIC PRINT" Exit " GRAPHIC SET FONT f1 RETURN END FUNCTION
Leave a comment:
-
-
Hint.
A graphics window is not per se a scrollable window. It is the display of GDI graphics added to its underlying bitmap. So in order to scroll you need a second bitmap, which is your composite, virtual menu bitmap . When you capture the middle button you then need to:- Determine if the button is held down and ...
- Determine the amount and direction of movement
- After sufficient movement:
- With the REDRAW option on
- Clear the GW
- Copy the corresponding portion of the virtual menu bitmap to GW
- reset hotspot schema to correspond to displayed items (offset)
- REDRAW
Leave a comment:
-
Why does Middle scrolling button end program ?
Well, I need help again !
My little graphic console program work like a charm and I am in the process of building all my next apps that way.
But...
I noticed that if you scroll up or down with the middle button, you end the program. even if off focus ?
I thought that PBCC could not access that button ?
But since I subclassed that window, it must be that the Windows API come into play. As I don't know much about that, I need help from you expert Windows programmers.
So, if you want to try my little program and give me your talented answer, I will be very gratefull
If I can add that scroll to my menus, it will make my day
Many thanks to you all hotshot programmers
Leave a comment:
-
-
Rube Goldberg Cursor code
Rick,
I followed your suggestion about the new GRAPHIC SET FONT Command and added a few improvements.
I changed the Blinking Cursor code as I was having a lot of timing problems and it was slowing my old machines too much.
I now use a simple box exactly the size of the Font Matrix and I does work like a charm. Simpler is always better.
That Demo now has full keyboard input and can also scroll the whole or part of the screen up and down or sideway.
For those members who are porting old QB application, I would suggest looking at this Technique instead of using LINE INPUT Command for data entry.
Sorry about the long code lines but with a big screen, it work fine as you see all the code without scrolling.
As for the GOTO, they work quite well and I remember a Quote from our Hawai member "If it is stupid and it works, it it not stupid"
Now I will start writing the real program but I expect I will learn a lot more on the way.
Code:'A small Graphic 1024x768 input screen demo with #CONSOLE OFF to test the new GRAPHIC INKEY$ and GRAPHIC SET FONT 'I stopped using GRAPHIC WINDOW CLICK Command as it will not catch mouse move and is limited to the left button 'I have added full keyboard handling in order to make any data entry possible 'Cursor has been changed to a non blinking box as making a blinking one was a real pain 'Set X2 to PixW and Y2 to PixH for full screen window 'The top Heading will show mouse position and button click and also the number of Rows and Columns for your chosen Font size 'Enter text and hit Return for next line. Esc to end or shut window with mouse or click Green EXIT Button 'Click anywhere on screen to position cursor with left or right button and enter text 'Move mouse over green EXIT Button for MouseOver effect #COMPILE EXE #CONSOLE OFF #INCLUDE "Win32Api.inc" DEFLNG a-z GLOBAL GrDialogProc AS LONG GLOBAL GrStaticProc AS LONG GLOBAL mx AS LONG,my AS LONG ' Mouse x and y GLOBAL lb AS LONG,rb AS LONG ' Left and right mouse button GLOBAL mm AS LONG ' Detect mouse movements GLOBAL bg AS LONG,fg AS LONG ' Background and foreground colors FUNCTION GrDlgProc(BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG FUNCTION = CallWindowProc(GrDialogProc, hWnd, wMsg, wParam, lParam) END FUNCTION FUNCTION GrProc(BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG SELECT CASE wMsg CASE %WM_MOUSEMOVE mx=LO(WORD,lParam): my=HI(WORD,lParam): mm=1 ' Current Mouse X and Y Position in the graphic window CASE %WM_LBUTTONDOWN lb=1: mx=LO(WORD,lParam): my=HI(WORD,lParam) ' Left button pressed CASE %WM_RBUTTONDOWN rb=1: mx=LO(WORD,lParam): my=HI(WORD,lParam) ' Right button pressed END SELECT FUNCTION = CallWindowProc(GrStaticProc, hWnd, wMsg, wParam, lParam) END FUNCTION FUNCTION PBMAIN () AS LONG LOCAL hGraphicWindow AS LONG DESKTOP GET CLIENT TO PixW,PixH x=0: y=2: x1=0: y1=0: x2=1024: y2=768 ' Set X2=PixW and Y2=PixH for full screen x1=PixW-x2 FONT NEW "Lucida console",12,1,0,0,0 TO f1 ' 12=79x36 bold font 12=85x36 regular font FONT NEW "Lucida console",9,1,0,0,0 TO f2 ' 9=51x102 bold font 9=51x114 regular font caption$="Graphic console input test Enter text and hit Return or Click Mouse to next input position Esc to end" GRAPHIC WINDOW caption$,x1,y1,x2,y2 TO hGraphicWindow ' Start Graphic Window hStatic = GetWindow(hGraphicWindow, %GW_CHILD) ' Retrieve static handle of graphic window GrStaticProc = SetWindowLong(hStatic, %GWL_WNDPROC, CODEPTR(GrProc)) ' Subclasses Graphic control GRAPHIC ATTACH hGraphicWindow,0,REDRAW GRAPHIC SET FONT f2: GRAPHIC CHR SIZE TO carw2!,carh2! ' Find pixel width and height of f2 graphic font GRAPHIC SET FONT f1: GRAPHIC CHR SIZE TO carw!,carh! ' Find pixel width and height of f1 graphic font GRAPHIC CLEAR %BLACK,%GREEN: GRAPHIC COLOR %GREEN,%BLACK ' Black background with Green text like old time MaxCol=x2/CarW!: MaxRow=y2/CarH! ' Maximums will depend on number of pixels on desktop GRAPHIC WIDTH 1 GRAPHIC REDRAW ' Show screen background instantly GOSUB TopHeading: GRAPHIC COLOR %GREEN,%BLACK ' Show mouse result csr=-2 ' Empty box cursor not masking caracters KeyMouse:REM Keyboard and Mouse input GRAPHIC GET DC TO hwin: IF hwin=0 THEN END ' Window has been closed by mouse GRAPHIC GET PIXEL (x!+1,y!+1) TO bg: GRAPHIC GET PIXEL (x!+1,y!+1) TO fg ' Store previous colors GRAPHIC INKEY$ TO ink$: SLEEP 1: ink%=0: GOSUB CursorOn 'Mouse section IF lb THEN GOSUB CursorOff: x=mx/CarW!-1: y=my/CarH!-1: GOSUB CursorOn: IF mo=1 THEN END ' Left Button IF rb THEN GOSUB CursorOff: x=mx/CarW!-1: y=my/CarH!-1: GOSUB CursorOn: IF mo=1 THEN END ' Right Button IF lb OR rb OR mm THEN GOSUB prompt ' Show mouse movements and where both button are clicked IF ink$="" THEN KeyMouse 'Keyboard special key section IF LEN(ink$)=2 THEN ink%=ASC(RIGHT$(ink$,1)): ink$="" IF ink%=71 THEN GOSUB CursorOff: x=0 ' End IF ink%=72 THEN GOSUB CursorOff: IF y>2 THEN y=y-1 ELSE BEEP ' Up arrow IF ink%=75 THEN GOSUB CurSorOff: IF x>0 THEN x=x-1 ELSE BEEP ' Left arrow IF ink%=77 THEN GOSUB CurSorOff: IF x<MaxCol-1 THEN x=x+1 ELSE BEEP ' Right arrow IF ink%=80 THEN GOSUB CursorOff: IF y<MaxRow-2 THEN y=y+1 ELSE BEEP: y=MaxRow ' Down arrow IF ink%=79 THEN GOSUB CursorOff: x=MaxCol-1 ' Home 'Keyboard scrolling section 'Insert one space and move line right IF ink%=82 THEN GOSUB CursorOff: GRAPHIC COPY hGraphicWindow, 0,(x*CarW!,y*CarH!)-((MaxCol)*CarW!,y*CarH!+CarH!) TO ((x+1)*CarW!,y*CarH!): ink$=" ": GOSUB ScrnPrint 'Delete one space and move line left IF ink%=83 THEN GOSUB CursorOff: GRAPHIC COPY hGraphicWindow, 0,(x*CarW!+CarW!,y*CarH!)-((MaxCol)*CarW!,y*CarH!+CarH!) TO (x*CarW!,y*CarH!): ink$=" ": x0=x: x=MaxCol-1: GOSUB ScrnPrint: x=x0 'Scroll whole screen up IF ink%=73 THEN GOSUB CursorOff: GRAPHIC COPY hGraphicWindow, 0,(0,3*CarH!)-(MaxCol*CarW!,MaxRow*CarH!) TO (0,2*CarH!): ink$="": x=0: y=2: GOSUB ScrnPrint 'Scrool whole screen down IF ink%=81 THEN GOSUB CursorOff: GRAPHIC COPY hGraphicWindow, 0,(0,2*CarH!)-(MaxCol*CarW!,MaxRow*CarH!) TO (0,3*CarH!): ink$=STRING$(MaxCol,32): x=0: y=2: GOSUB ScrnPrint GOTO KeyMouse END IF 'Keyboard regular key section IF ink$=CHR$(27) THEN END IF ink$=CHR$(8) AND x>0 THEN ink$=" ": GOSUB CursorOff: x=x-1: GOSUB ScrnPrint: ink$="" IF ink$=CHR$(13) THEN GOSUB CursorOff: x=0: IF y<MaxRow-1 THEN y=y+1 ELSE BEEP IF ink$>CHR$(31) THEN GOSUB CursorOff: GOSUB ScrnPrint: IF x<MaxCol-1 THEN x=x+1 ELSE BEEP GOTO KeyMouse ScrnPrint:REM Set position and print graphic caracters on screen winh big font F1 GRAPHIC SET POS (x*CarW!,y*CarH!): GRAPHIC PRINT ink$: GRAPHIC REDRAW RETURN CursorOn:REM Simple non blinking empty cursor size of caracter box IF y>1 AND csr <>0 THEN GRAPHIC BOX (x*CarW!,y*CarH!)-(x*CarW!+CarW!,y*CarH!+CarH!),0,%WHITE,csr: csr=-2: GRAPHIC REDRAW RETURN CursorOff:REM erase cursor at end of line CR or mouse click and redraw at next position IF y>1 THEN GRAPHIC BOX (x*CarW!,y*CarH!)-(x*CarW!+CarW!,y*CarH!+CarH!),0,%BLACK,csr: GRAPHIC REDRAW RETURN TopHeading:REM Top box to display mouse results with small font GRAPHIC SET FONT f2 GRAPHIC BOX (0,y1)-(x2-2,CarH2!*2+3),25,%WHITE,%WHITE ' Outer box GRAPHIC BOX (3,y1+3)-(x2-5,CarH2!*2),25,%BLACK,%YELLOW ' Inner box GRAPHIC BOX (x2-CarW!*6+5,y1+6)-(x2-8,CarH2!*2-3),25,%BLACK,%GREEN ' Exit box GRAPHIC COLOR %BLACK,%GREEN GRAPHIC SET POS (x2-CarW2!*36,CarH2!*.6): GRAPHIC PRINT STR$(MaxRow)+" Rows by"+STR$(MaxCol)+" Columns " GRAPHIC SET POS (x2-CarW2!*7,CarH2!*.6): GRAPHIC PRINT" Exit " GRAPHIC REDRAW GRAPHIC SET FONT f1 RETURN Prompt:REM Show mouse events with small font GRAPHIC SET FONT f2 GRAPHIC COLOR %BLACK,%YELLOW IF mm THEN GRAPHIC SET POS (1*CarW2!,1*CarH2!*.6): GRAPHIC PRINT"Mouse move"+STR$(mx)+","+LTRIM$(STR$(my))+" " IF lb THEN GRAPHIC SET POS (30*CarW2!,1*CarH2!*.6): GRAPHIC PRINT"Left button clicked at"+STR$(mx)+","+LTRIM$(STR$(my))+" " IF rb THEN GRAPHIC SET POS (30*CarW2!,1*CarH2!*.6): GRAPHIC PRINT"Right button clicked at"+ STR$(mx)+","+LTRIM$(STR$(my))+" " IF mo=0 AND mx>x2-CarW!*6+5 AND my<CarH!*2-12 THEN mo=1: GRAPHIC COLOR %BLACK,%RED: GOSUB MouseOver ' Button on IF mo=1 AND mx<x2-CarW!*6+5 OR my>CarH!*2-12 THEN mo=0: GRAPHIC COLOR %BLACK,%GREEN: GOSUB MouseOver ' Button off lb=0: rb=0: mm=0: GRAPHIC REDRAW: GRAPHIC COLOR %GREEN,%BLACK GRAPHIC SET FONT f1 RETURN MouseOver:REM Show Mouse Over event with small font GRAPHIC SET FONT f2 GRAPHIC SET POS (x2-CarW2!*7,CarH2!*.6): GRAPHIC PRINT" Exit " GRAPHIC SET FONT f1 RETURN END FUNCTION
Leave a comment:
-
-
New Font Command
Thanks Rick,
I will certainly use those new Commands in my next graphic input as I will need many differents Font sizes for the kind of data entry program I will be writing.
With my twin 24" 1920x1200 LCD Monitors, I can test gigantic fonts fit for an almost blind operator and I will include that option in my software.
I seem to remember Michael complaining about having a hard time reading high resolution screen....Last edited by Guy Dombrowski; 22 Sep 2008, 05:54 PM.
Leave a comment:
-
-
Guy,
The GRAPHIC FONT statement is being supplanted by FONT NEW, GRAPHIC SET FONT and FONT END statements. These allow pre-defining one or more fonts to use in a program, then call them into your GW as needed, and release them before ending the program. FONT NEW allows more specification of a font's parameters than the GRAAPHIC FONT has. The flexibility is nice, built in now and especially handy for vertical or other angular font presentations.
FONT NEW fontname$ [,points!, style&, charset&, pitch&, escapement&] TO fhndl
versus
GRAPHIC FONT fontname$ [,points&, style&]Last edited by Richard Angell; 22 Sep 2008, 04:35 PM.
Leave a comment:
-
-
Got it !
Thanks to all those good tip on the Support Forum I finaly got my new program to run like I wanted.
The demo start in 1024 by 768 but if you have a big wide LCD Monitor you can use some really big fonts and still allow plenty of caracters for big data entry setup.
Now, I will add more code to trap the whole keyboard.
The Cursor code work well enough but there may be a better way to do it.
Any suggestion to improve the demo ? Apart from DIM ALL...
Code:'A small Graphic 1024x768 input screen demo with #CONSOLE OFF to test the new GRAPHIC INKEY$ and GRAPHIC WINDOW CLICK Commands 'Set X2 to PixW and Y2 to PixH for full screen window 'Enter text and hit Return for next line. Esc to end or shut window with mouse or click Green EXIT Button 'Click anywhere on screen to position cursor with left button and enter text #COMPILE EXE #CONSOLE OFF #INCLUDE "Win32Api.inc" DEFLNG a-z GLOBAL GrDialogProc AS LONG GLOBAL GrStaticProc AS LONG GLOBAL mx AS LONG,my AS LONG ' Mouse x and y GLOBAL lb AS LONG,rb AS LONG ' Left and right mouse button GLOBAL mm AS LONG ' Detect mouse movements GLOBAL bg AS LONG,fg AS LONG ' Background and foreground colors FUNCTION GrDlgProc(BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG FUNCTION = CallWindowProc(GrDialogProc, hWnd, wMsg, wParam, lParam) END FUNCTION FUNCTION GrProc(BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG SELECT CASE wMsg CASE %WM_MOUSEMOVE mx=LO(WORD,lParam): my=HI(WORD,lParam): mm=1 ' Current Mouse X and Y Position in the graphic window CASE %WM_LBUTTONDOWN lb=1: mx=LO(WORD,lParam): my=HI(WORD,lParam) ' Left button pressed CASE %WM_RBUTTONDOWN rb=1: mx=LO(WORD,lParam): my=HI(WORD,lParam) ' Right button pressed END SELECT FUNCTION = CallWindowProc(GrStaticProc, hWnd, wMsg, wParam, lParam) END FUNCTION FUNCTION PBMAIN () AS LONG LOCAL hGraphicWindow AS LONG DESKTOP GET CLIENT TO PixW,PixH x=0: y=2: x1=0: y1=0: x2=1024: y2=768 ' Set X2=PixW and Y2=PixH for full screen fnt$="Lucida Console": pt!=12 ' Ajust pt! for font point size 12=79x36 bold font 12=85x36 regular font caption$="Graphic console input test Enter text and hit Return or Click Mouse to next input position Esc to end" GRAPHIC WINDOW caption$,x1,y1,x2,y2 TO hGraphicWindow ' Start Graphic Window hStatic = GetWindow(hGraphicWindow, %GW_CHILD) ' Retrieve static handle of graphic window GrStaticProc = SetWindowLong(hStatic, %GWL_WNDPROC, CODEPTR(GrProc)) ' Subclasses Graphic control GRAPHIC ATTACH hGraphicWindow,0,REDRAW GRAPHIC CLEAR %BLACK,%GREEN: GRAPHIC COLOR %GREEN,%BLACK ' Black background with Green text like old time GRAPHIC FONT fnt$,pt!,0 ' Select regular or bold font GRAPHIC CHR SIZE TO carw!,carh! ' Find pixel width and height of chosen graphic font MaxCol=PixW/CarW!: MaxRow=PixH/CarH! ' Maximums will depend on number of pixels on desktop GRAPHIC WIDTH 2 GRAPHIC REDRAW ' Show screen background instantly GOSUB TopHeading ' Show mouse result KeyMouse:REM Keyboard and Mouse input GRAPHIC GET DC TO hwin: IF hwin=0 THEN END ' Window has been closed by mouse GRAPHIC GET PIXEL (x!+1,y!+1) TO bg: GRAPHIC GET PIXEL (x!+1,y!+1) TO fg ' Store previous colors GRAPHIC INKEY$ TO ink$: SLEEP 1: GOSUB CursorOn IF lb OR rb OR mm THEN GOSUB prompt 'Catch mouse movements and right button GRAPHIC WINDOW CLICK TO clk,x!,y!: IF clk THEN x=x+1: GOSUB CursorOff: x=x!/CarW!-1: y=y!/CarH!-1: IF mo=1 THEN END IF ink$="" THEN KeyMouse IF ink$=CHR$(27) THEN END ScrnPrint:REM Set position and print graphic caracters on screen GRAPHIC SET POS (x*CarW!,y*CarH!) IF ASC(ink$)>31 THEN GRAPHIC PRINT ink$: GRAPHIC REDRAW x=x+1: IF x>MaxCol THEN BEEP: x=MaxCol IF ink$=CHR$(13) THEN GOSUB CursorOff: x=0: y=y+1 IF y>MaxRow THEN BEEP: y=MaxRow GOTO KeyMouse CursorOn:REM Simple blinking cursor .5 second hog% prevent hogging resources by drawing all the time hog%=-1 is for instant draw IF (TIMER-INT(TIMER) >.5 AND hog%=0) OR hog%=-1 THEN GRAPHIC BOX (x*CarW!+3,y*CarH!+CarH!-4)-(x*CarW!+CarW!,y*CarH!+CarH!-1),0,%WHITE,%WHITE: hog%=1: GRAPHIC REDRAW ' Draw White Cursor END IF IF TIMER-INT(TIMER) <.5 AND hog%=1 THEN GRAPHIC BOX (x*CarW!+3,y*CarH!+CarH!-4)-(x*CarW!+CarW!,y*CarH!+CarH!-1),0,%BLACK,%BLACK: hog%=0: GRAPHIC REDRAW ' Draw Black Cursor END IF RETURN CursorOff:REM erase cursor at end of line CR or mouse click and flag instant redraw at next caracter GRAPHIC BOX (x*CarW!-CarW!+3,y*CarH!+CarH!-4)-(x*CarW!,y*CarH!+CarH!-1),0,fg,bg: hog%=-1: GRAPHIC REDRAW ' Erase Cursor RETURN TopHeading:REM Top box to display mouse results GRAPHIC BOX (x1+3,y1+3)-(x2-2,CarH!*2),25,%WHITE,%YELLOW GRAPHIC BOX (x1+6,y1+6)-(x2-5,CarH!*2-3),25,%BLACK,%YELLOW GRAPHIC BOX (x2-CarW!*6,y1+6)-(x2-5,CarH!*2-3),25,%BLACK,%GREEN GRAPHIC COLOR %BLACK,%GREEN GRAPHIC SET POS (x2-CarW!*5,CarH!*.5): GRAPHIC PRINT"Exit" GRAPHIC REDRAW RETURN Prompt:REM Show mouse events GRAPHIC COLOR %BLACK,%YELLOW IF mm THEN GRAPHIC SET POS (1*CarW!,1*CarH!-CarH!/2): GRAPHIC PRINT"Mouse move"+STR$(mx)+","+LTRIM$(STR$(my))+" " IF lb THEN GRAPHIC SET POS (25*CarW!,1*CarH!-CarH!/2): GRAPHIC PRINT"Left button clicked at"+STR$(mx)+","+LTRIM$(STR$(my))+" " IF rb THEN GRAPHIC SET POS (25*CarW!,1*CarH!-CarH!/2): GRAPHIC PRINT"Right button clicked at"+ STR$(mx)+","+LTRIM$(STR$(my))+" " IF mo=0 AND mx>x2-CarW!*6 AND my<CarH!*2 THEN mo=1: GRAPHIC COLOR %BLACK,%RED: GOSUB MouseOver IF mo=1 AND mx<x2-CarW!*6 OR my>CarH!*2 THEN mo=0: GRAPHIC COLOR %BLACK,%GREEN: GOSUB MouseOver lb=0: rb=0: mm=0: GRAPHIC REDRAW: GRAPHIC COLOR %GREEN,%BLACK RETURN MouseOver:REM Show Mouse Over event GRAPHIC SET POS (x2-CarW!*5,CarH!*.5): GRAPHIC PRINT"Exit" RETURN END FUNCTION
Leave a comment:
-
-
Subclass the Graphic Window and then trap the %WM_MOUSEMOVE message.
In Subclassing a Graphic Window, you first subclass the Graphic Window, then get the handle to its client area, really a child window, where all the action is taking place, Then subclass that window and traap the mouse moves there
Code:FUNCTION ChildGWSubProc(BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, _ BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG LOCAL lResult AS LONG SELECT CASE wMsg '... CASE %WM_MOUSEMOVE '... Colx = (LOWRD(lParam)): Rowy = (HIWRD(lParam) '...
Note though that pressing Q does not exit that program, use the "X"?
Keep in mind that code was for PBCC 4, so you will need to replace the #COMPILER PBCC 4 with #COMPILER PBCC or #COMPILER PBCC 5 to compile and see it run.Last edited by Richard Angell; 19 Sep 2008, 09:59 PM. Reason: link to previous code, add clarification,keyed snip to link code
Leave a comment:
-
-
I don't have CC so I can't try your sample, but if you're interested getting more information about what's going on with the mouse, check out the "SetWindowsHookEx %WH_MOUSE" API function.
Leave a comment:
-
-
End of the 80x25 Console
Hi everybody,
Now, with the new CC5 compiler, I think it is possible to make a console like program without any console.
My little demo work like a charm even on old slow computers.
The new GRAPHIC INKEY$ and GRAPHIC WINDOW CLICK commands are a dream come true.
The only thing missing is a way to catch mouse movements without having to click it.
You could then have a Web Like menu where you light buttons just by moving over them
Anybody out there able to subclass that ????
Code:'A small full screen with #CONSOLE OFF demo to test the new GRAPHIC INKEY$ and GRAPHIC WINDOW CLICK Commands 'Enter text and hit Return. Esc to end or shut window with mouse 'Click anywhere on screen to position cursor and enter text #COMPILE EXE #CONSOLE OFF DEFLNG a-z FUNCTION PBMAIN () AS LONG DESKTOP GET CLIENT TO PixW,PixH: x1=0: y1=0: x2=PixW: y2=PixH fnt$="Lucida Console": pt!=18 caption$="Graphic console full screen input test Enter text and hit Return or Click Mouse to next position" x=0: y=0 ' Start print position GRAPHIC WINDOW caption$,x1,y1,x2,y2 TO hwin GRAPHIC ATTACH hwin,0,REDRAW GRAPHIC CLEAR %BLACK,%GREEN: GRAPHIC COLOR %GREEN,%BLACK ' Black background with Green text like old time GRAPHIC GET PIXEL (2,2) TO bkgr ' Find Background color if other colors used instead of black GRAPHIC FONT fnt$,pt!,1 ' Select font GRAPHIC CHR SIZE TO carw!,carh! ' Find pixel width and height of chosen graphic font MaxCol=PixW/CarW!: MaxRow=PixH/CarH! ' Maximums will depend on number of pixels on desktop GRAPHIC REDRAW KeyMouse:REM Keyboard and Mouse input GRAPHIC INKEY$ TO z$: SLEEP 1: GOSUB CursorOn: GRAPHIC GET DC TO hwin: IF hwin=0 THEN END ' Window has been closed by mouse GRAPHIC WINDOW CLICK TO clk,x!,y!: IF clk THEN x=x+1: GOSUB CursorOff: x=x!/CarW!-1: y=y!/CarH!-1: GOTO ScrnPrint IF z$="" THEN KeyMouse IF z$=CHR$(27) THEN END ScrnPrint:REM Set position and print graphic caracters on screen GRAPHIC SET POS (x*CarW!,y*CarH!) IF ASC(z$)>31 THEN GRAPHIC PRINT z$: GRAPHIC REDRAW x=x+1: IF x>MaxCol THEN BEEP: x=MaxCol IF z$=CHR$(13) THEN GOSUB CursorOff: x=0: y=y+1 IF y>MaxRow THEN BEEP: y=MaxRow GOTO KeyMouse CursorOn:REM Simple blinking cursor .5 second hog% prevent hogging resources by drawing all the time hog%=-1 is for instant draw IF (TIMER-INT(TIMER) >.5 AND hog%=0) OR hog%=-1 THEN GRAPHIC BOX (x*CarW!,y*CarH!+CarH!-4)-(x*CarW!+CarW!,y*CarH!+CarH!),0,%WHITE,%WHITE: hog%=1: GRAPHIC REDRAW END IF IF TIMER-INT(TIMER) <.5 AND hog%=1 THEN GRAPHIC BOX (x*CarW!,y*CarH!+CarH!-4)-(x*CarW!+CarW!,y*CarH!+CarH!),0,%BLACK,bkgr: hog%=0: GRAPHIC REDRAW END IF RETURN CursorOff:REM erase cursor at end of line CR or mouse click and flag instant redraw at next caracter GRAPHIC BOX (x*CarW!-CarW!,y*CarH!+CarH!-4)-(x*CarW!,y*CarH!+CarH!),0,%BLACK,bkgr: hog%=-1: GRAPHIC REDRAW RETURN END FUNCTION
Tags: None
-
Leave a comment: