Announcement

Collapse
No announcement yet.

End of the 80x25 Console

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Old QB45 Programmer

  • #2
    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.
    - LJ

    Comment


    • #3
      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)
      '...
      You might look at my post on Nov 24, 2005 , the code still compiles, but use the "X" to terminate. Some of it now is handled by PBCC 5's new and improved functions. Here

      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
      Rick Angell

      Comment


      • #4
        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
        Old QB45 Programmer

        Comment


        • #5
          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.
          Rick Angell

          Comment


          • #6
            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.
            Old QB45 Programmer

            Comment


            • #7
              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
              Last edited by Guy Dombrowski; 25 Sep 2008, 07:19 AM. Reason: Window was at 1280x1024
              Old QB45 Programmer

              Comment


              • #8
                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
                Old QB45 Programmer

                Comment


                • #9
                  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:
                  1. Determine if the button is held down and ...
                  2. Determine the amount and direction of movement
                  3. 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
                  If the user continues dragging repeat 3 until the middle button is released.
                  Rick Angell

                  Comment


                  • #10
                    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
                    Old QB45 Programmer

                    Comment


                    • #11
                      Still no menu?
                      Rick Angell

                      Comment


                      • #12
                        Menu

                        I am working on it !
                        Old QB45 Programmer

                        Comment


                        • #13
                          In order to track scrolling you might need in GrProc to also add:
                          Code:
                          CASE %WM_MBUTTONUP
                                mb=0: FUNCTION=0: EXIT FUNCTION                      ' Middle button released
                          and in Prompt: remove mb = 0 from the next to the last line.

                          With these changes in your earlier post mb down will now track constantly until released. I did not look at the wheel, don't have that type of rodent on this machine. Still I did not look too hard to see how if at all you plan to track and move themenu ... since itt is no yet in the pgm.
                          Rick Angell

                          Comment


                          • #14
                            Scrolling

                            Rick,

                            Since you do not have a mouse with a scroll wheel, you can not try my code properly. ( They are worth 10 bucks here)
                            The way I did it was to move the cursor one line up or down on each wheel detent move.
                            That wheel will click when rotated both ways and I can detect the new position of the cursor.
                            I choosed to assign one line per click so it will be very eazy to implement a mouseover effect like the Exit button.
                            The end result will be exactly like a CNN Web Site where you scroll up and down to select the last Breaking News .
                            My next posting will show that kind of menu but you will have to get a new mouse to see it.
                            Of course, simply moving your old mouse over it will work too.
                            Old QB45 Programmer

                            Comment


                            • #15
                              I have a couple of wheel mice, just not on this machine. For CAD that I must use, wheel mice are not as nice as a clear middle button. I have seen in a couple of browsers, if the cursor is not on a link or edit box, the third button is scroll.
                              Rick Angell

                              Comment


                              • #16
                                Also, I do not plan on using the middle mouse for clicking as it is eazy to depress it as you are rolling the wheel.
                                Much better to use only the wheel itself to move up or down when doing data entry.
                                A lot of my custommer won't be using the mouse much as they are used to old Dos programs and they prefer everything in full screen.
                                They can use the keyboard to move around nicely without any mouse.

                                Well, I will be shutting my computer as it is Sunday and 22:00 here in Quebec.

                                Bye and good night
                                Old QB45 Programmer

                                Comment


                                • #17
                                  Menu

                                  Here is my last addition as suggested by Rick.
                                  I have added the start of a menu system to see what was involved in writing that code.
                                  As it can call old Dos programs, it will be very useful if you are upgrading many old modules that have to be kept running while the new code is replacing the old ones.
                                  The menu can be operated with the functions key in a full screen mode without any mouse.
                                  Of course, the whole thing is still somewhat rough and need a bit of work to be a finished product but I like that concept of having a graphical console.
                                  Code:
                                  'A small Graphic 1024x768 input screen demo with #CONSOLE OFF to test the new GRAPHIC INKEY$ and GRAPHIC SET FONT
                                  'A small menu has been added that can be accessed with the button at the top or with the Functions Key F1 to F5
                                  'F2 through F4 are used to start other programs with SHELL ( Even old QB45  will work .... )
                                  'F1 and F5 need more code as they show only that they have been called.
                                  'Full keyboard and mouse handling including the middle button and scroll wheel
                                  'Set X2 to PixW and Y2 to PixH for full screen window or any size wanted
                                  'The left bottom Heading will show mouse clicks, positions and wheel move up or down.
                                  'The center will show the cursor row position change when using the mouse wheel
                                  '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 top Button for MouseOver effect and click them to start the logic
                                  'Program will end with Esc or Exit button or closing window or F2,F3,F4 if no program to load.
                                  
                                  #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=1280: y2=1024
                                   '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!-3                       ' 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
                                   GOSUB BottomHeading: GRAPHIC COLOR %GREEN,%BLACK
                                   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 ' Left button click showing menus
                                       GOSUB CursorOff: x=mx/CarW!-1: y=my/CarH!-1: GOSUB CursorOn                             ' Left Button
                                       IF mx>CarW2! AND mx<CarW2!*18 AND my<CarH2!*2 THEN GOSUB Instruction                    ' Start Instruction Menu
                                       IF mx>CarW2!*20 AND mx<CarW2!*35 AND my<CarH2!*2 THEN GRAPHIC WINDOW END: SHELL f2$     ' Put Accounting program name in f2$
                                       IF mx>CarW2!*37 AND mx<CarW2!*51 AND my<CarH2!*2 THEN GRAPHIC WINDOW END: SHELL f3$     ' Put Inventory program name in f3$
                                       IF mx>CarW2!*53 AND mx<CarW2!*65 AND my<CarH2!*2 THEN GRAPHIC WINDOW END: SHELL f4$     ' Put Payroll program name in f4$
                                       IF mx>CarW2!*67 AND mx<CarW2!*77 AND my<CarH2!*2 THEN GOSUB Tools                       ' Start Tools menu
                                       IF mx>x2-CarW2!*7 AND my<CarH2!*2 AND mo=1 THEN END                                     ' Exit pressed
                                     END IF
                                   IF rb THEN GOSUB CursorOff: x=mx/CarW!-1: y=my/CarH!-1: GOSUB CursorOn:                     ' Right Button
                                   IF wm THEN
                                     GOSUB CursorOff: y=y-wm: IF y<2 THEN BEEP: y=2 ELSE IF y>MaxRow THEN BEEP: y=MaxRow       ' Wheel mouse limit
                                     GOSUB CursorOn
                                   END IF
                                   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%=59 THEN GOSUB Instruction                                                      ' F1 key
                                     IF ink%=60 THEN GRAPHIC WINDOW END: SHELL f2$                                          ' F2 key
                                     IF ink%=61 THEN GRAPHIC WINDOW END: SHELL f3$                                          ' F3 key
                                     IF ink%=62 THEN GRAPHIC WINDOW END: SHELL f4$                                          ' F4 key
                                     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 y<=MaxRow 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 AND y<=MaxRow 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 menu
                                   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 (CarW2!*.6, y1+6)-(CarW2!*18.5, CarH2!*2-3),25,%BLACK,%GREEN    ' Instructions box
                                   GRAPHIC BOX (CarW2!*19.6, y1+6)-(CarW2!*35.5, CarH2!*2-3),25,%BLACK,%GREEN  ' Accounting box
                                   GRAPHIC BOX (CarW2!*36.6, y1+6)-(CarW2!*51.5, CarH2!*2-3),25,%BLACK,%GREEN  ' Inventory box
                                   GRAPHIC BOX (CarW2!*52.6, y1+6)-(CarW2!*65.5, CarH2!*2-3),25,%BLACK,%GREEN  ' Payroll box
                                   GRAPHIC BOX (CarW2!*66.6, y1+6)-(CarW2!*77.5, CarH2!*2-3),25,%BLACK,%GREEN  ' Tool box
                                   GRAPHIC BOX (x2-CarW2!*7.3, y1+6)-(x2-8, CarH2!*2-3),25,%BLACK,%GREEN       ' Exit box
                                   GRAPHIC COLOR %BLACK,%GREEN
                                   GRAPHIC SET POS (CarW2!, CarH2!*.6): GRAPHIC PRINT " F1 Instructions "
                                   GRAPHIC SET POS (CarW2!*20, CarH2!*.6): GRAPHIC PRINT " F2 Accounting "
                                   GRAPHIC SET POS (CarW2!*37, CarH2!*.6): GRAPHIC PRINT " F3 Inventory "
                                   GRAPHIC SET POS (CarW2!*53, CarH2!*.6): GRAPHIC PRINT " F4 Payroll "
                                   GRAPHIC SET POS (CarW2!*67, CarH2!*.6): GRAPHIC PRINT " F5 Tools "
                                   GRAPHIC SET POS (x2-CarW2!*7, CarH2!*.6): GRAPHIC PRINT " Exit "
                                   GRAPHIC REDRAW
                                   GRAPHIC SET FONT f1
                                  RETURN
                                  
                                  BottomHeading:REM Bottom box to display mouse results with small font
                                   GRAPHIC SET FONT f2
                                   GRAPHIC BOX (0, y2-CarH2!*2)-(x2-2, y2),25,%WHITE,%WHITE                ' Outer box
                                   GRAPHIC BOX (3, y2-CarH2!*2+3)-(x2-5, y2-3),25,%BLACK,%YELLOW           ' Inner box
                                  ' GRAPHIC BOX (x2-CarW!*6+5, y2-CarH2!*2+6)-(x2-8, y2-6),25,%BLACK,%GREEN ' Exit box
                                   GRAPHIC COLOR %BLACK,%GREEN
                                   GRAPHIC SET POS (x2-CarW2!*37, y2-CarH2!*2+8): GRAPHIC PRINT " Row= "+LTRIM$(STR$(maxRow+3))+"  Column= "+LTRIM$(STR$(MaxCol))+" "
                                  ' GRAPHIC SET POS (x2-CarW2!*7, y2-CarH2!*2+8): GRAPHIC PRINT" Exit "
                                   GRAPHIC SET POS (x2-CarW2!*14, y2-CarH2!*2+8): GRAPHIC PRINT" Grid=" STR$(carw!)+"x"+LTRIM$(STR$(carh!))+" "  ' Show size of caracter box
                                   GRAPHIC REDRAW
                                   GRAPHIC SET FONT f1
                                  RETURN
                                  
                                  Prompt:REM Show mouse events on Bottom Heading with small font
                                   GRAPHIC SET FONT f2: GRAPHIC COLOR %BLACK,%YELLOW
                                   IF mm THEN GRAPHIC SET POS (CarW2!, y2-CarH2!*2+8): GRAPHIC PRINT"Mouse move"+STR$(mx)+","+LTRIM$(STR$(my))+"     "
                                   IF wm=1 THEN GRAPHIC SET POS (CarW2!, y2-CarH2!*2+8): GRAPHIC PRINT"Wheel mouse up          "
                                   IF wm=-1 THEN GRAPHIC SET POS (CarW2!, y2-CarH2!*2+8): GRAPHIC PRINT"Wheel mouse down        "
                                   IF lb THEN GRAPHIC SET POS (CarW2!, y2-CarH2!*2+8): GRAPHIC PRINT"Left button clicked     "
                                   IF mb THEN GRAPHIC SET POS (CarW2!, y2-CarH2!*2+8): GRAPHIC PRINT"Middle button clicked   "
                                   IF rb THEN GRAPHIC SET POS (CarW2!, y2-CarH2!*2+8): GRAPHIC PRINT"Right button clicked    "
                                  'Show cursor position
                                   GRAPHIC SET POS (30*CarW2!, y2-CarH2!*2+8): GRAPHIC PRINT" Cursor is at Row";: GRAPHIC PRINT USING$("###",y+1)
                                  'Show mouse over effects
                                   IF mo=1 THEN mo=0: GOSUB MouseOver  ' All Buttons off
                                   IF mo=0 AND my<CarH2!*2 THEN
                                     f1=0: IF mx>CarW2! AND mx<CarW2!*18 THEN mo=1: mp!=CarW2!: mo$=" F1 Instructions "
                                     IF mx>CarW2!*20 AND mx<CarW2!*35 THEN mo=1: mp!=CarW2!*20: mo$=" F2 Accounting "
                                     IF mx>CarW2!*37 AND mx<CarW2!*51 THEN mo=1: mp!=CarW2!*37: mo$=" F3 Inventory "
                                     IF mx>CarW2!*53 AND mx<CarW2!*65 THEN mo=1: mp!=CarW2!*53: mo$=" F4 Payroll "
                                     IF mx>CarW2!*67 AND mx<CarW2!*77 THEN mo=1: mp!=CarW2!*67: mo$=" F4 Tools "
                                     IF mx>x2-CarW2!*7 THEN mo=1: mp!=x2-CarW2!*7: mo$=" Exit "
                                     GOSUB MouseOver
                                   END IF
                                   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: IF mo=1 THEN GRAPHIC COLOR %WHITE,%RED ELSE GRAPHIC COLOR %BLACK,%GREEN
                                   GRAPHIC SET POS (mp!,CarH2!*.6): GRAPHIC PRINT mo$
                                   GRAPHIC SET FONT f1
                                  RETURN
                                  
                                  Instruction:REM Put Instruction Menu code here
                                   GRAPHIC SET FONT f2
                                   GRAPHIC SET POS (CarW2!, y2-CarH2!*2+8): GRAPHIC PRINT" Instruction Menu "
                                   GRAPHIC SET FONT f1
                                  RETURN
                                  
                                  Tools:REM Put  Tools code here
                                   GRAPHIC SET FONT f2
                                   GRAPHIC SET POS (CarW2!, y2-CarH2!*2+8): GRAPHIC PRINT" Tools Menu       "
                                   GRAPHIC SET FONT f1
                                  RETURN
                                  
                                  END FUNCTION
                                  Old QB45 Programmer

                                  Comment


                                  • #18
                                    Evolution of the Graphic Console

                                    Hi everybody,

                                    Here is my new Graphical Console demo. It will scale to any screen resolution.
                                    I rewrote a lot of code and added many new features.
                                    Most of the additions were with the Menu handling as the keyboard was pretty much complete.
                                    But I added F1 to F10 functions for Mouseless operation.
                                    The windows location will now be saved and it will start where it was terminated. ( as long as your resolution is better than 1024x768 ) All preferences will also be saved there in the future...

                                    I am trying for something new with the menu bar on top.
                                    Instead of unrolling a top to bottom menu, I use a horizontal menu using the same bar but with differents colors and numbers of buttons.

                                    Try the F7 Button and give me your feedback.
                                    The End button will end the Tools Menu and return control to the Main menu so you will need to click the F10 button twice to end the program.
                                    Of course, the Tools menu does nothing for now.

                                    Is it something intuitive or am I on the wrong track ? A console program has to be different ????
                                    Code:
                                    'Evolution of my first Graphic Console program with full mouse and keyboard handling + mouse wheel
                                    'It will remenber its screen position ( as long as your resolution is more than 1024x768 ) if you end it with the END Button and not the X to shut down Windows
                                    'Menu added to the top bar that can be accessed By clicking buttons or with the Functions Key F1 to F10
                                    'The buttons size and location will be ajusted automatically to the text length of F1$ to F10$ text ( See ButtonText )
                                    'Put your program names in P1$ to P6$.  May be used to call your old modules while writing the new ones.
                                    'Try Tools Menu F7 to see new horizontal menu presentation with different color and change function key text for your own needs
                                    'The F10 End key will end Tools Menu the first time and the Main Program the second time.  Look at the text button.
                                    'Sorry again about the long code lines but if you have a 24" 1920x1200 Monitor, you will understand !  ( I have 2... Ha Ha )
                                    
                                    #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
                                     DIM spec$(30),scrn$(30),s$(10)
                                     LOCAL hGraphicWindow AS LONG
                                     DESKTOP GET CLIENT TO PixW,PixH             ' Find screen resolution
                                     x1=0: y1=0: x2=1024: y2=768                 ' Initial window 1024x768   Set X2=PixW and Y2=PixH for full screen
                                     x2=1280: y2=1024
                                     x1=PixW-x2                                  ' Position initial window top right
                                     drv$=LEFT$(CURDIR$,2): spec$=drv$+"specsys" ' Lire spec Drive par default
                                    
                                     FONT NEW "Lucida Console",12,1,0,0,0 TO fnt1  ' 12=79x36 bold font  12=85x36 regular font
                                     FONT NEW "Lucida console",8,1,0,0,0 TO fnt2   ' 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 or use MouseWheel "
                                     x=0: y=2: csr=-2                              ' Start position of Empty box cursor
                                    
                                    Setting:REM read Screen Setting
                                     OPEN "SetScreen.CSV" FOR INPUT AS #1: IF ERR>0 THEN ERR=0: GOTO CloseTxt       ' First time with no setup data
                                     REDIM s$(2): IF EOF(1)=0 THEN LINE INPUT#1,scrn$(0): PARSE scrn$(0),s$(),","   ' Read last saved position
                                     IF s$(0)<>"" THEN x1=VAL(s$(0)): y1=VAL(s$(1)): GRAPHIC SET LOC x1,y1          ' Set Graphic Window position
                                    'REDIM s$(10): IF EOF(1)=0 THEN LINE INPUT#1,scrn$(1): PARSE scrn$(z),s$(),","  ' Futur code to save date for Font #1
                                    'REDIM s$(10): IF EOF(1)=0 THEN LINE INPUT#1,scrn$(2): PARSE scrn$(z),s$(),","  ' Futur code to save data for Font #2
                                    CloseTxt:REM end of read
                                     CLOSE #1
                                    
                                     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 fnt2: GRAPHIC CHR SIZE TO CarW2!,CarH2! ' Find pixel width and height of fnt2 graphic font
                                     GRAPHIC SET FONT fnt1: GRAPHIC CHR SIZE TO CarW!,CarH!   ' Find pixel width and height of fnt1 graphic font
                                     GRAPHIC CLEAR %BLACK,%GREEN: GRAPHIC COLOR %GREEN,%BLACK ' Black background with Green text like old time
                                     MaxCol=x2/CarW!: MaxRow=y2/CarH!-3                       ' Maximums will depend on number of pixels on desktop
                                     GRAPHIC WIDTH 1
                                     GRAPHIC REDRAW                                           ' Show screen background instantly
                                     GOSUB ProgName: GOSUB ButtonText                         ' Assign programs and names to buttons
                                     GOSUB TopHeading: GRAPHIC COLOR %GREEN,%BLACK            ' Show Top Menu
                                     GOSUB BottomHeading: GRAPHIC COLOR %GREEN,%BLACK
                                    
                                    KeyMouse:REM Keyboard and Mouse input
                                     GRAPHIC GET DC TO hwin: IF hwin=0 THEN END                                 ' Graphic Window has been closed
                                     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 AND my<CarH2!*2 THEN ' Clicking the F1 to f6 buttons with mouse Left button will start new program but will not end menu like the Function keys
                                         GOSUB CursorOff: x=mx/CarW!-1: y=my/CarH!-1: GOSUB CursorOn
                                         IF mx>CarW2! AND mx<CarW2!*(f1+1) AND fin% THEN SHELL p1$                 ' F1 Program
                                         IF mx>CarW2!*(f1+2) AND mx<CarW2!*(f2+2) AND fin% THEN SHELL p2$          ' F2 Program
                                         IF mx>CarW2!*(f2+3) AND mx<CarW2!*(f3+3) AND fin% THEN SHELL p3$          ' F3 Program
                                         IF mx>CarW2!*(f3+4) AND mx<CarW2!*(f4+4) AND fin% THEN SHELL p4$          ' F4 Program
                                         IF mx>CarW2!*(f4+5) AND mx<CarW2!*(f5+5) AND fin% THEN SHELL p5$          ' F5 Program
                                         IF mx>CarW2!*(f5+6) AND mx<CarW2!*(f6+6) AND fin% THEN SHELL p6$          ' F6 Program
                                         IF mx>CarW2!*(f6+7) AND mx<CarW2!*(f7+7) AND fin% THEN GOSUB Tools        ' F7 Program inside menu
                                           IF mx>x2-CarW2!*(f10+1) AND mo=1 THEN
                                             IF fin% THEN GOSUB SavePos: fin%=0: END                      ' End button pressed in Main Menu  Program end
                                             IF tool% THEN GOSUB ButtonText: GOSUB TopHeading: tool%=0    ' End Button pressed in Tools menu back to main menu
                                           END IF
                                       END IF
                                    'Show action Results
                                     IF lb OR rb THEN GOSUB CursorOff: x=mx/CarW!-1: y=my/CarH!-1: GOSUB CursorOn:            ' Show Cursor position when left or right button clicked
                                     IF wm THEN
                                       GOSUB CursorOff: y=y-wm: IF y<2 THEN BEEP: y=2 ELSE IF y>MaxRow THEN BEEP: y=MaxRow    ' Wheel mouse limit
                                       GOSUB CursorOn
                                     END IF
                                     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%=59 AND fin% THEN GRAPHIC WINDOW END: SHELL p1$  ' F1 key  The F keys will terminate the menu but the buttons will not
                                       IF ink%=60 AND fin% THEN GRAPHIC WINDOW END: SHELL p2$  ' F2 key
                                       IF ink%=61 AND fin% THEN GRAPHIC WINDOW END: SHELL p3$  ' F3 key
                                       IF ink%=62 AND fin% THEN GRAPHIC WINDOW END: SHELL p4$  ' F4 key
                                       IF ink%=63 AND fin% THEN GRAPHIC WINDOW END: SHELL p5$  ' F5 key
                                       IF ink%=64 AND fin% THEN GRAPHIC WINDOW END: SHELL p6$  ' F6 key
                                       IF ink%=65 AND fin% THEN GOSUB Tools                    ' F7 Tools section with own menu
                                         IF ink%=68 THEN                                       ' F10 key end Tools Menu or Main Program if in Main Menu
                                           IF fin% THEN GOSUB SavePos: GRAPHIC WINDOW END: END
                                           IF tool% THEN GOSUB ButtonText: GOSUB TopHeading: tool%=0
                                         END IF
                                       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$(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 with big font Fnt1
                                     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 y<=MaxRow 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 AND y<=MaxRow 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 menu Buttons will be sized automatically by their text length   0=no button
                                     f1=LEN(f1$)
                                     f2=LEN(f1$+f2$): IF f2$="" THEN f2=0
                                     f3=f2+LEN(f3$): IF f3$="" THEN f3=0
                                     f4=f3+LEN(f4$): IF f4$="" THEN f4=0
                                     f5=f4+LEN(f5$): IF f5$="" THEN f5=0
                                     f6=f5+LEN(f6$): IF f6$="" THEN f6=0
                                     f7=f6+LEN(f7$): IF f7$="" THEN f7=0
                                     f8=f7+LEN(f8$): IF f8$="" THEN f8=0
                                     f9=f8+LEN(f9$): IF f9$="" THEN f9=0
                                     f10=LEN(fin$): IF f7$="" THEN f7=0
                                     GRAPHIC SET FONT fnt2
                                     GRAPHIC BOX (0, 0)-(x2-2, CarH2!*2+3),25,%WHITE,%WHITE  ' Outer box
                                     GRAPHIC BOX (3, 3)-(x2-5, CarH2!*2),25,%BLACK,%YELLOW   ' Inner box main Menu
                                     IF fin% THEN r=0: g=255: b=0 ELSE r=0: g=255: b=255     ' Change Buttons background color for Tools Menu
                                     tint=RGB(r,g,b)
                                     IF f1 THEN GRAPHIC BOX (CarW2!*.6, 6)-(CarW2!*(f1+1.4), CarH2!*2-3),25,%BLACK,tint          ' F1 box
                                     IF f2 THEN GRAPHIC BOX (CarW2!*(f1+1.6), 6)-(CarW2!*(f2+2.4), CarH2!*2-3),25,%BLACK,tint    ' F2 box
                                     IF f3 THEN GRAPHIC BOX (CarW2!*(f2+2.6), 6)-(CarW2!*(f3+3.4), CarH2!*2-3),25,%BLACK,tint    ' F3 box
                                     IF f4 THEN GRAPHIC BOX (CarW2!*(f3+3.6), 6)-(CarW2!*(f4+4.4), CarH2!*2-3),25,%BLACK,tint    ' F4 box
                                     IF f5 THEN GRAPHIC BOX (CarW2!*(f4+4.6), 6)-(CarW2!*(f5+5.4), CarH2!*2-3),25,%BLACK,tint    ' F5 box
                                     IF f6 THEN GRAPHIC BOX (CarW2!*(f5+5.6), 6)-(CarW2!*(f6+6.4), CarH2!*2-3),25,%BLACK,tint    ' F6 box
                                     IF f7 THEN GRAPHIC BOX (CarW2!*(f6+6.6), 6)-(CarW2!*(f7+7.4), CarH2!*2-3),25,%BLACK,tint    ' F7 box
                                     IF f8 THEN GRAPHIC BOX (CarW2!*(f7+7.6), 6)-(CarW2!*(f8+8.4), CarH2!*2-3),25,%BLACK,tint    ' F8 box
                                     IF f9 THEN GRAPHIC BOX (CarW2!*(f8+8.6), 6)-(CarW2!*(f9+9.4), CarH2!*2-3),25,%BLACK,tint    ' F9 box
                                     IF f10 THEN GRAPHIC BOX (x2-CarW2!*(f10+1.4), 6)-(x2-8, CarH2!*2-3),25,%BLACK,tint          ' F10 End box
                                    
                                     IF fin% THEN GRAPHIC COLOR %BLACK,%GREEN ELSE GRAPHIC COLOR %BLACK,tint
                                     IF f1 THEN GRAPHIC SET POS (CarW2!, CarH2!*.6): GRAPHIC PRINT f1$                              ' F1 text
                                     IF f2 THEN GRAPHIC SET POS (CarW2!*(f1+2), CarH2!*.6): GRAPHIC PRINT f2$                       ' F2 Text
                                     IF f3 THEN GRAPHIC SET POS (CarW2!*(f2+3), CarH2!*.6): GRAPHIC PRINT f3$                       ' F3 Text
                                     IF f4 THEN GRAPHIC SET POS (CarW2!*(f3+4), CarH2!*.6): GRAPHIC PRINT f4$                       ' F4 Text
                                     IF f5 THEN GRAPHIC SET POS (CarW2!*(f4+5), CarH2!*.6): GRAPHIC PRINT f5$                       ' F5 Text
                                     IF f6 THEN GRAPHIC SET POS (CarW2!*(f5+6), CarH2!*.6): GRAPHIC PRINT f6$                       ' F6 Text
                                     IF f7 THEN GRAPHIC SET POS (CarW2!*(f6+7), CarH2!*.6): GRAPHIC PRINT f7$                       ' F7 Text
                                     IF f8 THEN GRAPHIC SET POS (CarW2!*(f7+8), CarH2!*.6): GRAPHIC PRINT f8$                       ' F8 Text
                                     IF f9 THEN GRAPHIC SET POS (CarW2!*(f8+9), CarH2!*.6): GRAPHIC PRINT f9$                       ' F9 Text
                                     IF f10 THEN GRAPHIC SET POS (x2-CarW2!*(f10+1), CarH2!*.6): GRAPHIC PRINT fin$                 ' F10 End Text
                                     GRAPHIC REDRAW
                                     GRAPHIC SET FONT fnt1
                                    RETURN
                                    
                                    BottomHeading:REM Bottom box to display mouse results with small font
                                     GRAPHIC SET FONT fnt2
                                     GRAPHIC BOX (0, y2-CarH2!*2)-(x2-2, y2),25,%WHITE,%WHITE                ' Outer box
                                     GRAPHIC BOX (3, y2-CarH2!*2+3)-(x2-5, y2-3),25,%BLACK,%YELLOW           ' Inner box
                                     GRAPHIC COLOR %BLACK,%GREEN
                                     GRAPHIC SET POS (x2-CarW2!*37, y2-CarH2!*2+8): GRAPHIC PRINT " Row= "+LTRIM$(STR$(maxRow+3))+"  Column= "+LTRIM$(STR$(MaxCol))+" "
                                     GRAPHIC SET POS (x2-CarW2!*14, y2-CarH2!*2+8): GRAPHIC PRINT" Grid=" STR$(carw!)+"x"+LTRIM$(STR$(carh!))+" "  ' Show size of caracter box
                                     GRAPHIC REDRAW
                                     GRAPHIC SET FONT fnt1
                                    RETURN
                                    
                                    Prompt:REM Show mouse events on Bottom Heading with small font
                                     GRAPHIC SET FONT fnt2: GRAPHIC COLOR %BLACK,%YELLOW
                                     IF mm THEN GRAPHIC SET POS (CarW2!, y2-CarH2!*2+8): GRAPHIC PRINT"Mouse move"+STR$(mx)+","+LTRIM$(STR$(my))+"     "
                                     IF wm=1 THEN GRAPHIC SET POS (CarW2!, y2-CarH2!*2+8): GRAPHIC PRINT"Wheel mouse up          "
                                     IF wm=-1 THEN GRAPHIC SET POS (CarW2!, y2-CarH2!*2+8): GRAPHIC PRINT"Wheel mouse down        "
                                     IF lb THEN GRAPHIC SET POS (CarW2!, y2-CarH2!*2+8): GRAPHIC PRINT"Left button clicked     "
                                     IF mb THEN GRAPHIC SET POS (CarW2!, y2-CarH2!*2+8): GRAPHIC PRINT"Middle button clicked   "
                                     IF rb THEN GRAPHIC SET POS (CarW2!, y2-CarH2!*2+8): GRAPHIC PRINT"Right button clicked    "
                                    'Show cursor position
                                     GRAPHIC SET POS (30*CarW2!, y2-CarH2!*2+8): GRAPHIC PRINT" Cursor is at Row";: GRAPHIC PRINT USING$("###",y+1)
                                    'Show mouse over effects
                                     IF mo=1 THEN mo=0: GOSUB MouseOver  ' All Buttons off
                                     IF mo=0 AND my<CarH2!*2 AND my>CarH2!/4 AND mx>CarW2!/4 AND mx<x2-CarW2!/2 THEN
                                       IF mx>CarW2! AND mx<CarW2!*(f1+1) THEN mo=1: mp!=CarW2!: mo$=f1$ '              F1
                                       IF mx>CarW2!*(f1+2) AND mx<CarW2!*(f2+2) THEN mo=1: mp!=CarW2!*(f1+2): mo$=f2$ 'F2
                                       IF mx>CarW2!*(f2+3) AND mx<CarW2!*(f3+3) THEN mo=1: mp!=CarW2!*(f2+3): mo$=f3$ 'F3
                                       IF mx>CarW2!*(f3+4) AND mx<CarW2!*(f4+4) THEN mo=1: mp!=CarW2!*(f3+4): mo$=f4$ 'F4
                                       IF mx>CarW2!*(f4+5) AND mx<CarW2!*(f5+5) THEN mo=1: mp!=CarW2!*(f4+5): mo$=f5$ 'F5
                                       IF mx>CarW2!*(f5+6) AND mx<CarW2!*(f6+6) THEN mo=1: mp!=CarW2!*(f5+6): mo$=f6$ 'F6
                                       IF mx>CarW2!*(f6+7) AND mx<CarW2!*(f7+7) THEN mo=1: mp!=CarW2!*(f6+7): mo$=f7$ 'F7
                                       IF mx>x2-CarW2!*(f10+1) THEN mo=1: mp!=x2-CarW2!*(f10+1): mo$=fin$
                                       GOSUB MouseOver
                                     END IF
                                     lb=0: rb=0: mm=0: mb=0: wm=0:  GRAPHIC REDRAW: GRAPHIC COLOR %GREEN,%BLACK: GRAPHIC SET FONT fnt1
                                    RETURN
                                    
                                    MouseOver:REM Show Mouse Over event with small font
                                     GRAPHIC SET FONT fnt2
                                     IF mo=1 THEN
                                       IF fin% THEN GRAPHIC COLOR %WHITE,%RED ELSE GRAPHIC COLOR %YELLOW,%RED
                                     END IF
                                     IF mo=0 THEN
                                       IF fin% THEN GRAPHIC COLOR %BLACK,%GREEN ELSE GRAPHIC COLOR %BLACK,RGB(r,g,b)
                                     END IF
                                     GRAPHIC SET POS (mp!,CarH2!*.6): GRAPHIC PRINT mo$
                                     GRAPHIC SET FONT fnt1
                                    RETURN
                                    
                                    Tools:REM Put  Tools code here
                                     F1$=" F1 Title ": f2$=" F2 Resolution ": f3$=" F3 Font ": f4$=" F4 Point ": f5$=" F5 Style ": f6$=" F6 Color ": f7$=""
                                     GRAPHIC BOX (3, 3)-(x2-5, CarH2!*2),25,%BLACK,%YELLOW                              ' Inner box
                                     mo$="": fin$=" F10 Menu ": fin%=0: tool%=1: GOSUB TopHeading
                                    RETURN
                                    
                                    SavePos:REM Save graphic window position
                                     OPEN "SetScreen.CSV" FOR OUTPUT AS #1: GRAPHIC GET LOC TO x0,y0
                                     PRINT #1,STR$(x0)+","+STR$(y0)
                                    'Futur code to save Tools data
                                     CLOSE #1
                                    RETURN
                                    
                                    ProgName:REM Assign programs names to P1$ to P6$  May be any old or new programs
                                     p1$="Program1"
                                     p2$="Program2"
                                     p3$="Program3"
                                     p4$="Program4"
                                     p5$="Program5"
                                     p6$="Program6"
                                    'Add more code if more buttons used to load other programs
                                    RETURN
                                    
                                    ButtonText:REM Assign names to F1 to F10 buttons
                                     f1$=" F1 Accounting "
                                     f2$=" F2 Billing "
                                     f3$=" F3 Inventory "
                                     F4$=" F4 Projet "
                                     f5$=" F5 Payroll "
                                     f6$=" F6 Text "
                                     f7$=" F7 Tools "
                                    'Add more code if more buttons needed     Fin%=1 is flag to show that main menu is running and we can shut the program
                                     fin$=" F10 Exit ": fin%=1
                                    RETURN
                                    
                                    END FUNCTION
                                    Last edited by Guy Dombrowski; 5 Oct 2008, 09:43 PM.
                                    Old QB45 Programmer

                                    Comment


                                    • #19
                                      Graphic Console 2.0

                                      Hi everybody,

                                      Since this post was widely read I have been working hard to improve the concept and I think you will like the result !
                                      I found a neat trick to ajust the console size the simplest possible way.
                                      Just hit the (+) and (-) keys to increase or decrease the resolution from 800x600 to 1920x1200.
                                      All text and graphic will scale properly.
                                      Let me tell you that a full screen console of that size without caption heading and bottom taskbar is totally awsome.
                                      I also added a little logo I have been using on my printed form.
                                      Of course this is still a work in progress and I will be adding code for a while so stay tuned for my next iteration.
                                      Also any suggestion will be appreciated.

                                      Code:
                                      'A new and better way of ajusting a Graphic Console
                                      'Simply hit the (+) and (-) key to increase or decrease the console size. All fonts and graphics will scale.
                                      'If you have a 1920 x 1200 monitor, you will have 10 differents size to try
                                      'Position is also saved so if you have 2 monitors, you can park the graphic screen in either one.
                                      'The buttons size and location will be ajusted automatically to the text length of F1$ to F7$
                                      'Put your program names in P1$ to P6$.  May be used to call your old modules while writing the new ones.
                                      'Full keyboard and mouse handling including the middle button and scroll wheel
                                      'Bottom Heading will show resolution changes and maximum Desktop size
                                      'The center will show the cursor row position change when using the mouse wheel
                                      '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.  Clic F6 to clear page
                                      'F7 is the start of a printer scrip. It will read 40 lines. The first 20 are the esc codes descriptions and the next 20 are the actual code
                                      'You can edit DotMatrix.txt to add instructions and printer codes as needed.
                                      '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.
                                      'Mouse wheel will move cursor up or down anywhere
                                      'Move mouse over top Buttons for MouseOver effect and click them to start the code associated to them
                                      'Program will end with Exit button or closing window or F1 to F6 if no program exist to load or with the Esc key
                                      
                                      #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
                                       DIM spec$(30),scrn$(30),s$(10)
                                       LOCAL hGraphicWindow AS LONG
                                       DESKTOP GET CLIENT TO DskX,DskY                        ' Find Desk resolution minus task bar if not hidden
                                       DESKTOP GET SIZE TO MonX,MonY                          ' Find Absolute monitor size
                                       TaskBar=MonY-DskY                                      ' Taskbar height ( if normal ? )
                                       CaptionH=TaskBar: IF CaptionH=0 THEN CaptionH=MonY/32  ' Aproximate height if TaskBar hidden
                                      
                                       drv$=LEFT$(CURDIR$,2): spec$=drv$+"specsys"            ' Lire spec Drive par default
                                       GOSUB LitSpec
                                      
                                      Setting:REM read saved Screen Setting position and resolution and mix special colors that will be used in our menus
                                       rouge=RGB(255,200,200): rose=RGB(255,0,255): vert=RGB(200,255,200): bleu=RGB(100,200,255): jaune=RGB(255,255,170): orange=RGB(255,180,50): gris=RGB(220,220,220)
                                       x0=0: y0=0: pt=0: x1=0: y1=0: pt=0: x2=800:  y2=600:  pt0=9:  pt1=10: pt2=6:  pt3=49 ' Minimum setup
                                       OPEN "SetScreen.TXT" FOR INPUT AS #1: IF ERR>0 THEN ERR=0: GOTO StartWindow          ' First time with no setup data
                                       REDIM s$(2): IF EOF(1)=0 THEN LINE INPUT#1,z$: PARSE z$,s$(),","                     ' Read last saved position
                                       IF s$(0)<>"" THEN x0=VAL(s$(0)): y0=VAL(s$(1)): scr%=VAL(s$(2))                      ' Graphic Window position and resolution
                                       CLOSE #1: GOSUB ReadCaption
                                      
                                      StartWindow:REM Start Graphic Window with variable resolution controled with the (+) and (-) key
                                       FONT NEW "Sylfaen",pt+pt0,0,0,0 TO fnt0           ' Big font for banner heading no need to be monospace type
                                       FONT NEW "Lucida Console",pt+pt1,0,0,0,0 TO fnt1  ' Regular font for data entry must be monospace
                                       FONT NEW "Courier new",pt+pt2,1,0,0,0 TO fnt2     ' Smaller font for buttons and prompt must be monospace
                                       FONT NEW "sylfaen",pt+pt3,1,0,0,0 TO fnt3         ' Giant font for center Logo no need for monospace
                                       GRAPHIC WINDOW caption$,x1,y1,x2,y2 TO hGraphicWindow
                                       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 LOC x1,y1
                                       GRAPHIC SET FONT fnt2: GRAPHIC CHR SIZE TO CarW2!,CarH2! ' Find pixel width and height of fnt2 graphic font
                                       GRAPHIC SET FONT fnt1: GRAPHIC CHR SIZE TO CarW!,CarH!   ' Find pixel width and height of fnt1 graphic font
                                       GRAPHIC CLEAR %BLACK,%GREEN: GRAPHIC COLOR %GREEN,%BLACK ' Black background with Green text like old time
                                       MaxCol=x2/CarW!: MaxRow=y2/CarH!-3                       ' Maximums will depend on number of pixels on desktop
                                       GRAPHIC WIDTH 1: GRAPHIC REDRAW                          ' Show screen background instantly
                                       GOSUB ProgName: GOSUB ButtonText                         ' Assign programs and names to buttons
                                       GOSUB TopHeading: GRAPHIC COLOR %GREEN,%BLACK            ' Show Top Menu
                                       GOSUB BottomHeading: GRAPHIC COLOR %GREEN,%BLACK         ' Show Bottom Menu
                                       x=0: y=2: csr=-2                                         ' Cursor start position and style -2 is empty rectangle
                                      
                                      KeyMouse:REM Keyboard and Mouse input
                                       GRAPHIC GET DC TO hwin: IF hwin=0 THEN END                                  ' Graphic Window has been closed
                                       GRAPHIC INKEY$ TO ink$: SLEEP 1: ink%=0: GOSUB CursorOn
                                         IF ink$=CHR$(27) THEN                                                     ' Esc key end Utility Menu or Main Program if in Main Menu
                                           IF fin% THEN GOSUB SavePos: GRAPHIC WINDOW END: END
                                           IF tool% THEN GOSUB ClearScrn: GOSUB ButtonText: GOSUB TopHeading: tool%=0
                                         END IF
                                      'Mouse section
                                         IF lb AND my<CarH2!*2 THEN ' Clicking the F1 to f6 buttons with mouse Left button will start new program but will not end menu like the Function keys
                                           IF fin% THEN csr=-2: GOSUB CursorOff: x=mx/CarW!-1: y=my/CarH!-1: GOSUB CursorOn
                                           IF mx>CarW2! AND mx<CarW2!*(f1+1) AND fin% THEN SHELL p1$                 ' F1 Program
                                           IF mx>CarW2!*(f1+2) AND mx<CarW2!*(f2+2) AND fin% THEN SHELL p2$          ' F2 Program
                                           IF mx>CarW2!*(f2+3) AND mx<CarW2!*(f3+3) AND fin% THEN SHELL p3$          ' F3 Program
                                           IF mx>CarW2!*(f3+4) AND mx<CarW2!*(f4+4) AND fin% THEN SHELL p4$          ' F4 Program
                                           IF mx>CarW2!*(f4+5) AND mx<CarW2!*(f5+5) AND fin% THEN SHELL p5$          ' F5 Program
                                           IF mx>CarW2!*(f5+6) AND mx<CarW2!*(f6+6) AND fin% THEN GOSUB ClearScrn    ' F6 Wipe screen to try text and mouse
                                           IF mx>CarW2!*(f6+7) AND mx<CarW2!*(f7+7) AND fin% THEN GOSUB Utilitaires  ' F7 Code inside menu
                                             IF mx>x2-CarW2!*(f0+1) AND mo=1 THEN
                                               GOSUB ClearScrn
                                               IF fin% THEN GOSUB SavePos: fin%=0: END                      ' End button pressed in Main Menu  Program end
                                               IF tool% THEN GOSUB ButtonText: GOSUB TopHeading: tool%=0    ' End Button pressed in Utility menu back to main menu
                                             END IF
                                         END IF
                                      'Show action Results
                                       IF lb OR rb THEN csr=-2: GOSUB CursorOff: x=mx/CarW!-1: y=my/CarH!-1: GOSUB CursorOn:            ' Show Cursor position when left or right button clicked
                                       IF wm THEN
                                         csr=-2: GOSUB CursorOff: y=y-wm: IF y<2 THEN BEEP: y=2 ELSE IF y>MaxRow THEN BEEP: y=MaxRow    ' Wheel mouse limit
                                         GOSUB CursorOn
                                       END IF
                                       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$="": csr=-2
                                         IF ink%=59 AND fin% THEN GRAPHIC WINDOW END: SHELL p1$  ' F1 key  The F keys will terminate the menu but the buttons will not
                                         IF ink%=60 AND fin% THEN GRAPHIC WINDOW END: SHELL p2$  ' F2 key
                                         IF ink%=61 AND fin% THEN GRAPHIC WINDOW END: SHELL p3$  ' F3 key
                                         IF ink%=62 AND fin% THEN GRAPHIC WINDOW END: SHELL p4$  ' F4 key
                                         IF ink%=63 AND fin% THEN GRAPHIC WINDOW END: SHELL p5$  ' F5 key
                                         IF ink%=64 AND fin% THEN GOSUB ClearScrn                ' F6 key Will simply wipe screen
                                         IF ink%=65 AND fin% THEN GOSUB Utilitaires              ' F7 Utility section with own menu
                                         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-1 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$(8) AND x>0 THEN ink$="": GOSUB CursorOff: x=x-1: csr=-2: GOSUB ScrnPrint
                                         IF ink$="+" THEN
                                           IF scr%<9 THEN scr%=scr%+1: GRAPHIC WINDOW END: GOSUB ReadCaption:  GOTO StartWindow ELSE BEEP       ' Restart graphic window with more resolution
                                         END IF
                                         IF ink$="-" THEN
                                            IF scr%>0 THEN scr%=scr%-1: x2=0: GRAPHIC WINDOW END: GOSUB ReadCaption: GOTO StartWindow  ELSE BEEP ' Restart graphic window with less resolution
                                         END IF
                                       IF ink$=CHR$(13) THEN csr=-2: GOSUB CursorOff: x=0: IF y<MaxRow THEN y=y+1 ELSE BEEP
                                       IF ink$>CHR$(31) THEN csr=-2: 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 with big font Fnt1
                                       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 y<=MaxRow AND csr<>0 THEN GRAPHIC BOX (x*CarW!,y*CarH!)-(x*CarW!+CarW!,y*CarH!+CarH!),0,%WHITE,csr: csr=0: GRAPHIC REDRAW
                                      RETURN
                                      
                                      CursorOff:REM erase cursor at end of line CR or mouse click and redraw at next position
                                       IF y>1 AND y<=MaxRow 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 menu Buttons will be sized automatically by their text length   0=no button
                                       GRAPHIC SET FONT fnt2
                                       f0=LEN(fin$): f1=LEN(f1$)
                                       f2=LEN(f1$+f2$): IF f2$="" THEN f2=0
                                       f3=f2+LEN(f3$): IF f3$="" THEN f3=0
                                       f4=f3+LEN(f4$): IF f4$="" THEN f4=0
                                       f5=f4+LEN(f5$): IF f5$="" THEN f5=0
                                       f6=f5+LEN(f6$): IF f6$="" THEN f6=0
                                       f7=f6+LEN(f7$): IF f7$="" THEN f7=0
                                       f8=f7+LEN(f8$): IF f8$="" THEN f8=0
                                       f9=f8+LEN(f9$): IF f9$="" THEN f9=0
                                       GOSUB Banner: GOSUB logo: GOSUB Welcome
                                      'Dessiner les boutons du haut
                                       GRAPHIC SET FONT fnt2
                                       GRAPHIC BOX (0, 0)-(x2-1, CarH2!*2+2),25,%WHITE,%WHITE  ' Outer box Main Menu
                                       GRAPHIC BOX (2, 2)-(x2-3, CarH2!*2),25,%BLACK,%YELLOW   ' Inner box Main Menu
                                       IF fin% THEN r=0: g=255: b=0 ELSE r=255: g=170: b=0     ' Change Buttons background color for Utility Menu
                                       tint=RGB(r,g,b)
                                       IF f0 THEN GRAPHIC BOX (x2-CarW2!*(f0+1.4), 5)-(x2-6, CarH2!*2-3),25,%BLACK,tint            ' Esc End box
                                       IF f1 THEN GRAPHIC BOX (CarW2!*.6, 5)-(CarW2!*(f1+1.3), CarH2!*2-3),25,%BLACK,tint          ' F1 box
                                       IF f2 THEN GRAPHIC BOX (CarW2!*(f1+1.7), 5)-(CarW2!*(f2+2.3), CarH2!*2-3),25,%BLACK,tint    ' F2 box
                                       IF f3 THEN GRAPHIC BOX (CarW2!*(f2+2.7), 5)-(CarW2!*(f3+3.3), CarH2!*2-3),25,%BLACK,tint    ' F3 box
                                       IF f4 THEN GRAPHIC BOX (CarW2!*(f3+3.7), 5)-(CarW2!*(f4+4.3), CarH2!*2-3),25,%BLACK,tint    ' F4 box
                                       IF f5 THEN GRAPHIC BOX (CarW2!*(f4+4.7), 5)-(CarW2!*(f5+5.3), CarH2!*2-3),25,%BLACK,tint    ' F5 box
                                       IF f6 THEN GRAPHIC BOX (CarW2!*(f5+5.7), 5)-(CarW2!*(f6+6.3), CarH2!*2-3),25,%BLACK,tint    ' F6 box
                                       IF f7 THEN GRAPHIC BOX (CarW2!*(f6+6.7), 5)-(CarW2!*(f7+7.3), CarH2!*2-3),25,%BLACK,tint    ' F7 box
                                       IF f8 THEN GRAPHIC BOX (CarW2!*(f7+7.7), 5)-(CarW2!*(f8+8.3), CarH2!*2-3),25,%BLACK,tint    ' F8 box
                                       IF f9 THEN GRAPHIC BOX (CarW2!*(f8+8.7), 5)-(CarW2!*(f9+9.3), CarH2!*2-3),25,%BLACK,tint    ' F9 box
                                      'Ajouter textes dans les boutons
                                       IF fin% THEN GRAPHIC COLOR %BLACK,%GREEN ELSE GRAPHIC COLOR %BLACK,tint
                                       IF f0 THEN GRAPHIC SET POS (x2-CarW2!*(f0+1), CarH2!*.6): GRAPHIC PRINT fin$                   ' Esc End Text
                                       IF f1 THEN GRAPHIC SET POS (CarW2!, CarH2!*.6): GRAPHIC PRINT f1$                              ' F1 text
                                       IF f2 THEN GRAPHIC SET POS (CarW2!*(f1+2), CarH2!*.6): GRAPHIC PRINT f2$                       ' F2 Text
                                       IF f3 THEN GRAPHIC SET POS (CarW2!*(f2+3), CarH2!*.6): GRAPHIC PRINT f3$                       ' F3 Text
                                       IF f4 THEN GRAPHIC SET POS (CarW2!*(f3+4), CarH2!*.6): GRAPHIC PRINT f4$                       ' F4 Text
                                       IF f5 THEN GRAPHIC SET POS (CarW2!*(f4+5), CarH2!*.6): GRAPHIC PRINT f5$                       ' F5 Text
                                       IF f6 THEN GRAPHIC SET POS (CarW2!*(f5+6), CarH2!*.6): GRAPHIC PRINT f6$                       ' F6 Text
                                       IF f7 THEN GRAPHIC SET POS (CarW2!*(f6+7), CarH2!*.6): GRAPHIC PRINT f7$                       ' F7 Text
                                       IF f8 THEN GRAPHIC SET POS (CarW2!*(f7+8), CarH2!*.6): GRAPHIC PRINT f8$                       ' F8 Text
                                       IF f9 THEN GRAPHIC SET POS (CarW2!*(f8+9), CarH2!*.6): GRAPHIC PRINT f9$                       ' F9 Text
                                       GRAPHIC REDRAW
                                       GRAPHIC SET FONT fnt1
                                      RETURN
                                      
                                      BottomHeading:REM Bottom box to display mouse results with small font
                                       GRAPHIC SET FONT fnt2
                                       GRAPHIC BOX (0, y2-CarH2!*2)-(x2-2, y2),25,%WHITE,%WHITE             ' Outer box
                                       GRAPHIC BOX (3, y2-CarH2!*2+3)-(x2-5, y2-3),25,%BLACK,%RED           ' Inner box
                                       GRAPHIC COLOR noir,jaune
                                       GRAPHIC SET POS (CarW2!, y2-CarH2!*1.5): GRAPHIC PRINT" Resolution ="+STR$(x2)+" x"+STR$(y2)+" "
                                       GRAPHIC SET POS (CarW2!*29, y2-CarH2!*1.5): GRAPHIC PRINT " DeskTop ="+STR$(DskX)+" x"+STR$(DskY)+" "
                                      
                                       GRAPHIC SET POS (x2-CarW2!*44, y2-CarH2!*1.5): GRAPHIC PRINT " MaxRow = "+LTRIM$(STR$(maxRow+3))+"  Column = "+LTRIM$(STR$(MaxCol))+" "
                                       GRAPHIC SET POS (x2-CarW2!*15, y2-CarH2!*1.5): GRAPHIC PRINT" Grid =" STR$(carw!)+"x"+LTRIM$(STR$(carh!))+" "  ' Show size of caracter box
                                       GRAPHIC REDRAW
                                       GRAPHIC SET FONT fnt1
                                      RETURN
                                      
                                      Prompt:REM Show mouse events on Bottom Heading with small font
                                       GRAPHIC SET FONT fnt2: GRAPHIC COLOR noir,jaune
                                      'Show cursor position
                                       GRAPHIC SET POS (55*CarW2!, y2-CarH2!*1.5): GRAPHIC PRINT" Cursor is at "+STR$(x+1)+" x"+STR$(y+1)+" "
                                      'Show mouse over effects
                                       IF mo=1 THEN mo=0: GOSUB MouseOver  ' All Buttons off
                                       IF mo=0 AND my<CarH2!*2 AND my>CarH2!/4 AND mx>CarW2!/4 AND mx<x2-CarW2!/2 THEN
                                         IF mx>CarW2! AND mx<CarW2!*(f1+1) THEN mo=1: mp!=CarW2!: mo$=f1$ '              F1
                                         IF mx>CarW2!*(f1+2) AND mx<CarW2!*(f2+2) THEN mo=1: mp!=CarW2!*(f1+2): mo$=f2$ 'F2
                                         IF mx>CarW2!*(f2+3) AND mx<CarW2!*(f3+3) THEN mo=1: mp!=CarW2!*(f2+3): mo$=f3$ 'F3
                                         IF mx>CarW2!*(f3+4) AND mx<CarW2!*(f4+4) THEN mo=1: mp!=CarW2!*(f3+4): mo$=f4$ 'F4
                                         IF mx>CarW2!*(f4+5) AND mx<CarW2!*(f5+5) THEN mo=1: mp!=CarW2!*(f4+5): mo$=f5$ 'F5
                                         IF mx>CarW2!*(f5+6) AND mx<CarW2!*(f6+6) THEN mo=1: mp!=CarW2!*(f5+6): mo$=f6$ 'F6
                                         IF mx>CarW2!*(f6+7) AND mx<CarW2!*(f7+7) THEN mo=1: mp!=CarW2!*(f6+7): mo$=f7$ 'F7
                                         IF mx>x2-CarW2!*(f0+1) THEN mo=1: mp!=x2-CarW2!*(f0+1): mo$=fin$
                                         GOSUB MouseOver
                                       END IF
                                       lb=0: rb=0: mm=0: mb=0: wm=0:  GRAPHIC REDRAW: GRAPHIC COLOR %GREEN,%BLACK: GRAPHIC SET FONT fnt1
                                      RETURN
                                      
                                      MouseOver:REM Show Mouse Over event with small font
                                       GRAPHIC SET FONT fnt2
                                       IF mo=1 THEN
                                         IF fin% THEN GRAPHIC COLOR %WHITE,%RED ELSE GRAPHIC COLOR %YELLOW,%RED
                                       END IF
                                       IF mo=0 THEN
                                         IF fin% THEN GRAPHIC COLOR %BLACK,%GREEN ELSE GRAPHIC COLOR %BLACK,orange
                                       END IF
                                       GRAPHIC SET POS (mp!,CarH2!*.6): GRAPHIC PRINT mo$
                                       GRAPHIC SET FONT fnt1
                                      RETURN
                                      
                                      Utilitaires:REM Program set up
                                       F1$=" F1 Spécifications ": f2$=" F2 Ouverture ": f3$=" F3 Installation ": f4$=" F4 Imprimantes ": f5$=" F5 Back-Up ": f6$=" F6 Outils ": f7$=""
                                       mo$="": fin$=" Esc Menu ": fin%=0: tool%=1
                                       GOSUB TopHeading: GOSUB ClearScrn: GOSUB readLpt: GRAPHIC SET FONT fnt1
                                       x5!=INT((MaxCol-60)/4)*CarW!: y5!=(INT(bry/CarH!)*CarH!)                                 ' Utility Box Start position level with logo
                                       x6!=x5!+40*CarW!: y6!=y5!+21*CarH!+CarH!/2                                 ' Box size
                                       GRAPHIC BOX (x5!, y5!+CarH!/2)-(x6!, y6!),5,%WHITE,%WHITE          ' Outer box
                                       GRAPHIC BOX (x5!+3, y5!+3+CarH!/2)-(x6!-4, y6!-4),5,noir,bleu      ' Inner box
                                       x!=(x5!/CarW!)+1: y!=(y5!/CarH!)
                                       GRAPHIC COLOR noir,bleu
                                       FOR t=1 TO 20: GRAPHIC SET POS (x!*CarW!, y5!+CarH!*t): GRAPHIC PRINT t$(t+20): NEXT
                                       GRAPHIC COLOR %GREEN,%BLACK
                                       FOR t=1 TO 20: GRAPHIC SET POS ((x!+40)*CarW!, y5!+CarH!*t): GRAPHIC PRINT t$(t): NEXT
                                       'x=(x5!/CarW!)+41: y=(y6!/CarH!)
                                       mo=0: mp!=y
                                      
                                       GRAPHIC SET POS ((x!+40)*carW!, y5!+CarH!)
                                       GRAPHIC PRINT"***"
                                      
                                       x=(x!+40)*CarW!: y=y5!+CarH!
                                       GOSUB CursorOn
                                      RETURN
                                      
                                      ReadLpt:REM read LPT codes
                                       t%=0: REDIM t$(40)
                                       OPEN "DotMatrix.TXT" FOR INPUT AS #1
                                        IF ERR>0 THEN
                                          OPEN "DotMatrix.TXT" FOR OUTPUT AS #1: FOR t%=1 TO 14: t$(t%)=spec$(t%): PRINT #1,t$(t%): NEXT: t%=40
                                        END IF
                                       WHILE EOF(1)=0 AND t%<40:  t%=t%+1:LINE INPUT#1,t$(t%): WEND
                                       CLOSE #1
                                      RETURN
                                      
                                      ClearScrn:REM erase screen
                                       GRAPHIC BOX (0, CarH!*2-2)-(x2, y2-CarH!*2),0,%BLACK,%BLACK          ' Make solid black box
                                      RETURN
                                      
                                      SavePos:REM Save graphic window position and resolution
                                       OPEN "SetScreen.TXT" FOR OUTPUT AS #1: GRAPHIC GET LOC TO x0,y0
                                       PRINT #1,STR$(x0)+","+STR$(y0)+","+STR$(scr%)
                                       CLOSE #1
                                      RETURN
                                      
                                      ProgName:REM Assign programs names to P1$ to P6$
                                       p1$="\mg3\menu-mg3.exe": p2$="\mg3\factumg5.exe": p3$="\mg3\geinvmgi.exe": p4$="\mg3\gesprmgc.exe": p5$="\mg3\paie-mp4.exe": p6$="\mg3\edit-mg3.exe"
                                      'Add more code if more buttons used to load other programs
                                      RETURN
                                      
                                      ButtonText:REM Assign names to F1 to F10 buttons
                                       f1$=" F1 Accounting ": f2$=" F2 Billing ": f3$=" F3 Inventory ": F4$=" F4 Projet ": f5$=" F5 Payroll ": f6$=" F6 Text ": f7$=" F7 Tools ": fin$=" Esc Exit "
                                       fin%=1 ' Flag for main menu to enable end of program
                                      'Add more code if more buttons needed
                                      RETURN
                                      
                                      StrSize:REM Find Pixel width and height size of text string.  Find Grid size per caracter
                                       txt$=" "+txt$+" ": GRAPHIC TEXT SIZE txt$ TO tw,th: GRAPHIC TEXT SIZE "Z" TO gw,gh
                                      RETURN
                                      
                                      Banner:REM Banner showing Name, Data folder Location, Accounting period and Menu name
                                       GRAPHIC SET FONT fnt0: txt$="Z": GOSUB StrSize
                                       GRAPHIC BOX (gw*11.5, CarH2!*2.5)-(x2-gw*11.5, CarH2!*3+gh*3.5),10,%WHITE,%WHITE               ' Outer box
                                       GRAPHIC BOX (gw*11.5+4, CarH2!*2.5+3)-(x2-(gw*11.5)-4, CarH2!*3+gh*3.5-4),10,noir,orange       ' Inner box
                                       GRAPHIC COLOR noir,jaune
                                       txt$=nom$: GOSUB StrSize: GRAPHIC SET POS ((x2-tw)/2, CarH2!*3): GRAPHIC PRINT txt$            ' Company name on top
                                       GRAPHIC SET POS (gw*12.5, CarH2!*3+gh): GRAPHIC PRINT folder$                                  ' Data Folder on left
                                       txt$=period$: GOSUB StrSize: GRAPHIC SET POS (x2-tw-gw*12.5, CarH2!*3+gh): GRAPHIC PRINT txt$  ' Period on right
                                       txt$=titre$: GOSUB StrSize: GRAPHIC SET POS ((x2-tw)/2, CarH2!*3+gh*2): GRAPHIC PRINT txt$     ' Title at bottom
                                      RETURN
                                      
                                      Welcome:REM Banner showing Welcome at start of program
                                       GRAPHIC SET FONT fnt0: txt$="Welcome to the first PowerBasic Graphic Console": GOSUB StrSize
                                       GRAPHIC BOX ((x2-tw)/2-gw*2, bry+br+gh)-(x2-(x2-tw)/2+gw*2, bry+br+gh*4),10,%WHITE,%WHITE               ' Outer box
                                       GRAPHIC BOX ((x2-tw)/2-gw*2+3, bry+br+gh+3)-(x2-(x2-tw)/2+gw*2-3, bry+br+gh*4-3),10,noir,rose           ' Inner box
                                       GRAPHIC COLOR %WHITE,rose
                                       GOSUB StrSize: GRAPHIC SET POS ((x2-tw)/2, bry+br+gh*1.5): GRAPHIC PRINT txt$
                                       txt$=" Simply hit the (+) and (-) keys to ajust screen sizes ": GRAPHIC SET POS ((x2-tw)/2, bry+br+gh*2.5): GRAPHIC PRINT txt$
                                      RETURN
                                      
                                      logo:REM Print a round logo in the graphic window Center
                                       Author$="Guy Dombrowski Inc": Program$="MacroGestion 6.0": logoName$="MG6"
                                       GRAPHIC WIDTH 4 : GRAPHIC SET FONT fnt0
                                       br=y2*9/16: brx=(x2-br)/2: bry=(y2-br)/2                             ' Bounding Rectangle size = 9/16 of screen height and will always be centered
                                       ir=br*89/128: irx=brx+(br-ir)/2: iry=bry+(br-ir)/2                   ' Inner Rectangle size tied to Bounding Rectangle Circle
                                       GRAPHIC ELLIPSE (brx, bry)-(brx+br, bry+br),%WHITE,%GREEN            ' Outer Circle
                                       GRAPHIC ELLIPSE (brx+3, bry+3)-(brx+br-3, bry+br-3),%BLACK,%GREEN    ' Inner Circle
                                       GRAPHIC BOX (irx, iry)-(irx+ir, iry+ir),0,%BLACK,jaune               ' Draw center box
                                      'Couleurs des arcs
                                       GRAPHIC PAINT REPLACE (irx+ir/2, (iry+(bry-iry)/4)), %YELLOW,%GREEN  ' top arc yellow
                                       GRAPHIC PAINT REPLACE (irx+ir/2, (bry+br-(br-ir)/4)), %RED,%GREEN    ' bottom arc red
                                       GRAPHIC PAINT REPLACE (irx+ir+(br-ir)/4, brx+(br-ir)/4),%CYAN,%GREEN ' right arc cyan
                                      'Boites internes de texte
                                       GRAPHIC BOX (irx, iry)-(irx+ir, iry+th*2),0,%BLACK,orange            ' top text box orange
                                       GRAPHIC BOX (irx, iry+ir-th*2)-(irx+ir, iry+ir),0,%BLACK,orange      ' Bottom text box orange
                                       GRAPHIC COLOR noir,jaune
                                       txt$=Author$: GOSUB StrSize: GRAPHIC SET POS (irx+(ir-tw)/2, iry+th/2): GRAPHIC PRINT txt$          ' Author Name
                                       txt$=program$: GOSUB Strsize: GRAPHIC SET POS (irx+(ir-tw)/2, iry+ir-th*1.5 ): GRAPHIC PRINT txt$   ' Program Name
                                       GRAPHIC SET FONT fnt3
                                       txt$=LogoName$: GOSUB StrSize: GRAPHIC SET POS (irx+(ir-tw)/2, iry+(ir-th)/2-4): GRAPHIC PRINT txt$ ' Logo Name
                                       GRAPHIC WIDTH 1
                                      RETURN
                                      
                                      ReadCaption:REM Check Screen Resolution  (+) increase (-) decrease  pt0=Banner pt1=Main pt2=Buttons pt3=Logo
                                       caption$="Graphic console.  Enter text and hit Return or Click Mouse to next input position or use MouseWheel"
                                       x1=x0: y1=y0
                                      AjustScreen:REM Choose resolution and font size depending on scr%
                                       IF scr%=0 THEN x2=800:  y2=600:  pt0=9:  pt1=10: pt2=6:  pt3=49
                                       IF scr%=1 THEN x2=1024: y2=768:  pt0=11: pt1=12: pt2=8:  pt3=58
                                       IF scr%=2 THEN x2=1152: y2=864:  pt0=12: pt1=13: pt2=9:  pt3=68
                                       IF scr%=3 THEN x2=1280: y2=1024: pt0=14: pt1=15: pt2=10: pt3=82
                                       IF scr%=4 THEN x2=1440: y2=900:  pt0=14: pt1=16: pt2=11: pt3=76
                                       IF scr%=5 THEN x2=1600: y2=1024: pt0=15: pt1=16: pt2=12: pt3=85
                                       IF scr%=6 THEN x2=1600: y2=1200: pt0=16: pt1=19: pt2=12: pt3=88
                                       IF scr%=7 THEN x2=1680: y2=1050: pt0=17: pt1=19: pt2=13: pt3=88
                                       IF scr%=8 THEN x2=1920: y2=1200: pt0=20: pt1=22: pt2=14: pt3=95
                                       IF scr%=9 THEN caption$="": pt0=20: pt1=22: pt2=14: pt3=95: x1=0: y1=0      ' Max resolution Full Screen permanent no TaskBar no Caption
                                       IF x2>DskX THEN scr%=scr%-1: caption$="": GOTO AjustScreen                  ' Max resolution Full Screen reached for lesser monitors
                                       IF y2>DskY-Taskbar AND scr%<9 THEN y2=DskY-TaskBar                          ' Do not hide the TaskBar
                                       IF caption$<>"" AND y2=DskY THEN y2=y2-CaptionH                             ' Allow for Caption Height
                                       IF caption$="" THEN x2=MonX: y2=MonY: x1=0: y1=0                            ' Full screen if no caption
                                      RETURN
                                      
                                      litspec:REM Code to read custommer data
                                       nom$=" Your Custommer name "
                                       folder$=" C:\MG6\ABC06-08 "  ' Name and location of accounting files
                                       period$=" Période "+RIGHT$(DATE$,7)
                                       titre$=" Main accounting Menu "
                                      RETURN
                                      
                                      END FUNCTION
                                      Last edited by Guy Dombrowski; 14 Oct 2008, 12:21 PM. Reason: Decrease CPU usage by not drawing cursor all the time
                                      Old QB45 Programmer

                                      Comment


                                      • #20
                                        Mr Dumbrowski,

                                        for those of us who are thinking about buying PBCC V5 but have not yet made up their minds, please could you post screenshots?

                                        Thanks!

                                        Comment

                                        Working...
                                        X