How to make Special shape Data window or button introduction in PB

Source: Internet
Author: User

On the CSDN, there are often friends asked how irregular window or irregular button how to make, here I introduce
Several more commonly used API functions, to implement irregular windows or irregular button production.
First, look at the effect:
Click on the Circular lace button for the following results:

(blue for the desktop)

The inaugural issue of CSDN Community E-magazine-powerbuilder magazine
Second, the following I introduce the main application of several API functions:
1. Create a rounded rectangle createroundrectrgn
CreateRoundRectRgn
PB Declaration
FUNCTION ulong CreateRoundRectRgn (Long x1, long y1, long x2, long y2, long x3, long y3) library "GDI32"
Description
Creates a rounded rectangle that is determined by the X1, Y1-x2, Y2, and is defined by X3, Y3, to describe the rounded radians
return value
Long, the execution succeeds as the zone handle, and the failure is 0
Parameter table
Parameter type and description
X1,y1 Long, X in the upper-left corner of the rectangle, Y-coordinate
X2,y2 Long, the X-Y coordinate of the lower-right corner of the rectangle
X3 Long, width of rounded ellipse. Its range is from 0 (no rounded corners) to rectangular width (full circle)
Y3 Long, rounded ellipse high. Its range is from 0 (no rounded corners) to rectangular heights (full circle)
Annotations
Be sure to use the DeleteObject function to remove the area
The area created with this function is not exactly the same as the rounded rectangle drawn with the RoundRect API function, because the right and bottom sides of this rectangle do not include
Within the area
2. Create an area surrounded by a series of points createpolygonrgn
CreatePolygonRgn
PB Declaration
FUNCTION ulong CreatePolygonRgn (ref ws_position lppt[], int cpoints, int fnpolyfillmode) Library "GDI32"
Description
Creates an area that is surrounded by a series of points. Windows automatically connects the last point to the 1th to close the polygon when needed
return value
Long, execution succeeds for the created zone handle, failure is 0
Parameter table
Parameter type and description
Lppoint Pointapi, ncount the first POINTAPI structure in a POINTAPI structure
Ncount Long, point of polygon
Npolyfillmode
A Long that describes the polygon fill pattern. Can be a ALTERNATE or winding constant. Reference
Interpretation of polygon fill mode with Setpolyfillmode function
Annotations
Be sure to use the DeleteObject function to remove the area
-26-
The inaugural issue of CSDN Community E-magazine-powerbuilder magazine
3. Create an ellipse createellipticrgn
CreateEllipticRgn
PB Declaration
FUNCTION ulong CreateEllipticRgn (Long x1, long y1, long x2, long y2) library "GDI32"
Description
Creates an ellipse with X1, Y1, and X2, and Y2 coordinates that determine the inner tangent of the rectangle.
return value
Long, the execution succeeds as the zone handle, and the failure is zero
Parameter table
Parameter type and description
X1,y1 Long, Upper-left corner of rectangle X, Y-coordinate
X2,y2 Long, lower right corner of rectangle X, Y coordinate
Annotations
Be sure to use the DeleteObject function to delete the area when you are not. The ellipse drawn with the Ellipse API function is not exactly the same as the Ellipse region,
Because the drawing calculation for this function does not include the bottom and right sides of the rectangle
4. Change the area of the window SetWindowRgn, this is the most important function
SetWindowRgn
PB Declaration
FUNCTION ULONG SetWindowRgn (ULONG hwnd,ulong hrgn,boolean bredraw) LIBRARY "User32"
Description
This is one of the hidden API functions that are hard to notice and are a huge treasure for programmers. This function allows you to change
The area of the window. Usually all windows are rectangular--once a window exists, it contains a rectangular area. This function allows you to discard the zone.
This means that you can create a round, star-shaped window, or you can divide it into two or many parts--it can actually be any shape
return value
Long, execution success is not 0 value, failure is 0
Parameter table
Parameter type and description
HWnd Long, which will set the window of its region
HRgn
Long, a handle to the area that will be set, and once the area is set, you cannot use or modify the area sentence
Handle, and do not remove it
Bredraw Boolean, if true, to redraw the window immediately
Annotations
All coordinates specified for a range are represented in window coordinates (not customer coordinates), and they take the entire window (including the title bar and border) to the left
Upper corner as starting point
5. Merging regional functions Combinergn
Combinergn
-27-
The inaugural issue of CSDN Community E-magazine-powerbuilder magazine
PB Declaration
FUNCTION ulong Combinergn (Long hdestrgn, long hSrcRgn1, long hSrcRgn2, long Ncombinemode)
LIBRARY "GDI32"
Description
Combine two regions into a new region
return value
Long, one of the following constants:
Complexregion: areas have overlapping boundaries
Simpleregion: Zone boundaries do not overlap each other
Nullregion: Zone is empty
ERRORAPI: Cannot create a combined region
Parameter table
Parameter type and description
Hdestrgn Long, which contains the area handle of the combined result
HSrcRgn1 Long, source area 1
HSrcRgn2 Long, source area 2
Long, the method of combining the two regions. Can be set to the following constants
Rgn_and Hdestrgn is set to the intersection of two source regions
Rgn_copy Hdestrgn is set as a copy of HSRCRGN1
Rgn_diff
Hdestrgn is set to HSRCRGN1 in the
HSRCRGN2 parts that do not intersect
Rgn_or Hdestrgn is set to a two-zone-set
Ncombinemode
Rgn_xor
Hdestrgn is set to a range of two source regions OR
The outside part
6. Delete GDI objects DeleteObject
DeleteObject
PB Declaration
FUNCTION ULONG DeleteObject (ULONG hobject) LIBRARY "Gdi32.dll"
Description
Use this function to remove GDI objects such as brushes, brushes, fonts, bitmaps, regions, palettes, and so on. All system resources used by the object
The source will be released.
return value
Long, nonzero indicates success, 0 indicates failure
Parameter table
Parameter type and description
Hobject Long, a handle to a GDI object
Annotations
-28-
The inaugural issue of CSDN Community E-magazine-powerbuilder magazine
Do not delete a brush, brush, or bitmap that has been selected into a device scene. If you delete a bitmap-based shadow (pattern) brush, the bitmap does not
Removed by this function--only brushes are erased
Third, some core implementation code
The Code for the circular window:
Long ll_x1, ll_x2, ll_x3
Long ll_y1, Ll_y2, Ll_y3
Long Ll_handle
Long Ll_data
Take the width of the window
Ll_data = Unitstopixels (Parent.width, xunitstopixels!)
Ll_data = Pixelstounits (Ll_data, ypixelstounits!)
Parent.height = Ll_data
LL_X1 = 10
Ll_y1 = 25
ll_x2 = Unitstopixels (Parent.width, xunitstopixels!)-10
Ll_y2 = Unitstopixels (Parent.height, yunitstopixels!)-10
Create a circular area
Ll_handle = CreateEllipticRgn (ll_x1, Ll_y1, ll_x2, Ll_y2)
SetWindowRgn (handle (parent), Ll_handle, True)
Return 1
The code is also relatively simple, and I do not elaborate on the other, interested friends can be the entire window of the source code into the PBL to run their own
Try it for a second.
Source:
http://blog.csdn.net/lzp_lrp/article/details/45668141

How to make Special shape Data window or button introduction in PB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.