Announcement

Collapse
No announcement yet.

Need to print a Special Character to console screen

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

  • Need to print a Special Character to console screen

    Hi,
    I have a program written in PBCC 5.0. The font properties of the shortcut
    that start the program is set to Raster/Terminal 10x18.

    I am trying to display on the console screen a character that is not one of the 255 characters available in the raster/terminal font. Is there any way I can make this special character and imbed it in a resource file or something and then be able to display it on the console screen at a specific row and column using Locate.

    For Example Locate 25,30:PRINT SPECIALCHAR$

    Thanks my Friends in advance for your help and suggestions.
    Mary

  • #2
    Hi Mary!

    That's a tough one! I gave this a try and was able to use some of the Windows Graphics Device Interface Functions to output text to the console screen...

    Code:
    #Compile Exe
    #Dim All
    #Include "Win32Api.inc"
    Declare Function GetConsoleWindow Lib "Kernel32.dll" Alias "GetConsoleWindow" () As Dword
                                                                                                       
    Function PBMain() As Long
      Local lpPaint As PAINTSTRUCT
      Local strText As String
      Local hWnd As Dword
      Local hDC As Long
      
      hWnd=GetConsoleWindow()
      hDC=GetDC(hWnd)
      strText="Mary Needs To Print Something Unusual To The Console."
      Call TextOut(hDC,0,0,Byval Strptr(strText),Len(strText))
      strText="Can Probably Use Low Level Graphics Primitives In"
      Call TextOut(hDC,0,16,Byval Strptr(strText),Len(strText))
      strText="Windows Graphics Device Interface."
      Call TextOut(hDC,0,32,Byval Strptr(strText),Len(strText))
      ReleaseDC(hWnd,hDC)
      Waitkey$
    
      PBMain=0
    End Function
    Maybe I'm way off base, but I'm thinking it could possibly be done by creating the special character as a bit map, then using the GDI functions to draw it to the screen as I did above with the text. Hopefully somebody can come up with an easier way?
    Fred
    "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

    Comment


    • #3
      Wow! Just dawned on me that's a natural for all the new wiz-bang graphics available with the newer compilers. I see there are a plethora of graphics statements. Of course, you would have to use graphics windows. Since I've never used any, I'm not the right one to help!
      Fred
      "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

      Comment


      • #4
        Mary --

        Is there any way I can make this special character and imbed it in a resource file or something and then be able to display it on the console screen at a specific row and column using Locate.
        As far as I know, the only way to do that would be to create a custom font that includes the special character. Raster fonts are relatively easy to create but there are a number of complications. If it seems like a viable option for you, I'll elaborate.

        -- Eric
        "Not my circus, not my monkeys."

        Comment


        • #5
          Here is a solution that is not so pretty but it works.

          It displays a Courier character on the console screen at the specified row, column. Hit any key to display a different random character. Hit ESC to quit the program.

          Works for 10x18 raster font.

          Need to include Gert Volands "GRBUTTONS.INC".

          Basically creating a graphic window of size 10x18 pixels at the required location and using graphic print to put any graphic character there. You can drag the console screen around but it has a funny look as the graphic screen catches up with the console.

          Code:
          #COMPILE EXE
          #DIM ALL
          
          %WINDOW_CHAR = 12
          #INCLUDE "GrButtons.inc"                    'From Gert Voland
          
          FUNCTION PBMAIN () AS LONG
          
              LOCAL wGW, hGW, xGW, yGW AS LONG
              LOCAL x0, y0 AS LONG
              LOCAL row,col AS LONG
              LOCAL retbutton AS LONG
              LOCAL specialchar AS STRING
              LOCAL ikey AS STRING
          
              GLOBAL courier18 AS LONG
              FONT NEW "Courier New", 12 TO courier18
          
              row = 2
              col = 30
          
              'For Example Locate 25,30:PRINT SPECIALCHAR$  locate row,col
          
              CONSOLE GET LOC TO x0, y0
              wGW = 10                                              'width and height of GW   10x18 font
              hGW = 18
              xGW = col*wGW                                              'relative position of GW to Console
              yGW = row*hGW
          
              CONSOLE GET LOC TO x0, y0        'need to set console position again.
              CALL charwindow(x0 + xGW-5, y0 + yGW+13, wGW, hGW, specialchar) 'open the character window
          
              PRINT "12345678901234567890123456789012345678901234567890"
              PRINT "12345678901234567890123456789012345678901234567890"
              PRINT "12345678901234567890123456789012345678901234567890"
              PRINT "12345678901234567890123456789012345678901234567890"
              PRINT "12345678901234567890123456789012345678901234567890"
              CONSOLE SET FOCUS
              GRAPHIC SET FONT courier18
          
              DO
                  CALL GraphicGetEvents(retButton)
                  SLEEP 1  'release the processor
                  
                  GRAPHIC SET POS (0,0)
                  GRAPHIC PRINT CHR$(RND*100+100)     'display random courier character with key hit
                  GRAPHIC REDRAW
                                              'release processor
                  ikey = WAITKEY$
                  IF ikey = $ESC THEN EXIT DO         'quit on esc
              LOOP
          
          END FUNCTION
          
          '----------------------------------------------------------------------------
          
          SUB charwindow(BYVAL xpos AS LONG, ypos AS LONG, BYVAL w AS LONG, BYVAL h AS LONG, BYVAL char AS STRING)
          
              'Create the control window
              CALL GraphicCreateWindow(%WINDOW_CHAR, "", xpos, ypos, w, h)
              GRAPHIC COLOR %WHITE, %BLACK
              GRAPHIC REDRAW
          
          END SUB 'MainWindow

          Comment

          Working...
          X