| Subject |
Re: shorcut for printing |
| From |
Mervyn Bick <invalid@invalid.invalid> |
| Date |
Mon, 13 Jun 2022 10:36:14 +0200 |
| Newsgroups |
dbase.getting-started |
| Attachment(s) |
accellerator_key.wfm |
On 2022/06/09 13:52, Mustansir Ghor wrote:
> Dear Akshat
>
> Thank you.
>
You don't say what version of dBASE you're using but it's probably 11 as
Akshat surmises.
It's a bit of a kludge but you could use the same technique used to
force the dropdown list of a combobox to open.
The attached example uses a second pushbutton also set to use Alt-N to
simulate a mouse click on the Print button. It looks as if dBASE
executes the second button's onClick event handler when Alt-N is keyed
so there is no need to change the text on the existing Print button.
The second pushbutton needs to have it's visible property set true
otherwise it doesn't see the accelerator key so I've moved it off the
form to the left.
The code in the attached example is essentially a cut & paste of the
code used to force the dropdown list of a combobox to open. That worked
in dBASE 2019. This example only works in dBASE 10 and 11. I haven't
been able to figure out why this won't work in dBASE 12 or 2019 but it
should solve your problem if you are using dBASE 11.
The form metric must be pixels.
Mervyn.
| ** END HEADER -- do not remove this line
//
// Generated on 12/06/2022
//
parameter bModal
local f
f = new accellerator_keyForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class accellerator_keyForm of FORM
with (this)
onOpen = class::FORM_ONOPEN
metric = 6 // Pixels
height = 352.0
left = 116.0
top = 18.0
width = 280.0
text = ""
endwith
this.PUSHBUTTON1 = new PUSHBUTTON(this)
with (this.PUSHBUTTON1)
onClick = class::PUSHBUTTON1_ONCLICK
height = 24.0
left = 79.0
top = 90.0
width = 107.0
text = "Pri&nt"
endwith
this.PUSHBUTTON2 = new PUSHBUTTON(this)
with (this.PUSHBUTTON2)
onClick = class::PUSHBUTTON2_ONCLICK
height = 24.0
left = -200.0
top = 232.0
width = 107.0
text = "&n"
endwith
function PUSHBUTTON1_onClick()
msgbox('Print button clicked')
return
function PUSHBUTTON2_onClick()
//Place form coordinates that will show the cursor over the button into form.point
//This conversion to screen coordinates needs to be done each time the function is executed
//in case the user has moved the form on the screen
form.point.setx(form.pushbutton1.left+50) //make sure cursor is in button
form.point.sety(form.pushbutton1.top+10)
//Convert point values to position on screen.
clienttoscreen(form.hwnd,form.point)
//Get x and y coordinates for pushbutton
form.x_pb = form.point.getx(form.point,0)
form.y_pb = form.point.gety(form.point,4)
form.rmMouse.screenLeftClick(form.x_pb,form.y_pb )
return
function form_onOpen()
if type("ClientToScreen") # "FP"
extern clogical ClientToScreen(chandle,cptr) user32
endif
set procedure to :duflp:rmMouseEvents.cc
form.rmMouse = new rmMouseevents(form)
form.point = new point() // point is a structure to hold the cursor's x and y coordinates
return
endclass
|
|