programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

Evaluate in a callback

From: Charles Melice <mail_at_forthcad.com>
Date: Mon, 15 Jan 2001 09:46:20 +0100

In the sample below, I try to EVALUATE a sequence or
simply FIND a word inside a callback.

In the cases A and B, I get an access violation.

Is somebody can get me some help to do that ?

Thanks,
Charles Melice

\ --------------------------------------
\ Test EVALUATE in callback
\ --------------------------------------

FUNCTION: Ellipse ( hdc left top right bottom -- flag )

10 VALUE X-CENTER

: OnKeyDown ( char -- flag )
    CASE
        [CHAR] A OF
            S" 10 +TO X-CENTER" EVALUATE
        ENDOF

        [CHAR] B OF
            C" DUP" FIND 2DROP
        ENDOF

        [CHAR] X OF
            10 +TO X-CENTER
        ENDOF
        \
        DROP FALSE EXIT
    ENDCASE
    TRUE ;

:NONAME ( -- res )
    MSG CASE
        WM_PAINT OF
            HWND PAD BeginPaint
            ( hdc) X-CENTER 10 110 110 Ellipse DROP
            HWND PAD EndPaint DROP
        ENDOF

        WM_CREATE OF
            HWND SetFocus DROP
        ENDOF

        WM_DESTROY OF \ ** necessary, else task NOT removed by Windows
            \ 0 PostQuitMessage DROP
        ENDOF

        WM_KEYDOWN OF
            WPARAM OnKeyDown IF
                HWND 0 TRUE InvalidateRect DROP
            THEN
        ENDOF
        \ --default--
        DROP
        HWND MSG WPARAM LPARAM DefWindowProc
        EXIT
    ENDCASE
    0 EXIT ; 4 CB: CircleWindowProc

: RegCircleClass ( -- hclass )
    Z" CIRCLE-CLASS" CircleWindowProc DefaultClass ;

: CIRCLE ( -- )
    0 \ extended window style
    RegCircleClass DROP Z" CIRCLE-CLASS" \ address of registered class name
    Z" Just a circle" \ address of window name
    WS_OVERLAPPEDWINDOW WS_VISIBLE OR \ window style
    CW_USEDEFAULT DUP 200 150 \ window position and size
    0 \ handle of parent or owner window
    0 \ handle of menu or child-window identifier
    HINST \ handle of application instance
    0 \ address of window-creation data
    CreateWindowEx DROP ;

\ EOF

Received on Mon Jan 15 2001 - 01:57:46 PST

This archive was generated by hypermail 2.2.0 : Sat Nov 22 2008 - 03:04:27 PST