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

Posted on 2006-04-15
Last Modified: 2013-12-26
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?
Question by:Omnipower
    LVL 6

    Accepted Solution


    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

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

    Expert Comment

    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 :

    Anyway, I recommend you to read MS Reference :

    Hope it helps
    Regards :: Tr1l0b1t

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project ( automates most of the tasks discussed in this article. You can even fin…
    How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from ( Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now