CA - Visual Objects


This is made by using Computer Associates tool CA - Visual Objects. It acts just like original. Actually here is two versions first one is made by John Forsberg ( uses API interface ) and second one ( Uses VO's GUI classes made by Jari Sevòn. First one is only tested with VO 1.x, but second version works also with 2.0.


API Version:

TEXTBLOCK HELLOWIN.C  --  (c) Charles Petzold, 1992
/*--------------------------------------------------------
   HELLOWIN.C -- Displays "Hello, Windows" in client area
                 (c) Charles Petzold, 1992

   HELLOWIN.PRG - CA Visual Objects adaptation
                        John Forsberg, 1994
  --------------------------------------------------------*/


FUNCTION Start()

  STATIC szAppName := "HelloWin"            AS STRING
  LOCAL hWnd                                                      AS WORD
  LOCAL msg                                                         IS
_WINMSG
  LOCAL wndclass                                               IS
_WINWNDCLASS

  /* Parameters not received by VO */
  LOCAL hPrevinstance := _GetPrevInst()     AS WORD
  LOCAL hInstance          := _GetInst()               AS WORD
  LOCAL nCmdShow      := _GetCmdShow()  AS WORD

  IF hPrevInstance == 0

    wndclass.style         := _OR(CS_HREDRAW, CS_VREDRAW)
    wndclass.lpfnWndProc        := @WndProc()
    wndclass.cbClsExtra            := 0
    wndclass.cbWndExtra         := 0
    wndclass.hInstance              := hInstance
    wndclass.hIcon                      := LoadIcon (hInstance,
IDI_APPLICATION)
    wndclass.hCursor                 := LoadCursor (0, IDC_ARROW)
    wndclass.hbrBackground  := GetStockObject (WHITE_BRUSH)
    wndclass.lpszMenuName := ""
    wndclass.lpszClassName := szAppName

    RegisterClass (@wndclass)
  ENDIF

  hwnd := CreateWindow (szAppName, ;        // window class name
                 "The Hello Program", ;                        // window
caption
                 WS_OVERLAPPEDWINDOW, ;      // window style
                 CW_USEDEFAULT, ;                          // initial x
position
                 CW_USEDEFAULT, ;                          // initial y
position
                 CW_USEDEFAULT, ;                          // initial x
size
                 CW_USEDEFAULT, ;                          // initial y
size
                 0, ;
        // parent window handle
                 0, ;
        // window menu handle
                 hInstance, ;
// program instance handle
                NULL_PTR)                                            //
creation parameters

/*  Not in the book.  Add it if you prefer */
//  if hWnd = 0
//    return FALSE
//  endif

  ShowWindow (hwnd, nCmdShow)
  UpdateWindow (hwnd)

  WHILE (GetMessage (@msg, 0, 0, 0))
       TranslateMessage (@msg)
       DispatchMessage (@msg)
  END

  /* Not in the book.  Add it if you prefer */
  //  UnregisterClass ( szAppName, hInstance )
RETURN msg.wParam

FUNCTION WndProc (hwnd AS WORD, message AS WORD, wParam AS WORD, ;
                  lParam AS LONG) AS LONG  _WINCALL

     LOCAL hdc  AS WORD
     LOCAL ps   IS _WINPAINTSTRUCT
     LOCAL rect IS _WINRECT

     DO CASE
          CASE message == WM_PAINT
            hdc := BeginPaint (hwnd, @ps)

            GetClientRect (hwnd, @rect)

            DrawText (hdc, "Hello, Windows!", -1, @rect, ;
                      _OR(_OR(DT_SINGLELINE, DT_CENTER), DT_VCENTER))

            EndPaint (hwnd, @ps)
            RETURN 0L

          CASE message == WM_DESTROY
            PostQuitMessage (0)
            RETURN 0L

          ENDCASE

RETURN DefWindowProc (hwnd, message, wParam, lParam)

GUI class version:

TEXTBLOCK HELLOWIN.C  --  (c) Charles Petzold, 1992

/*--------------------------------------------------------
   HELLOWIN.C -- Displays "Hello, Windows" in client area
                 (c) Charles Petzold, 1992

   HELLOWIN.PRG - CA Visual Objects adaptation
                        John Forsberg, 1994

   HELLOEAS.AEF - CA Visual Objects adaptation ( Easy one )
                        Jari Sevon, 1995
  --------------------------------------------------------*/


METHOD Start() CLASS App
     LOCAL oWindow AS Window
      oWindow := Hello{}
      oWindow:Show()
RETURN( SELF:Exec() )

CLASS HELLO INHERIT TOPAPPWINDOW

METHOD INIT(oParent) CLASS HELLO
     SUPER:INIT(oParent)
     SELF:Caption := "The Easy Hello Program"
RETURN SELF

METHOD EXPOSE(oExpEvent) CLASS HELLO

     LOCAL oPoint AS POINT
     LOCAL oBoundBox AS BoundingBox
     LOCAL oDim AS Dimension
     LOCAL nxWinWidth   AS INT
     LOCAL nyWinHeight AS INT
     LOCAL nx AS INT
     LOCAL ny AS INT
     LOCAL cDispString := "Hello Windows !"
     LOCAL nxTextWidth  AS INT
     LOCAL nyTextHeight AS INT

     SUPER:EXPOSE(oExpEvent)

     oBoundBox  := SELF:CanvasArea
     nxWinWidth     := oBoundBox:Width
     nyWinHeight   := oBoundBox:Height

     oDim := SELF:SizeText(cDispString)
     nyTextHeight := oDim:Height
     nxTextWidth  := oDim:Width

     nx := ( ( nxWinWidth - nxTextWidth ) / 2 )
     ny := ( ( nyWinHeight - nyTextHeight ) / 2 )

     oPoint := POINT{ nx  , ny  }

     SELF:TextPrint( cDispString , oPoint )

RETURN 

submitted by: Jari.Sevon@code.pp.fi (Jari Sevón)