1. Win32 page flipping

I have several pages of graphics and text (wPuts'ed) that I wish to switch
between without flickering. How do I draw graphics and text into a bitmap, so
that I can blit it on to the screen in one go?
=======================
Patrick Barnes
Information Systems Group
201 Elizabeth St, Sydney
Patrick.Barnes at transgrid.com.au
Ext: 91-3583
Ph:(02) 9284-3583
Mob: 0410 751 044


***********************************************************************




***********************************************************************

new topic     » topic index » view message » categorize

2. Re: Win32 page flipping

On Tue, 14 Jan 2003 14:00:43 +1100, Patrick.Barnes at transgrid.com.au
wrote:

>
>I have several pages of graphics and text (wPuts'ed) that I wish to =
switch between without flickering. How do I draw graphics and text into a=
 bitmap, so that I can blit it on to the screen in one go?

=46lickering? Do you use repaintWindow() alot? I found I reduced alot of
flicker with surrounding toolbars, buttons, border etc which did not
need updating by invoking my oppaint routine directly.

Otherwise: I assume you already have code which writes direct to the
window, so use something like this:

	size =3D getClientRect(win) -- returns {x1,y1,x2,y2}
	size[3]-=3Dsize[1]
	size[4]-=3Dsize[2]
	If Bitmap=3D0 then --[**1**]
		Bitmap=3Dcreate(Pixmap,"",0,0,0,size[3],size[4],0)
	end if
	setCtlSize(Bitmap,size[3],size[4])


then setFont/setPenColor/drawRectangle/drawLine/bitBlt/stretchBlt/
setTextColor/wPuts as usual, only to your Bitmap, then just:

	copyBlt(win, 0, 0, Bitmap)

Pete
 [**1**] I create my bitmap precisely once, maximum size since I open
the window maximised, and resized it before each repaint.

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

3. Re: Win32 page flipping

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

- ----- Original Message ----- 
From: <Patrick.Barnes at transgrid.com.au>
Subject: Win32 page flipping


> I have several pages of graphics and text (wPuts'ed) that I wish to switch
> between without flickering.
> How do I draw graphics and text into a bitmap, so that I can blit it on to the
> screen in one go?

Hello,

Several options to choose from here.

1) use CS_OWNDC when you create your MainWindow
     or
2) Create a/or more CompatibleDC's (memory device context)

[example]

global function CreateCompatibleDC(atom hdc)
   return c_func(xCreateCompatibleDC, {hdc})
end function

hdc = GetDC(hwnd) 
memdc = CreateCompatibleDC(hdc) -- make sure we destroy this when we exit the
prog

if iMsg = WM_PAINT then -- BitBlt the memdc to the hdc
   BitBlt(hdc, 0, 0,601,455,memdc,0,0,SRCCOPY)    

Its alittle more complex than this simple message so I would suggest downloading
some of euman's examples or if you prefer to use win32lib I could send you an
pretty neat graphical demo that got Jordah started.

Regards,
[not really] Unknown

-----BEGIN PGP SIGNATURE-----
Version: PGP Personal Privacy 6.5.8

iQA/AwUBPiONpqfIAe6g4MxnEQLaJwCePx3Cbvl+Mb7PQKvwJxG64BWQjysAoMJ0
a68vujwkGhvq57SYUzBriykc
=Omyi
-----END PGP SIGNATURE-----

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

4. Re: Win32 page flipping

Hi patrick,
     with win32lib, create a pixmap which is definately a compatible bitmap.
draw everything on it using wPuts..etc then use bitblt() or copyblt().

if you're interested in speed/flicker free, then use API calls as opposed to
win32lib calls. if you need the sequence of routines then.
    1) create a compatible DC of window u want to use.
      using CreateCompatibleDC(). remember to delete    this using DeleteDC
    2) Create a memory bitmap using CreateCompatibleBitmap
    3) Select the bitmap into the CompatibleDC. make sure u save the value
returned by SelectObject because u'll need to select it back into the DC
before you delete the compatible bitmap using DeleteObject
    4)Use PatBlt() to fill the bitmap(selected in DC) using specified raster
operations. this is faster than using a filled rectangle because it does a
sorta of bit block transfer.
    6) Write the Text using either DrawText or TextOut
    7) do all necessary stuff then use bitblt() to transfer the bitmap to
destination DC. then clean up.

     Sorry, maybe i have over-emphasised and u alreadyu know this but who
knows. Maybe someone out there has learnt some tips.

Jordah
----- Original Message -----
From: <Patrick.Barnes at transgrid.com.au>
To: "EUforum" <EUforum at topica.com>
Sent: Tuesday, January 14, 2003 3:00 AM
Subject: Win32 page flipping


>
> I have several pages of graphics and text (wPuts'ed) that I wish to switch
between without flickering. How do I draw graphics and text into a bitmap,
so that I can blit it on to the screen in one go?
> =======================
> Patrick Barnes
> Information Systems Group
> 201 Elizabeth St, Sydney
> Patrick.Barnes at transgrid.com.au
> Ext: 91-3583
> Ph:(02) 9284-3583
> Mob: 0410 751 044
>
>
> ***********************************************************************
>
>
> ***********************************************************************
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>

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

5. Re: Win32 page flipping

Hi Unknown,
     Send him the examples, they helped me a lot. Btw, Thanx alot for the
API tutorials/lessons u gave me.

Jordah
----- Original Message -----
From: <cgibin at bellsouth.net>
To: "EUforum" <EUforum at topica.com>
Subject: Re: Win32 page flipping


>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> - ----- Original Message -----
> From: <Patrick.Barnes at transgrid.com.au>
> Sent: Monday, January 13, 2003 10:00 PM
> Subject: Win32 page flipping
>
>
> > I have several pages of graphics and text (wPuts'ed) that I wish to
switch between without flickering.
> > How do I draw graphics and text into a bitmap, so that I can blit it on
to the screen in one go?
>
> Hello,
>
> Several options to choose from here.
>
> 1) use CS_OWNDC when you create your MainWindow
>      or
> 2) Create a/or more CompatibleDC's (memory device context)
>
> [example]
>
> global function CreateCompatibleDC(atom hdc)
>    return c_func(xCreateCompatibleDC, {hdc})
> end function
>
> hdc = GetDC(hwnd)
> memdc = CreateCompatibleDC(hdc) -- make sure we destroy this when we exit
the prog
>
> if iMsg = WM_PAINT then -- BitBlt the memdc to the hdc
>    BitBlt(hdc, 0, 0,601,455,memdc,0,0,SRCCOPY)
>
> Its alittle more complex than this simple message so I would suggest
downloading
> some of euman's examples or if you prefer to use win32lib I could send you
an
> pretty neat graphical demo that got Jordah started.
>
> Regards,
> [not really] Unknown
>
> -----BEGIN PGP SIGNATURE-----
> Version: PGP Personal Privacy 6.5.8
>
> iQA/AwUBPiONpqfIAe6g4MxnEQLaJwCePx3Cbvl+Mb7PQKvwJxG64BWQjysAoMJ0
> a68vujwkGhvq57SYUzBriykc
> =Omyi
> -----END PGP SIGNATURE-----
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>

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

6. Re: Win32 page flipping

Hi Patrick,

  you can still trap that windows message using win32lib.
try something like this.

procedure TrapMsg(integer id,integer event,sequence params)
     if params[1] = WM_ERASEBKGND then
          returnValue(1)
     end if
end procedure
setHandler(<window id>,w32HEvent,routine_id("TrapMsg"))

Jordah
----- Original Message -----
From: <Patrick.Barnes at transgrid.com.au>
To: "EUforum" <EUforum at topica.com>
Sent: Tuesday, January 14, 2003 9:50 PM
Subject: RE: Win32 page flipping


>
> How do you do that? Is that a win32lib thing, or an api thing?
>
> -----Original Message-----
> From: Phil Russell [mailto:pg_russell at lineone.net]
> Sent: Tuesday, 14 January 2003 20:56
> To: EUforum
> Subject: RE: Win32 page flipping
>
>
> Hi Patrick,
>
> Another source of flicker that I have found is the automatic background
> erase that windows performs prior to WM_PAINT being issued. You can
> prevent this by returning 1 to the WM_ERASEBKGND message for the window
> you are blitting to.
>
> There is also a good article on flicker-free drawing at:
>
> http://freespace.virgin.net/james.brown7/tuts/flicker.htm
>
> HTH,
>
> Phil
>
> Patrick.Barnes at transgrid.com.au wrote:
> > I have several pages of graphics and text (wPuts'ed) that I wish to
> > switch between without flickering. How do I draw graphics and text into
> > a bitmap, so that I can blit it on to the screen in one go?
> > =======================
> > Patrick Barnes
> > Information Systems Group
> > 201 Elizabeth St, Sydney
> > Patrick.Barnes at transgrid.com.au
> > Ext: 91-3583
> > Ph:(02) 9284-3583
> > Mob: 0410 751 044
> >
> >
> > ***********************************************************************
> >
> >
> > ***********************************************************************
> >
> >
> TOPICA - Start your own email discussion group. FREE!
>
>
> ***********************************************************************
>
>
> ***********************************************************************
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu