[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1071
  • Last Modified:

How can you create a PowerBuilder Windows application with windows which look like iTunes or Napster?

How can you create a PowerBuilder Windows application with windows which look like iTunes or Napster?

i.e. with rounded window edges and shaded colouring - I can't find any way to control this in PowerBuilder

are these some extensions which I can download or purchase to enable me to do this?
do I just need to learn the PBNI to control the windows directly - if so can you find me an example?
0
Omnipower
Asked:
Omnipower
  • 2
1 Solution
 
tr1l0b1tCommented:
Hi,

my little contribution ...

~~~~~~~~~~~~~~~~
Shaded colouring :
~~~~~~~~~~~~~~~~
    - Windows : Create a bitmap with the shade effect and place it on the window background.
    - Buttons : Use PictureButtons containing appropiate bitmaps instead CommandButtons.

~~~~~~~~~~~~~~~~
Rounded window edges :
~~~~~~~~~~~~~~~~

You must create a 'region' and call the winAPI "SetWindowRgn()" passing the
window's handle and the 'region' as parameters. The external function declaration is :

    FUNCTION long SetWindowRgn( ulong hWnd, ulong hRgn, boolean bRedraw ) LIBRARY "user32.dll"

there is several external functions to create/manage regions :

    FUNCTION long CreateEllipticRgn(long x1, long y1, long x2, long y2) LIBRARY "gdi32.dll"
    FUNCTION long CreatePolygonRgn(POINT lppt[], int cPoints, int fnPolyFillMode) LIBRARY "gdi32.dll"
    FUNCTION long CreateRectRgn(long x1, long y1, long x2, long y2) LIBRARY "gdi32.dll"
    FUNCTION int CombineRgn(ulong hrgnDest, ulong hrgnSrc1, ulong hrgnSrc2, int fnCombineMode) LIBRARY "gdi32.dll"

where 'POINT' is a simple structure :
    global type point from structure
      long            cx
      long            cy
    end type

Well, here is an easy example (elliptical window) :

///////////////////////////
// Window's Open event

Long      x2, y2
ULong       hWnd
Long      il_newRgn
x2 = UnitsToPixels( this.Width, XUnitsToPixels! )
y2 = UnitsToPixels( this.Height, YUnitsToPixels! )
hWnd = Handle( this )
il_newRgn = CreateEllipticRgn( 0, 0, x2, y2 )
SetWindowRgn( hWnd, il_newRgn, TRUE )

///////////////////////////

If you want a complex user defined shape, you need to create an array with the points and call "CreatePolygonRgn()". When the shape is complex enough, I guess you'll need an utility that generate the point coordinates for you.

///////////////////////////
// Window's Open event

// CreatePolyRgn constants
CONSTANT int ALTERNATE = 1
CONSTANT int WINDING = 2

POINT      lpt_points[8]
ULong       hWnd
Long      ll_newRgn

// point coordinates
lpt_points[1].cx = 0
lpt_points[1].cy = 0
lpt_points[2].cx = 10
lpt_points[2].cy = 6
 ...
lpt_points[8].cx = 80
lpt_points[8].cy = 75

hWnd = Handle(this)
ll_newRgn = CreatePolygonRgn( lpt_points, 8, ALTERNATE )
SetWindowRgn( hWnd, il_newRgn, TRUE )

///////////////////////////

let me know if you have any question.
Regards
0
 
tr1l0b1tCommented:
more ...

This function is very interesting as it lets you create round rectangle regions which are very extended :

    FUNCTION long CreateRoundRectRgn( long nLeftRect, long nTopRect, long nRightRect, long nBottomRect , long nWidthEllipse, long nHeightEllipse) LIBRARY "gdi32.dll"

    nLeftRect,         // x-coordinate of upper-left corner
    nTopRect,         // y-coordinate of upper-left corner
    nRightRect,       // x-coordinate of lower-right corner
    nBottomRect,    // y-coordinate of lower-right corner
    nWidthEllipse,   // width of ellipse
    nHeightEllipse   // height of ellipse

also take in mind the 'CombineRgn' function (mentioned in the above post) :

    FUNCTION int CombineRgn(ulong hrgnDest, ulong hrgnSrc1, ulong hrgnSrc2, int fnCombineMode) LIBRARY "gdi32.dll"

    hrgnDest,      // handle to destination region
    hrgnSrc1,      // handle to 1st source region
    hrgnSrc2,      // handle to 2nd source region
    fnCombineMode   // region combining mode

where 'fnCombineMode' can take these values :

    CONSTANT RGN_AND   = 1    // Creates the intersection of the two combined regions
    CONSTANT RGN_OR    = 2    // Creates the union of two combined regions
    CONSTANT RGN_XOR   = 3   // Creates the union of two combined regions except for any overlapping areas
    CONSTANT RGN_DIFF   = 4   // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2
    CONSTANT RGN_COPY = 5   // Creates a copy of the region identified by hrgnSrc1

Regions can also be used with objects such PictureButtons or CommandButtons just
taking its handle and aplying them a region as described in the next issue :  http://www.experts-exchange.com/Programming/Programming_Languages/PowerBuilder/Q_20486020.html

Anyway, I recommend you to read MS Reference : http://msdn.microsoft.com/library/en-us/gdi/regions_7ab7.asp

Hope it helps
Regards :: Tr1l0b1t
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now