|
楼主 |
发表于 2020-6-12 10:00:10
|
显示全部楼层
贴个按钮jscript代码吧:
- function MBtn(win, idPrefix, text, active, ltrb) {
- this.win = win;
- this.idPrefix = idPrefix;
- this.text = text;
- this.active = active;
- this.ltrb = ltrb;
- this.getText = function() {
- return this.text;
- };
- this.getHotspotId = function() {
- return this.idPrefix + "_hs";
- };
- this.setLtrb = function(l,t,r,b) {
- this.ltrb = [l,t,r,b];
- };
- this.drawMe = function() {
- var l = this.ltrb[0];
- var t = this.ltrb[1];
- var r = this.ltrb[2];
- var b = this.ltrb[3];
- var act = RECT_ACTION_SIMPLE;
- var color1 =DARK_BLUE;
- var color2 = DARK_BLUE;
- if (this.active) {
- act = RECT_ACTION_3D;
- color1 = 5; //5 : Raised 6 : Etched 9 : Bump 10 : Sunken
- color2 = 15; //0x03 (3) top left 0x06 (6) top right 0x09 (9) bottom left 0x0c (12) bottom right 0x0f (15) rect
- }
- // black out previous draw
- world.WindowRectOp(this.win, RECT_ACTION_FILL, l,t,r,b, BLACK,BLACK);
- // Rect
- world.WindowRectOp(this.win, act, l, t, r, b, color1, color2);
- // Hotspot
- world.WindowAddHotspot(this.win, this.getHotspotId(), l,t,r,b,
- "", //BSTR MouseOver
- "", // BSTR CancelMouseOver
- "btnMouseDown", //BSTR MouseDown
- "", //BSTR CancelMouseDown
- "", //BSTR MouseUp
- "", //BSTR TooltipText
- 1, //cursor_hand = 1
- 0 //Flags)
- )
- // Text
- var txtH = world.WindowFontInfo(this.win, MFONT, 1);
- var txtT = t + (b - t - txtH) / 2;
- var txtW = world.WindowTextWidth(this.win, MFONT, this.text, false);
- var txtL = l + (r - l - txtW) / 2;
- world.WindowText(this.win, MFONT, this.text, txtL, txtT, r, b, GREEN, false);
- }
- }
复制代码 |
|