/* Filename: Round_Corner_Button1.cc Date: 2023-03-21 Author: Mervyn Bick Revision: 1 Instead of using a dBASE shape object, the function CreateRoundRectRgn() from the Windows32 API is used to creat the region. This gives control over the rounding of the corners but does not allow for a border. Description: Round_Corner_Button is a pushbutton based on an idea (and code) "borrowed" from Marc van den Berghen's article "The Form Factory" in issue 21 of the dBulletin. https://www.jpmartel.com/bulletin.htm The custom control should be used on a form where the metric property is set to pixels. In the designer the pushbutton will present as a square. Resize as appropriate keeping the height and width about the same. When the form opens the pushbutton will set its width to match the height. This ensures any text remains centered. If it is necessary to assign an event handler to the onOpen event the onOpen event in the custom class must be executed before any other code. function ROUNDBUTTON1_onOpen() roundbutton::onOpen() // Other code return */ class Round_Corner_Button1( parentObj ) of PushButton( parentObj ) custom with (this) onOpen = class::ONOPEN metric = 6 // Pixels height = 65.0 width = 65.0 text = 'PB' fontsize = 15 systemtheme := false colorNormal = "0x40/0xeaeaea" endwith function onopen local hrgn1 if this.width <> this.height this.width = this.height endif if type("SetWindowRgn") # "FP" extern cint SetWindowRgn(chandle, chandle, clogical) user32 endif if type("CreateRoundRectRgn") # "FP" extern chandle CreateRoundRectRgn(cint,cint,cint,cint,cint,cint) gdi32 endif z = 30 // rounding for corners nFudge = 2 //hide edges in new region x1 = 0 y1 = 0 x2 = this.width y2 = this.height hrgn1=CreateRoundRectRgn(x1+nFudge,y1+nFudge,y2-nFudge,y2-nFudge,z,z) setwindowrgn(this.hwnd,hrgn1,true) this.top = this.top this.left = this.left return endclass