1. RE: Virtual Window code

euman at bellsouth.net wrote:
> 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...
> 
Thank you for the encouraging words about the library. Comments as clear 
and helpful as yours have proven to consolidate organizations that are 
customer-focused, caring, innovative, and open; such as Microsoft.

You are correct, its nothing to do with the 65k (sic) limit. The reason 
is that the code was wrong about calculating the source and destination 
points and the width and heights to copy.

Wayne, I've said this before and its worth repeating... If one is going 
to most of the app using direct API calls, the win32lib is not the right 
tool. Here is a reworking of your example for all the API code removed 
(because its not needed). Your inclusion of the API stuff only made it 
much more complicated that it needed to be. 

I've also added code to handle window resizing and ensuring that we 
don't try to copy non-existant parts of the bitmap.

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.

-----
without warning

include Win32Lib.ew

integer vxScreen, vyScreen, 
        fromX, fromY, 
        vxMainWin, vyMainWin,
        vxMax, vyMax

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

constant 
    MainWin = createEx( Window, "Virtual Window Demo", NULL, 25, 25, 
vxMainWin, vyMainWin, 0, 0),
    VirtScrn = createEx( Pixmap, "", 0, 0, 0, vxScreen, vyScreen, 0, 0)
                                             
procedure onPaint_MainWin( integer self, integer event, sequence parms )
             
   -- Copy the pixmap to the window.
   bitBlt(MainWin,  0, 0,           -- Dest
          VirtScrn, fromX, fromY,   -- Source 
          vxMainWin, vyMainWin,     -- width, height
          SRCCOPY )                 -- style
    
end procedure
setHandler(MainWin, w32HPaint, routine_id("onPaint_MainWin"))

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

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

    -- Clear the pixmap to all white                         
    setPenColor(VirtScrn, BrightWhite)
    drawRectangle(VirtScrn, True, 0, 0, vxScreen, vyScreen)
    
    -- Draw a black rectangle in the pixmap
    setPenColor(VirtScrn, Black)
    drawRectangle(VirtScrn, False, 10, 10, 600, 415)
         
    -- Draw a red rectangle in the pixmap
    setPenColor(VirtScrn, BrightRed)
    drawRectangle(VirtScrn, False, 320, 240, vxScreen-75, vyScreen-75)
                         
    -- Draw a green rectangle in the pixmap
    setPenColor(VirtScrn, Green)
    drawRectangle(VirtScrn, False, 5, 5, vxScreen-5, vyScreen-5)
                         
    -- Draw the initial window image.
    onPaint_MainWin(self, w32HPaint, {})
   
end procedure
setHandler(MainWin, w32HActivate, routine_id("onCreate_MainWin"))

procedure on_resize( integer self, integer event, sequence parms )
    sequence lCS   
    
    -- Get the new size of the window
    vxMainWin = parms[2]
    vyMainWin = parms[3]                     
    
    -- Shift viewport if new area is exposed.
    if fromX + vxMainWin > vxScreen then
        fromX = vxScreen - vxMainWin
    end if
    if fromY + vyMainWin > vyScreen then
        fromY = vyScreen - vyMainWin
    end if

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

    -- Repaint the images
    onPaint_MainWin(self, w32HPaint, {})

end procedure
setHandler(MainWin, w32HResize, routine_id("on_resize"))

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

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

WinMain( MainWin, Normal ) 

--
Derek

new topic     » topic index » view message » categorize

2. 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?

My apologies for stepping in, Euman, I couldn't resist.


--
jon

jxliv7 at hotmail.com

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

3. RE: Virtual Window code

> Derek Parnell wrote:
>
<snip> 
> 
> Wayne, I've said this before and its worth repeating... If one is going 
> to most of the app using direct API calls, the win32lib is not the right 
> 
> tool. Here is a reworking of your example for all the API code removed 
> (because its not needed). Your inclusion of the API stuff only made it 
> much more complicated that it needed to be. 
>
<snip>

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?

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).

what is the easiest, fastest, and most efficient way to make something 
that can do Windows? what are and why are there differences within the 
Euphoria community programming Windows? is it worth dropping Euphoria 
and learning another language as a way to make Windows applications? 

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.

thanks for your candor and your sharing in the community, i for one 
appreciate it.


--
jon


jxliv7 at hotmail.com

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

4. RE: Virtual Window code

> From: jxliv7 at hotmail.com [mailto:jxliv7 at hotmail.com]
>
> > Derek Parnell wrote:
> >
> <snip> 
> > 
> > Wayne, I've said this before and its worth repeating... If 
> > one is going to most of the app using direct API calls, the
> > win32lib is not the right tool. Here is a reworking of your
> > example for all the API code removed (because its not
> > needed). Your inclusion of the API stuff only made it 
> > much more complicated that it needed to be. 
> >
> <snip>
> 
> 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?

Win32Lib makes lots of calls to the Win32 API.  Win32Lib has a much easier
to understand interface at the cost of some flexibility and the fact that it
isn't as complete as it could be (though it's constantly growing).  Bach
(which is actually a modified Euphoria interpreter) includes a 3rd party
library that plays a similar role to Win32Lib, with the advantage that it's
sort of built into the language (it's actually linked to the IUP dll, IIRC).


You can do anything that Win32Lib can do by directly calling the Win32 API.
It's just a bit more complex.  You'll have to understand how all the
functions and structures work, as opposed to understanding how to call a
Win32Lib routine, which will call the proper functions and build the correct
structures.  However, there are still things that Win32Lib can't do.  In
these cases, it is usually possible to mix some direct API calls in with
Win32Lib based code.  You should be aware of how your code interacts with
Win32Lib, however.  I think Euman just demonstrated that rather well.

> 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).
> 
> what is the easiest, fastest, and most efficient way to make 
> something that can do Windows? what are and why are there differences 
> within the Euphoria community programming Windows? is it worth
> dropping Euphoria and learning another language as a way to make
> Windows applications? 

My personal preference is Win32Lib.  And Judith's IDE can be a big help (I
think I'm a bit too masochistic, as I still tend to hand code my Win32Lib
apps :).  You might also look at Andrea Cini's contribution, which many have
found helpful (although I don't think she's still supporting it, and it's
closed source, so you can't modify it yourself).  Others have made libraries
which are somewhere between Win32Lib and raw API coding.  I wouldn't
recommend starting out this way.  I don't think you'll find any other
language much easier to use that Euphoria + Win32Lib (or EuGTK when you
start in with Linux).


Matt Lewis

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

5. RE: Virtual Window code

On 19 Aug 2003 at 6:00, Derek Parnell wrote:

> 
> 
> euman at bellsouth.net wrote:
> > 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...
> > 
> Thank you for the encouraging words about the library. Comments as clear 
> and helpful as yours have proven to consolidate organizations that are 
> customer-focused, caring, innovative, and open; such as Microsoft.
> 
> You are correct, its nothing to do with the 65k (sic) limit. The reason 
> is that the code was wrong about calculating the source and destination 
> points and the width and heights to copy.
> 
> Wayne, I've said this before and its worth repeating... If one is going 
> to most of the app using direct API calls, the win32lib is not the right 
> tool. Here is a reworking of your example for all the API code removed 
> (because its not needed). Your inclusion of the API stuff only made it 
> much more complicated that it needed to be. 
> 
> I've also added code to handle window resizing and ensuring that we 
> don't try to copy non-existant parts of the bitmap.
> 
> 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.

> Derek

You've once again pulled the Rabbit out of the hat Derek.
I don't know Win32lib and its odd that I seem to make API
work for me so much easier ( this must be the screwdriver thing.)

Anyway, The example is exactly what I was trying to accomplish,
Thanks for your help.

Did you get my post where I pointed out that Win32lib would put
Euphoria on the map, just not right at the moment. blink

I knock the library (jokingly) because I don't know it as intiment as you or
Matt.
I don't look at it everyday, each week and I thought I could try to
help a friend in need who uses the library. I guess in a way, Ive succeded.

I'll remember to make a note not to use API when writing Win32lib code.

Thanks again,
Euman

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

6. RE: Virtual Window code

> From: euman at bellsouth.net [mailto:euman at bellsouth.net]

> I'll remember to make a note not to use API when writing 
> Win32lib code.

My advice would be first to see if Win32Lib can do the task (usually, it
can).  If it can't do it as well as you'd like it to, then I'd recommend
looking at the code in question to see if there's an easy way to do what you
want.  If so, modify it and send it off to Derek.  If not, write a routine
(or set of routines) that do it and send it off to Derek.  Just remember
that you need to consider the other work that win32lib is already doing,
because it can save you a lot of trouble by preventing duplication, or you
might be causing conflicts that lead to other problems.

I know that a lot of your complaints are about speed.  Win32Lib is a
generalist approach to the Win32 API.  It needs to serve many people, so it
can't always cater to one specific scenario, which lends itself very well to
a specific optimization.  If you find a case like this, by all means,
optimize it and make an end run around the library.  I just don't recommend
doing this on a regular basis, because you'll spend your life optimizing
things that don't need it.

Matt Lewis

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

7. RE: Virtual Window code

> Matt Lewis wrote:
> 
> I don't think you'll find any other
> language much easier to use that Euphoria + Win32Lib (or EuGTK when you
> start in with Linux).
> 

thanks for the info and assesment. the best thing i can do is just jump 
in and see what it feels like when i'm up to neck in APIs, eh?

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

jxliv7 at hotmail.com


> 
> Matt Lewis
>

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

8. RE: Virtual Window code

> Derek Parnell wrote:
> 
> Nah, they're the rejects. You should see the ones that stay!
>

oh. fascinating. with the $AU so low against the $US, $1.53 to $1, 
perhaps i should consider moving over there and stretching my pension. 
how expensive is your DSL...?


--
jon

jxliv7 at hotmail.com

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

9. RE: Virtual Window code

> Derek Parnell wrote:
> 
<snip>

thank you for taking the time to fill in some big blanks.

> 
> There is a huge difference in approach between programming for
> windowing systems and for non-windowing systems.

<snip>

i've actually anticipated and written for a Windows-style flow control, 
but of course it's not finished.

<snip>

while i appreciate your devotion to Visual Basic, i am steadily leaning 
toward an open source, non-Microsoft, 64-bit, Linux-clustered world.  

<snip>

a long, long time ago in a college far, far away i had to learn assembly 
and some other low level languages, so if it weren't for the sheer 
numbers of API routines (in Windows AND Linux) i would probably think 
about going back there. coming into the world of object oriented 
programming (Pearl, Ruby, Python, etc.) has its advantages, but somehow 
i'm reluctant to want to wrap my head around a new language.

<snip>

i think the easiest (and hardest!) thing for me to do is as you say, 
just "look inside Win32lib".

thanks,


--
jon


jxliv7 at hotmail.com

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

10. RE: Virtual Window code

This is a multi-part message in MIME format.

------=_NextPart_000_0012_01C366A2.C043A6A0
	charset="Windows-1252"

The speed between Euman's API app and the Win32Lib app looks no different to
me on my system.

  -----Original Message-----
  From: euman at bellsouth.net [mailto:euman at bellsouth.net]
  Subject: Re: Virtual Window code




  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.
--^^---------------------------------------------------------------
This email was sent to: cklester at yahoo.com


TOPICA - Start your own email discussion group. FREE!
---

------=_NextPart_000_0012_01C366A2.C043A6A0
Content-Type: text/html;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<?xml  version=3D"1.0" ?><HTML><HEAD><TITLE></TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 5.50.4926.2500" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D570013903-20082003><FONT face=3DArial color=3D#0000ff =
size=3D2>The=20
speed between Euman's API app and the Win32Lib app looks no different to =
me on=20
my system.</FONT></SPAN></DIV>
<DIV><SPAN class=3D570013903-20082003><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px =
solid; MARGIN-RIGHT: 0px">
  <DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
  size=3D2>-----Original Message-----<BR><B>From:</B> =
euman at bellsouth.net=20
  [mailto:euman at bellsouth.net]<BR><B>Sent:</B> Tuesday, August 19, 2003 =
6:17=20
  PM<BR><B>To:</B> EUforum<BR><B>Subject:</B> Re: Virtual Window=20
  code<BR><BR></FONT></DIV><PRE>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D The =
Euphoria Mailing List =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
</PRE>
  <DIV align=3Dleft><FONT face=3DArial color=3D#7f0000><SPAN=20
  style=3D"FONT-SIZE: 10pt">&gt; Derek and all, </SPAN></FONT></DIV>
  <DIV align=3Dleft><BR></DIV>
  <DIV align=3Dleft><FONT face=3DArial><SPAN style=3D"FONT-SIZE: =
10pt">Here's my=20
  rendition of the demo I was trying to accomplish in Win32lib.=20
  </SPAN></FONT></DIV>
  <DIV align=3Dleft><FONT face=3DArial><SPAN style=3D"FONT-SIZE: =
10pt">This demo uses=20
  a powerfull double buffering technique that will run circles=20
  </SPAN></FONT></DIV>
  <DIV align=3Dleft><FONT face=3DArial><SPAN style=3D"FONT-SIZE: =
10pt">(speed wize)=20
  around any Win32lib app (unless you would supply us with a&nbsp;=20
  </SPAN></FONT></DIV>
  <DIV align=3Dleft><FONT face=3DArial><SPAN style=3D"FONT-SIZE: =
10pt">double=20
  buffering demo using win32lib) </SPAN></FONT></DIV>
  <DIV align=3Dleft><FONT face=3DArial><SPAN style=3D"FONT-SIZE: =
10pt">&nbsp;&nbsp; [I=20
  think I wrote one along time ago when David Cuny had the library upto=20
  </SPAN></FONT></DIV>
  <DIV align=3Dleft><FONT face=3DArial><SPAN=20
  style=3D"FONT-SIZE: 10pt">&nbsp;&nbsp;&nbsp; version 0.15 or=20
  so.]</SPAN></FONT></DIV>
  <DIV align=3Dleft><BR></DIV>
  <DIV align=3Dleft><FONT face=3DArial><SPAN style=3D"FONT-SIZE: =
10pt">The user I am=20
  trying to help would prefer this be written using win32lib=20
</SPAN></FONT></DIV>
  <DIV align=3Dleft><FONT face=3DArial><SPAN style=3D"FONT-SIZE: =
10pt">but Im just not=20
  great with learning a new language (win32lib). I have become=20
  </SPAN></FONT></DIV>
  <DIV align=3Dleft><FONT face=3DArial><SPAN style=3D"FONT-SIZE: =
10pt">so used to=20
  Win32 API&nbsp; that I have a hard time understanding wrappers.=20
  </SPAN></FONT></DIV>
  <DIV align=3Dleft><BR></DIV>
  <DIV align=3Dleft><FONT face=3DArial><SPAN style=3D"FONT-SIZE: =
10pt">Enjoy!=20
  </SPAN></FONT></DIV>
  <DIV align=3Dleft><BR></DIV>
  <DIV align=3Dleft><FONT face=3DArial><SPAN style=3D"FONT-SIZE: =
10pt">Topica wouldn't=20
  allow me to upload the file in the email because they say=20
  its</SPAN></FONT></DIV>
  <DIV align=3Dleft><FONT face=3DArial><SPAN style=3D"FONT-SIZE: =
10pt">too large when=20
  in fact, the entire program is only 22k</SPAN></FONT></DIV>
  <DIV align=3Dleft><BR></DIV>
  <DIV align=3Dleft><FONT face=3DArial><SPAN style=3D"FONT-SIZE: =
10pt">Download here=20
  to see the API version of a Virtual Window Demo</SPAN></FONT></DIV>
  <DIV align=3Dleft><BR></DIV>
  <DIV align=3Dleft><FONT face=3DArial color=3D#008000><SPAN=20
  style=3D"FONT-SIZE: =
10pt"><U>ftp://h2osoft.homeip.net/virtwin.exw</U></SPAN></FONT><FONT=20
  face=3DArial><SPAN style=3D"FONT-SIZE: 10pt"> </SPAN></FONT></DIV>
  <DIV align=3Dleft><BR></DIV>
  <DIV align=3Dleft><FONT face=3DArial><SPAN style=3D"FONT-SIZE: =
10pt">The good news=20
  is there are a great many uses for this type of =
system.</SPAN></FONT></DIV>
  <DIV align=3Dleft><FONT face=3DArial><SPAN style=3D"FONT-SIZE: =
10pt">One that comes=20
  to mind is a CAD program (only a CAD app would be</SPAN></FONT></DIV>
  <DIV align=3Dleft><FONT face=3DArial><SPAN style=3D"FONT-SIZE: 10pt">a =
couple=20
  hundred thousand lines more work...</SPAN></FONT></DIV>
  <DIV align=3Dleft><BR></DIV>
  <DIV align=3Dleft><FONT face=3DArial><SPAN=20
  style=3D"FONT-SIZE: =
10pt">Euman.</SPAN></FONT></DIV><PRE>--^^--------------------------------=
-------------------------------
This email was sent to: cklester at yahoo.com

EASY UNSUBSCRIBE click here: <A =
href=3D"http://topica.com/u/?b1dd66.b2Iiq0.Y2tsZXN0">http://topica.com/u/=
?b1dd66.b2Iiq0.Y2tsZXN0</A>
Or send an email to: EUforum-unsubscribe at topica.com

TOPICA - Start your own email discussion group. FREE!
<A =
href=3D"http://www.topica.com/partner/tag02/create/index2.html">http://ww=
w.topica.com/partner/tag02/create/index2.html</A>
--^^---------------------------------------------------------------</PRE>=

------=_NextPart_000_0012_01C366A2.C043A6A0--

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

11. RE: Virtual Window code

On 19 Aug 2003 at 22:39, C. K. Lester wrote:

> 
> 
> 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.

Euman

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

Search



Quick Links

User menu

Not signed in.

Misc Menu