Solved

Printing crviewer control by pressing one key only

Posted on 2003-11-02
8
470 Views
Last Modified: 2008-01-09
Hi, I have a form (frmReport) which has one control on it (crvReport).

What I would like is when you press the "/" (Asc(47)) button the form must close and when pressing the "*" (Asc(42))  button the form must print and close.

The trouble is there is no keyboard event for the crviewer control.

What can I try?

TIA
0
Comment
Question by:jinxster
  • 3
  • 2
8 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 9668698
Nothing in CR that I am aware of since it cannot respond to a keypress event.

I wonder if you could put a timer on the form and have it check for a keypress through Windows API calls.  I don't know how to do it but it might be possible.

mlmcc

0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9670532
?

If you set keypreview to true on the form, you should get the form's key_press event.
Am I missing something?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9671054
Eddy - The Crystal control only exposes the click events.

mlmcc
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Accepted Solution

by:
jinxster earned 0 total points
ID: 9672002
Hi, Eddy, the keypreview property means that if controls on the form have a key(press, up, down) but nothing is inside, the form's key(press, up, down) prevails.

I found a work around, (without using API)

Basically, it goes like this:

Add a textbox on the form and make sure it is behind the crviewer control.
Write the necessary code in the key_press, key_down, key_up events of the textbox.
In the viewchanged AND gotfocus event of the crviewer control add: textbox.SetFocus

The events should work. This also works nicely to make page up and page down scroll through pages home goto first page, end goto last, etc.

Thanks.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 10170900
PAQ.  no refund unless he responds
0
 

Author Comment

by:jinxster
ID: 10176313
I gave my own solution so I do not feel anyone really earned any points, sorry.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now