1. Virtual Window code

--Alt-Boundary-24756.22969406
Content-description: Mail message body

Ok, I have about given up on the graphics codeing design built-into
Win32lib so I have another Question.

Why do my scrollbars automatically stop, Im sure its not that Im over the 65k
limit...

Here's updated code that actually (sorta) works...

-- Author: Euman 2003

without warning

include Win32Lib.ew

constant
xPatBlt = registerw32Function(gdi32, "PatBlt", {C_POINTER, C_INT, C_INT, C_INT, 
C_INT, C_LONG}, C_LONG),
PATCOPY =  #F00021

object junk

constant
MainWin = createEx( Window, "Virtual Window Demo", NULL, 25, 25, 640, 480, 0, 
0),
hWnd = getHandle( MainWin )

sequence InitExtent

atom hdc, memdc, hbit, hbrush, ps
   hdc = 0
   memdc = 0

integer vxScreen, vyScreen, x1, y1, x2, y2

   vxScreen = 1280
   vyScreen = 960
   x1 = 0
   y1 = 0
   x2 = 640
   y2 = 480
   
-- onOpen_MainWin
procedure onCreate_MainWin( integer self, integer event, sequence parms )
  
  hdc = w32Func( xGetDC, {hWnd} )
  memdc = w32Func( xCreateCompatibleDC, {hdc} )
  hbit = w32Func( xCreateCompatibleBitmap, { hdc, vxScreen, vyScreen } )
  junk = w32Func( xSelectObject, {memdc, hbit} ) 
  hbrush = w32Func( xGetStockObject, {WHITE_BRUSH}) 
  junk = w32Func( xSelectObject, {memdc, hbrush} ) 
        
if not w32Func( xPatBlt, {memdc, 0, 0, vxScreen, vyScreen, PATCOPY}) then end
  if

  setScrollRange ( {MainWin, SB_HORZ}, 1, vxScreen )
  setScrollRange ( {MainWin, SB_VERT}, 1, vyScreen )

  setPenColor( MainWin, Green )
  junk = w32Func(xRectangle, {memdc, 10, 10, 600, 415})
  junk = w32Func( xReleaseDC, {hWnd, hdc} )
  junk = w32Func( xInvalidateRect, {hWnd, NULL, 0} )
   
end procedure
setHandler(MainWin, w32HActivate, routine_id("onCreate_MainWin"))

integer pos, orgX, orgY
   orgX = 0 
   orgY = 0

procedure on_scroll( integer self, integer event, sequence parms )

   pos = getHScrollPos( MainWin )
   x1 = pos x2 += pos orgX = pos

   pos = getVScrollPos( MainWin )
   y1 = pos y2 += pos orgY = pos

  junk = w32Func( xInvalidateRect, {hWnd, NULL, 0} )

end procedure
setHandler(MainWin, w32HScroll,  routine_id ("on_scroll"))


ps = acquire_mem(0, SIZEOF_PAINTSTRUCT)

-- onPaint_MainWin
procedure onPaint_MainWin( integer self, integer event, sequence parms )

   hdc = getDC( self )        
   if not w32Func( xBitBlt, {hdc, x1, y1, x2, y2, memdc, x1+orgX, y1+orgY, 
SRCCOPY} ) then end if     
    
end procedure
setHandler(MainWin, w32HPaint, routine_id("onPaint_MainWin"))


-- onClose_MainWin
procedure onClose_MainWin( integer self, integer event, sequence parms )
  
  junk = w32Func( xReleaseDC, {0, hdc} ) 

end procedure
setHandler(MainWin, w32HClose, routine_id("onClose_MainWin"))

WinMain( MainWin, Normal )


--Alt-Boundary-24756.22969406
Content-type: text/html; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body

<?xml  version="1.0" ?><html>
<head>
<title></title>
</head>
<body>
<div align="left"><font face="Arial"><span style="font-size:10pt">Ok, I have
about given up on the graphics codeing design built-into</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Win32lib so I
have another Question.</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Why do my
scrollbars automatically stop, Im sure its not that Im over the 65k
limit...</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Here's updated
code that actually (sorta) works...</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">-- Author:
Euman 2003</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">without
warning</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">include
Win32Lib.ew</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">constant</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">xPatBlt =
registerw32Function(gdi32, &quot;PatBlt&quot;, {C_POINTER, C_INT, C_INT, C_INT,
C_INT, C_LONG}, C_LONG),</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">PATCOPY
=  #F00021</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">object
junk</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">constant</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">MainWin =
createEx( Window, &quot;Virtual Window Demo&quot;, NULL, 25, 25, 640, 480, 0,
0),</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">hWnd =
getHandle( MainWin )</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">sequence
InitExtent</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">atom hdc,
memdc, hbit, hbrush, ps</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
hdc = 0</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
memdc = 0</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">integer
vxScreen, vyScreen, x1, y1, x2, y2</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
vxScreen = 1280</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
vyScreen = 960</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
x1 = 0</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
y1 = 0</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
x2 = 640</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
y2 = 480</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">--
onOpen_MainWin</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">procedure
onCreate_MainWin( integer self, integer event, sequence parms
)</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> 
</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  hdc =
w32Func( xGetDC, {hWnd} )</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  memdc =
w32Func( xCreateCompatibleDC, {hdc} )</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  hbit =
w32Func( xCreateCompatibleBitmap, { hdc, vxScreen, vyScreen }
)</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  junk =
w32Func( xSelectObject, {memdc, hbit} ) </span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  hbrush
= w32Func( xGetStockObject, {WHITE_BRUSH}) </span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  junk =
w32Func( xSelectObject, {memdc, hbrush} ) </span></font></div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">       
</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  if not
w32Func( xPatBlt, {memdc, 0, 0, vxScreen, vyScreen, PATCOPY}) then end if
</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> 
setScrollRange ( {MainWin, SB_HORZ}, 1, vxScreen )</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> 
setScrollRange ( {MainWin, SB_VERT}, 1, vyScreen )</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> 
setPenColor( MainWin, Green )</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  junk =
w32Func(xRectangle, {memdc, 10, 10, 600, 415})</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  junk =
w32Func( xReleaseDC, {hWnd, hdc} )</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  junk =
w32Func( xInvalidateRect, {hWnd, NULL, 0} )</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">end
procedure</span></font></div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">setHandler(MainWin, w32HActivate,
routine_id(&quot;onCreate_MainWin&quot;))</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">integer pos,
orgX, orgY</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
orgX = 0 </span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
orgY = 0</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">procedure
on_scroll( integer self, integer event, sequence parms )</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
pos = getHScrollPos( MainWin )</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
x1 = pos x2 += pos orgX = pos</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
pos = getVScrollPos( MainWin )</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
y1 = pos y2 += pos orgY = pos</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  junk =
w32Func( xInvalidateRect, {hWnd, NULL, 0} )</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">end
procedure</span></font></div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">setHandler(MainWin, w32HScroll,  routine_id
(&quot;on_scroll&quot;))</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">ps =
acquire_mem(0, SIZEOF_PAINTSTRUCT)</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">--
onPaint_MainWin</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">procedure
onPaint_MainWin( integer self, integer event, sequence parms
)</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
hdc = getDC( self )       
</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
if not w32Func( xBitBlt, {hdc, x1, y1, x2, y2, memdc, x1+orgX, y1+orgY,
SRCCOPY} ) then end if     </span></font></div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">    </span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">end
procedure</span></font></div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">setHandler(MainWin, w32HPaint,
routine_id(&quot;onPaint_MainWin&quot;))</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">--
onClose_MainWin</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">procedure
onClose_MainWin( integer self, integer event, sequence parms
)</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> 
</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  junk =
w32Func( xReleaseDC, {0, hdc} ) </span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">end
procedure</span></font></div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">setHandler(MainWin, w32HClose,
routine_id(&quot;onClose_MainWin&quot;))</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">WinMain(
MainWin, Normal )</span></font></div>
<div align="left"></div>

--Alt-Boundary-24756.22969406--

new topic     » topic index » view message » categorize

2. Re: Virtual Window code

On Mon, 18 Aug 2003 16:21:33 -0400, euman at bellsouth.net wrote:

>Why do my scrollbars automatically stop, Im sure its not that Im over =
the 65k limit...
As you know, I dunno. Try replacing:
  junk =3D w32Func( xInvalidateRect, {hWnd, NULL, 0} )
with:
setText(MainWin,sprint({x1,x2,orgX,y1,y2,orgY}))
repaintWindow(MainWin)

a) it appears x2,y2 are not being set correct?
b) the very different display might offer a clue.

Pete

new topic     » goto parent     » topic index » view message » categorize

3. Re: Virtual Window code

----- Original Message ----- 
From: <jxliv7 at hotmail.com>
To: "EUforum" <EUforum at topica.com>
Subject: RE: Virtual Window code


> 
> 
> > Derek Parnell wrote:
> > 
> > We have a device here in Australia that is known as an "American 
> > Screwdriver"; I believe that it is known in other places as a 
> > hammer.
> > 
> 
> Watch it, Derek, we Americans are quite efficient with crescent
> hammers, too. But since you brought up Australia, I notice that
> a lot of your women (actresses, singers) are leaving lately for
> parts elsewhere. Could it be they've grown tired of shrimps...
> er, on the barbie?

Nah, they're the rejects. You should see the ones that stay!
--
Derek

new topic     » goto parent     » topic index » view message » categorize

4. Re: Virtual Window code

----- Original Message ----- 
From: <jxliv7 at hotmail.com>
To: "EUforum" <EUforum at topica.com>
Subject: RE: Virtual Window code


[snip]

<caveat>These are my opinions and therefore may not be valid.</caveat>
 
> Derek, you have brought up a serious point that i do NOT understand 
> about Windows programming in Euphoria. that is, what is the difference 
> between the API calls, the win32lib, and even some other library(s) 
> (like BACH) i find here?

At the lowest (practical) level, a program must eventually use direct calls the
the Windows API routines. These routines are created by Microsoft (and maybe a
few others) and reside in a set of .DLL files. Euphoria allows us to use these
API calls directly. The API calls are fairly low-level meaning that each routine
does a very small specific function and you need to use many, and in the right
sequence, to achieve even the simplest of real-world tasks. For example, the
simple "Hello World" program coded in C can run to over a hundred lines. To use
API calls, you need to do some serious research and then still plenty of trial
and error.

Win32lib's aim is to make creating and maintaining Windows apps easier that
using straight API calls. It does this by doing the housekeeping and other
'boring' stuff. Also it tries to standardize the programming interface. Once you
start using the API, it soon becomes apparent that different groups wrote it, and
they didn't always talk to each other blink Win32lib uses direct API calls
internally, of course. We try to hide their usage as much as possible, though.
There are thousands of API routines and win32lib uses maybe 10%. Over time, we
will add extra functionality as requested, but it will never encompass the entire
API.

In the RDS archives you will find a few other ways of making Windows coding more
accessible to the average coder. Win32lib is just one way of doing it.
 
> i like Judith's IDE, i was writing my code with it before i switched 
> over to MEdit, but i am still stuck in the DOS style of coding. what i 
> write doesn't interface with anything, it just does what i want it to 
> do. i would like a GUI so i can handle input and output within a Windows 
> environment (no Linux yet, although i run a box).

There is a huge difference in approach between programming for windowing systems
and for non-windowing systems. This subject can have a tutorial all to itself!

The primary difference is ...
Non-windowing: The program (author) controls the work flow, and the user must do
accomodate it.
Windowing: The user controls the work flow, and the program (author) must do
accomodate it.

This shows up in the style of laying out the code and the way that control flows
from one section of code to another.

In windowing systems, the code tends to consist of short, very one-purpose-only
routines that don't tend to call each other very much. They are invoked as a
response to the user's action and when a routine is completed, the program will
quietly wait for the next user action or event.

A typical windows program will have a message loop in it. That will generally
look something like...

   while StillRunning do
        GetNextEventMessage()
        If there is a handler routine defined for this event then
              run the routine.
        end if
   end while

This is what win32lib hides for you.

> what is the easiest, fastest, and most efficient way to make something 
> that can do Windows? 

Euphoria with Win32lib, of course blink 

But seriously folks, I still think that Visual Basic can satisify most Windows
requirements. It has its limits just like any other system, but you'll be
surprised how productive you can be.

>what are and why are there differences within the 
> Euphoria community programming Windows? 

Because Euphoria is a versatile language, and there are more that one way to
skin a Window. Diversity is not a bad thing if better things can evolve from it.

> is it worth dropping Euphoria 
> and learning another language as a way to make Windows applications? 

I would not recommend you dropping Euphoria, but I would also encourage you to
look at the many alternatives to it, for Windows programming. Visual Basic (v6 or
.NET) is a fairly painless way. You might consider Delphi too. These are fairly
mainstream. Getting away from the madding crowd a bit, you could look at Blitz
Basic or even AMOS (though I think that's changed it name). If you know Intel
Assembler then Masm32 is a great development system for Assember Windows coding.

> Don't get me wrong, i've been playing with Euphoria for about 8 years, 
> but i think it's time i moved up a notch. i read the EUforum daily 
> summaries from topica, but this Windows question has kept me lurking 
> when i should be coding. i cannot figure it out.

I only got into Windows coding seriously when I took a look inside Win32lib.
Before that I'd used VB a bit but that hides most of the nasty stuff like
win32lib does. Check out the better computer bookstores for tomes on Windows
Programming - but beware, they can be expensive.
 
-- 
Derek

new topic     » goto parent     » topic index » view message » categorize

5. Re: Virtual Window code

On Tue, 19 Aug 2003 06:00:08 +0000, Derek Parnell
<ddparnell at bigpond.com> wrote:

> Here is a reworking of your example for all the API code removed=20
<snip>

Derek,
Thanks for the updated code (that you did for Wayne), however it
exhibits some of the same minor flaws I'd like to get rid of in my
program. I think I've fixed it, now I can see the trees from the
forest, your comments please.

=46irst, this is(was) the problem:
Put with trace trace(1) at the top of the program and ensure
win32lib.ew is 100% without trace.
Run the program and reposition the trace window bottom right.
Minimise all other apps so the window is definitely not hidden.
=46irst it draws a blank window, and invokes on_resize()
setScrollRange causes another resize event, so you get 3 in total, and
the blank window is drawn (with scrollbars) another two times.
1st bitblt dumps garbage to the screen.
2nd and 3rd ditto
Window is redrawn blank
w32HPaint event re-dumps garbage to the screen
=46inally the w32HActivate gets it together and it is all fine.

The fix:
1) do this immediately after creating the window:
	setScrollRange ( {MainWin, SB_HORZ}, 1, (vxScreen - vxMainWin))
	setScrollRange ( {MainWin, SB_VERT}, 1, (vyScreen - vyMainWin))
and they can be removed from the start of onCreate_MainWin().
This means they occur before the resize event handler is associated
with the window, so now it only gets called once.
2) put isVisible(MainWin) test around the onPaint_MainWin call in
onCreate_MainWin()
3) Change onCreate_MainWin from w32HActivate to w32HOpen
This means it is called before paint or resize.
4) finally, I think the onPaint_MainWin call in on_resize is spurious,
so I removed it.

Agree? Disagree? How many bugs have I introduced?

Cheers,
Pete

new topic     » goto parent     » topic index » view message » categorize

6. Re: Virtual Window code

----- Original Message -----=20
From: "Pete Lomax" <petelomax at blueyonder.co.uk>
To: "EUforum" <EUforum at topica.com>
Subject: Re: Virtual Window code


>=20
>=20
> On Tue, 19 Aug 2003 06:00:08 +0000, Derek Parnell
> <ddparnell at bigpond.com> wrote:
>=20
> > Here is a reworking of your example for all the API code removed=20
> <snip>
>=20
> Derek,
> Thanks for the updated code (that you did for Wayne), however it
> exhibits some of the same minor flaws I'd like to get rid of in my
> program. I think I've fixed it, now I can see the trees from the
> forest, your comments please.
>=20
> First, this is(was) the problem:
> Put with trace trace(1) at the top of the program and ensure
> win32lib.ew is 100% without trace.
> Run the program and reposition the trace window bottom right.
> Minimise all other apps so the window is definitely not hidden.
> First it draws a blank window, and invokes on_resize()
> setScrollRange causes another resize event, so you get 3 in total, and
> the blank window is drawn (with scrollbars) another two times.
> 1st bitblt dumps garbage to the screen.
> 2nd and 3rd ditto
> Window is redrawn blank
> w32HPaint event re-dumps garbage to the screen
> Finally the w32HActivate gets it together and it is all fine.
>=20
> The fix:
> 1) do this immediately after creating the window:
> setScrollRange ( {MainWin, SB_HORZ}, 1, (vxScreen - vxMainWin))
> setScrollRange ( {MainWin, SB_VERT}, 1, (vyScreen - vyMainWin))
> and they can be removed from the start of onCreate_MainWin().
> This means they occur before the resize event handler is associated
> with the window, so now it only gets called once.

Instead of this 'fix', remove these two lines altogether and add the =
WS_SCROLLBARS flag to the createEx(Window...).

> 2) put isVisible(MainWin) test around the onPaint_MainWin call in
> onCreate_MainWin()

This 'fix' is not needed at all. The paint is not called if the window =
is minimized or hidden.

> 3) Change onCreate_MainWin from w32HActivate to w32HOpen
> This means it is called before paint or resize.

Remove this setHandler as it is not needed. I've renamed this routine =
InitVirtualScreen and call it just after creating the pixmap.

> 4) finally, I think the onPaint_MainWin call in on_resize is spurious,
> so I removed it.

Agreed. It is not needed in the onCreate_MainWin() either.


Here is my version....

-----------------------
without warning
include Win32Lib.ew

integer vxScreen
integer vyScreen=20
integer fromX
integer fromY
integer vxMainWin
integer vyMainWin
integer MainWin
integer VirtScrn=20
       =20
-------------------------------
procedure InitVirtualScreen()
-------------------------------

    -- Clear the pixmap to all white                        =20
    setPenColor(VirtScrn, BrightWhite)
    drawRectangle(VirtScrn, True, 0, 0, vxScreen, vyScreen)
   =20
    -- Draw a black rectangle in the pixmap
    setPenColor(VirtScrn, Black)
    drawRectangle(VirtScrn, False, 10, 10, 600, 415)
        =20
    -- Draw a red rectangle in the pixmap
    setPenColor(VirtScrn, BrightRed)
    drawRectangle(VirtScrn, False, 320, 240, vxScreen-75, vyScreen-75)
                        =20
    -- Draw a green rectangle in the pixmap
    setPenColor(VirtScrn, Green)
    drawRectangle(VirtScrn, False, 5, 5, vxScreen-5, vyScreen-5)
                           =20
end procedure

-------------------------------
procedure onPaint_MainWin( integer self, integer event, sequence parms )
-------------------------------
            =20
   -- Copy the pixmap to the window.
   bitBlt(MainWin,  0, 0,           -- Dest
          VirtScrn, fromX, fromY,   -- Source=20
          vxMainWin, vyMainWin,     -- width, height
          SRCCOPY )                 -- style
   =20
end procedure
  =20
-------------------------------
procedure onResize_MainWin( integer self, integer event, sequence parms =
)
-------------------------------
    -- Get the new size of the window
    vxMainWin =3D parms[2]
    vyMainWin =3D parms[3]                    =20
   =20
    -- Shift viewport if new area is exposed.
    if fromX + vxMainWin > vxScreen then
        fromX =3D vxScreen - vxMainWin
    end if
    if fromY + vyMainWin > vyScreen then
        fromY =3D vyScreen - vyMainWin
    end if

    -- Adjust scrollbars   =20
    setScrollRange ( {MainWin, SB_HORZ}, 1, (vxScreen - vxMainWin))
    setScrollRange ( {MainWin, SB_VERT}, 1, (vyScreen - vyMainWin))

end procedure

-------------------------------
procedure onScroll_MainWin( integer self, integer event, sequence parms =
)
-------------------------------
    integer pos           =20
   =20
    pos =3D parms[1] - 1
    if parms[3] =3D SB_HORZ then
        if pos + vxMainWin < vxScreen then
            fromX =3D pos
        else
            fromX =3D vxScreen - vxMainWin
        end if
    elsif parms[3] =3D SB_VERT then
        if pos + vyMainWin < vyScreen then
            fromY =3D pos
        else
            fromY =3D vyScreen - vyMainWin
        end if
    end if
                           =20
    -- Only bother redrawing if still scrolling.
    if parms[2] !=3D SB_ENDSCROLL then
        onPaint_MainWin(self, w32HPaint, {})
    end if

end procedure

-------------------------------
procedure RunApp()
-------------------------------

    vxScreen =3D 1280
    vyScreen =3D 960
    fromX =3D 0
    fromY =3D 0
    vxMainWin =3D 640
    vyMainWin =3D 480

    MainWin =3D createEx( Window, "Virtual Window Demo", NULL, 25, 25,=20
                                vxMainWin, vyMainWin, WS_SCROLLBARS, 0)
    VirtScrn =3D createEx( Pixmap, "", 0, 0, 0, vxScreen, vyScreen, 0, =
0)

    InitVirtualScreen()
       =20
    setHandler(MainWin, w32HPaint,  routine_id("onPaint_MainWin"))
    setHandler(MainWin, w32HResize, routine_id("onResize_MainWin"))
    setHandler(MainWin, w32HScroll, routine_id("onScroll_MainWin"))

    WinMain( MainWin, Normal )=20
end procedure


-------------------------------
-------------------------------
-------------------------------

RunApp()

--=20
Derek

new topic     » goto parent     » topic index » view message » categorize

7. Re: Virtual Window code

On Tue, Aug 19, 2003 at 12:30:02PM +0000, jxliv7 at hotmail.com wrote:
> i must admit you have reminded me just how zealously i would love to 
> abandon Microsoft Windows completely and move to Linux, but with only a 
> 10% user base worldwide, there's a lack of serious apps.
> 
> thanks,
> 
> 
> --
> jon
> 

Lets not start this thread again. (lack of serious apps for linux). Please.
If you want, I can prove to you the true amount of apps for linux and BSD
off the forum (in private email).

jbrown

-- 
 /"\  ASCII ribbon              | http://www.geocities.com/jbrown1050/
 \ /  campain against           | Linux User:190064
  X   HTML in e-mail and        | Linux Machine:84163
 /*\  news, and unneeded MIME   | http://verify.stanford.edu/evote.html

new topic     » goto parent     » topic index » view message » categorize

8. Re: Virtual Window code

--Alt-Boundary-20214.25073140
Content-description: Mail message body

> Derek and all, 

Here's my rendition of the demo I was trying to accomplish in Win32lib. 
This demo uses a powerfull double buffering technique that will run circles 
(speed wize) around any Win32lib app (unless you would supply us with a  
double buffering demo using win32lib) 
   [I think I wrote one along time ago when David Cuny had the library upto 
    version 0.15 or so.]

The user I am trying to help would prefer this be written using win32lib 
but Im just not great with learning a new language (win32lib). I have become 
so used to Win32 API  that I have a hard time understanding wrappers. 

Enjoy! 

Topica wouldn't allow me to upload the file in the email because they say its
too large when in fact, the entire program is only 22k

Download here to see the API version of a Virtual Window Demo

ftp://h2osoft.homeip.net/virtwin.exw 

The good news is there are a great many uses for this type of system.
One that comes to mind is a CAD program (only a CAD app would be
a couple hundred thousand lines more work...

Euman.

--Alt-Boundary-20214.25073140
Content-type: text/html; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body

<?xml  version="1.0" ?><html>
<head>
<title></title>
</head>
<body>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; Derek and all, </span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Here's my
rendition of the demo I was trying to accomplish in Win32lib.
</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">This demo uses
a powerfull double buffering technique that will run circles </span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">(speed wize)
around any Win32lib app (unless you would supply us with a 
</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">double
buffering demo using win32lib) </span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">  
[I think I wrote one along time ago when David Cuny had the library upto
</span></font></div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">    version 0.15 or
so.]</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">The user I am
trying to help would prefer this be written using win32lib </span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">but Im just
not great with learning a new language (win32lib). I have become
</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">so used to
Win32 API  that I have a hard time understanding wrappers.
</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Enjoy!
</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Topica
wouldn't allow me to upload the file in the email because they say
its</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">too large when
in fact, the entire program is only 22k</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Download here
to see the API version of a Virtual Window Demo</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial" color="#008000"><span
style="font-size:10pt"><u>ftp://h2osoft.homeip.net/virtwin.exw</u></span></font><font
face="Arial"><span style="font-size:10pt"> </span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">The good news
is there are a great many uses for this type of system.</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">One that comes
to mind is a CAD program (only a CAD app would be</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">a couple
hundred thousand lines more work...</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">Euman.</span></font></div>

--Alt-Boundary-20214.25073140--

new topic     » goto parent     » topic index » view message » categorize

9. Re: Virtual Window code

On Tue, 19 Aug 2003 19:16:58 -0400 (08/20/03 09:16:58)
, <euman at bellsouth.net> wrote:

>
>> Derek and all,
>
> Here's my rendition of the demo I was trying to accomplish in Win32lib. 
> This demo uses a powerfull double buffering technique that will run 
> circles (speed wize) around any Win32lib app (unless you would supply us 
> with a  double buffering demo using win32lib) [I think I wrote one along 
> time ago when David Cuny had the library upto version 0.15 or so.]

Hmmm...its debatable whether or not to call this technique 'double 
buffering' as there is only one buffer involved. And I'm not sure if you 
mean that amongst all the different types of double-buffering technique, 
this one is a powerful one,  or that the technique of double-buffering is a 
technique which is in itself powerful.

Double-buffering is a very old technique that draws its attraction from the 
idea that drawing pixels onto a non-visible area is very much faster than 
drawing them into a visible area. The idea is simply that you draw in to 
buffer 'A' while the user is looking at the contents of buffer 'B', then 
when your drawing is complete, you quickly switch buffers so that now the 
user is looking at buffer 'A' while draw the next image/frame in buffer 
'B', and the cycle repeats.

Some earlier computers took advantage of this to allow lightening fast 
animations (C64 and Amiga come to mind). Changing the viewport was simply 
updating a single address pointer to the newly updated buffer.

In this example of Euman's we have a single drawing buffer, which is 
quickly copied to the user's current viewing buffer. Euman draws into the 
buffer and when completed, copies the buffer to the user's current viewing 
buffer, then the program updates the drawing in the buffer and the program 
continues this cycle. To be fair, Euman is not actually animating this 
graphic, just scrolling around it, but the principle is the same.

The previous example code that I sent was a win32lib program that did the 
same as Euman's code and it was only 3.5KB in size and ran almost as fast 
(less than 1% difference in speed).

However, I'll update it tonight to demostrate animated displays with 
sprites and maybe real double buffering if I get time.

> The user I am trying to help would prefer this be written using win32lib 
> but Im just not great with learning a new language (win32lib). I have 
> become so used to Win32 API  that I have a hard time understanding 
> wrappers.

It seems to me that you have demostrated the hard way of doing it, but if 
that's what you are comfortable with, then go for it!

> Enjoy!

BTW, it GPF'ed on my Win2000 machine - but that might have been my fault.

>
> Topica wouldn't allow me to upload the file in the email because they say 
> its
> too large when in fact, the entire program is only 22k
>
> Download here to see the API version of a Virtual Window Demo
>
> ftp://h2osoft.homeip.net/virtwin.exw
>
> The good news is there are a great many uses for this type of system.
> One that comes to mind is a CAD program (only a CAD app would be
> a couple hundred thousand lines more work...
>

** Animation.
** Games.

-- 

cheers,
Derek Parnell

new topic     » goto parent     » topic index » view message » categorize

10. Re: Virtual Window code

> > The speed between Euman's API app and the Win32Lib app looks no
different to me on my
> > system.
> >
>
> I wasn't saying this particular App was faster (to the eye its no faster
anyway)
> Neither of the apps do anything but draw a few rectangles for goodness
sake..
> Im saying that using Double buffering to Blit images or objects to a
window
> is much faster than creating a pixmap in Win32lib.
>
> Lets get this straight, Win32lib is many many times slower than my
prefered method
> of programming, (like Derek says) the hard way.

No doubt, but when will that really matter? It will obviously matter when
somebody wants to program QuakeEU... but when else?

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu