| 发表于:2007-04-09 17:09:587楼 得分:20 |
option explicit private sub fg_beforemousedown(byval button as integer, byval shift as integer, byval x as single, byval y as single, cancel as boolean) ' only interesetd in left button if button <> 1 then exit sub ' get cell that was clicked dim r&, c& r = fg.mouserow c = fg.mousecol ' make sure the click was on the sheet if r < 0 or c < 0 then exit sub ' make sure the click was on a cell with a button if not (fg.cell(flexcppicture, r, c) is imgbtnup) then exit sub ' make sure the click was on the button (not just on the cell) ' note: this works for right-aligned buttons dim d! d = fg.cell(flexcpleft, r, c) + fg.cell(flexcpwidth, r, c) - x if d > imgbtndn.width then exit sub ' click was on a button: do the work fg.cell(flexcppicture, r, c) = imgbtndn msgbox "thanks for clicking my custom button! " fg.cell(flexcppicture, r, c) = imgbtnup ' cancel default processing ' note: this is not strictly necessary in this case, because ' the dialog box already stole the focus etc, but let 's be safe. cancel = true end sub private sub form_load() ' initialize grid fg.editable = flexedkbdmouse fg.allowuserresizing = flexresizeboth ' add some buttons to the grid dim i% for i = 2 to 6 fg.cell(flexcppicture, i, 2) = imgbtnup fg.cell(flexcppicturealignment, i, 2) = flexalignrightcenter next end sub private sub form_resize() on error resume next fg.move fg.left, fg.top, scalewidth - 2 * fg.left, scaleheight - fg.left - fg.top end sub | | |
|