// a ToolButton class for forms that resets itself. // // Thanks to Glenn Johansen, Rick Miller, Ivar Jessen, Rich (from AutoTraker) // and Jim Sare for the various ideas and code snippets that made this possible! // What is different about this class (compared to all the original code from these // authors): I wanted to have "real" Buttons because I wanted to be able to use the // "speedtips" and other feature of the button class. // // Usage: Set procedure to toolbutton.cc additive // Drag a toolbtn onto your form. // Change the upbitmap (of the button) // Change the speedtip // Assign an onClick event to the Button // (as the first action in the onClick, you should reset the button with: // this.reset() // ) // // This control is only for forms with Metric PIXELS // and works best (at it's current size) with images of 24x24 // // Jan Hoelterling (jhoelterling@compuserve.com) // CLASS toolbtn(oParent) of PushButton(oParent) custom with (this) onOpen = Class::TOOLBTN_ONOPEN onMouseMove = class::ONMOUSEMOVE onLeftMouseUp = class::reset left = 0 top = 0 width = 23 height = 23 text = "" borderstyle = 3 // None speedbar = true fontsize = 8 upbitmap = "RESOURCE #856" *speedtip = "Replace this with your speedtip" mousePointer = 13 // Hand endwith form.btnhardreset = false this.up = false function ToolBtn_OnOpen // for some reason, this does not work as INIT if type("SetCapture") # "FP" extern chandle SetCapture(chandle) user32 endif if type("ReleaseCapture") # "FP" extern clogical ReleaseCapture(cvoid) user32 endif if type("SendMessage") # "FP" extern CLONG SendMessage(CHANDLE,CUINT,CUINT,CLONG) USER32 from "SendMessageA" endif // Flat button SendMessage(this.hWnd,htoi("0406"),16,0) return function onMouseMove(flags, col, row) static bOver = false if form.btnhardreset // Raises button this.up = true SendMessage(this.hWnd, 0x0406, 16, 2) this.mousePointer = 13 // Hand bOver = true form.btnhardreset=false else if col > this.width or row > this.height ReleaseCapture() if bOver //this.borderStyle = 3 // none // Flat button this.up = false SendMessage(this.hWnd, 0x0406, 16, 0) bOver = false endif else SetCapture(this.hwnd) if not bOver //this.borderStyle = 8 // raised // Raises button SendMessage(this.hWnd, 0x0406, 16, 2) this.up = true this.mousePointer = 13 // Hand bOver = true endif endif endif return function reset *ReleaseCapture() SendMessage(this.hWnd,htoi("0406"),16,0) form.btnhardreset=true return endclass