Welcome!

PowerBuilder Authors: Chris Pollach, Yeshim Deniz, Jayaram Krishnaswamy, Kevin Benedict, Avi Rosenthal

Related Topics: PowerBuilder, Microsoft Cloud

PowerBuilder: Blog Post

Bye Bye SetRedraw( )

More migration changes from Classic to .NET

A common Classic PB code technique when modifying the displayed contents of window controls, is to turn off screen refresh by calling SetRedraw( false ), performing the update activity and then calling SetRedraw (true).

Setredraw( ) is one of those graphic object methods that falls by the wayside when migrating to .NET.  It is no longer supported.  Is this a bad thing that will give your users a migraine headache or a non-issue?

This post and the accompanying video will give you a refreshing understanding of the issue and help set your expectations when you migrate and see those unsupported feature warnings.

First some background:

In classic Windows UI and .NET WinForm, each window (and remember internally each control is a window) is constantly redrawing itself; when it's first created, when it's covered and re-exposed, and when something about its look and feel needs to change.     When the application is told to paint itself (draw in PB terms), it works with an abstraction called a device context which is wrapped in a Graphics object.  The context deals with the drawing surface as a field of colored dots which each of which it turns on in a color or off to match the request.  The whole process is built upon the 1990's hardware and device driver technology that was current when MS Windows 3.x was designed Whew, I bet you're begin to get the feeling that constantly repainting a display during a dynamic refresh process is a lot of work for the application program!

WPF is built on top of modern Direct3D technology that takes advantage of current and new graphics cards as they come out.  WPF pushes off allot of the drawing and rendering work to the hardware level and deals with graphics as vectors instead of fields of individual dots.  Plus, WPF uses a method called retained-mode drawing that generally limits the amount of repainting a control must do.  A control renders itself once and WPF takes over from there.

The upshot of this, the reason that SetRedraw(  ) was necessary has been eliminated!  Window changes will appear smooth without the need to turn screen painting off and on.

Take a look at this code - It's the kind of visual refresh process you'd typically wrap inside SetRedraw( ) bookends.

Click on this link to watch a video where you'll see how this code behaves in Classic with SetRedraw on and off what happens after you migrate to .NET

http://www.elearnitonline.com/BlogVideos/Setredraw.html

More Stories By Yakov Werde

Yakov Werde, a 25 year IT industry veteran, is a member of TeamSybase and the newly formed Sybase Customer Evangelist Team. Yakov is a recognized author, speaker and trainer who has been designing and delivering PowerBuilder, .NET, EaServer, Web App Development, and Java training for over 14 years to corporate, military and government developers. Prior to discovering his aptitude as an educator, Yakov worked as an architect, project manager and application coder in the trenches of application software development. Yakov holds a Masters in Education with a specialty in instructional design for online learning from Capella University and a BS in math and computer science from Florida International University. Yakov, managing partner of eLearnIT LLC (www.elearnitonline.com), authors and delivers workshops and web based eLearning tutorials to guide professional developers toward PowerBuilder Classic and .NET mastery. Follow Yakov on Twitter as @eLearnPB