Update of /cvsroot/win32forth/win32forth/demos
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6495/demos
Modified Files:
WINHELLO.F
Log Message:
Changed WinHello to show some better WM_PAINT handling.
Index: WINHELLO.F
===================================================================
RCS file: /cvsroot/win32forth/win32forth/demos/WINHELLO.F,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** WINHELLO.F 21 Dec 2004 00:18:53 -0000 1.1
--- WINHELLO.F 8 Jan 2006 09:43:13 -0000 1.2
***************
*** 18,44 ****
;M
! :M WindowTitle: ( -- Zstring ) \ window caption
z" Hello World"
;M
:M On_Paint: { \ temp$ -- } \ all window refreshing is done by On_Paint:
! \ get the Client area of the window and fill it black
! AddrOf: wRect GetClientRect: self
! black AddrOf: wRect FillRect: dc
! \ set the backgroundcolor for text to black
! black SetBkColor: dc
! \ and set the Textcolor to green
! green SetTextColor: dc
! MAXSTRING LocalAlloc: temp$
! s" Repainted " temp$ place
! counter (.) temp$ +place
! s" times" temp$ +place
! 20 ( x ) 50 ( y ) temp$ count TextOut: dc
! 20 ( x ) 20 ( y ) s" Hello World" TextOut: dc
;M
:M On_Init: ( -- ) \ things to do at the start of window creation
On_Init: super \ do anything superclass needs
--- 18,71 ----
;M
! :M WindowTitle: ( -- Zstring ) \ window caption
z" Hello World"
;M
+ :M On_EraseBackground: ( hwnd msg wparam lparam -- res )
+ \ let the On_Paint: Method redraw the background
+ 4drop 0 ;M
+
:M On_Paint: { \ temp$ -- } \ all window refreshing is done by On_Paint:
! \ draw background only if needed
! ps_fErase
! if
! \ cr ." erase background"
! ps_left ps_top ps_right ps_bottom
! black FillArea: dc
! then
! \ check if our drawing area is visible or not
! 0 0 170 90 SetRect: wRect
! AddrOf: wRect GetHandle: dc call RectVisible
! if
! \ cr ." visible"
! \ let's draw...
! black SetBkColor: dc
! green SetTextColor: dc
! MAXSTRING LocalAlloc: temp$
! s" Repainted " temp$ place
! counter (.) temp$ +place
! s" times" temp$ +place
! 20 ( x ) 50 ( y ) temp$ count TextOut: dc
! 20 ( x ) 20 ( y ) s" Hello World" TextOut: dc
! \ else cr ." invisible"
! then ;M
!
! :M Paint: ( -- )
! \ Note: The Paint: method of the window class invalidates the
! \ complete client rectangle. Since we only draw in a smal part
! \ of the window only the the part of the window in whitch we
! \ are going to draw is marked as invalid.
! 0 0 170 90 SetRect: wRect
! 1 AddrOf: wRect hWnd Call InvalidateRect ?win-error
;M
+ :M WM_TIMER ( h m w l -- res ) \ handle the WM_TIMER events
+ 1 +to counter \ bump the counter
+ Paint: self \ refresh the window
+ 0 ;M
+
:M On_Init: ( -- ) \ things to do at the start of window creation
On_Init: super \ do anything superclass needs
***************
*** 47,55 ****
;M
- :M WM_TIMER ( h m w l -- res ) \ handle the WM_TIMER events
- 1 +to counter \ bump the counter
- Paint: self \ refresh the window
- 0 ;M
-
:M On_Done: ( -- ) \ things to do before program termination
1 hWnd Call KillTimer drop \ destroy the timer, we are done
--- 74,77 ----
***************
*** 79,80 ****
--- 101,103 ----
[THEN]
+ demo
|