KeyDown Event

This event is fired when a key is pressed. The parameters do not provide information about which other keys are pressed, like SHIFT, CTRL, ALT, MENU or WINDOWS keys. The state of these other keys can only be retrieved by the event handlers using the API GetKeyState() in C++ or by similar C# or VB calls.

 

Event Arguments

key

This contains the virtual key code for the key that is pressed or released.

lParam

This contains the same value that is sent by the WM_KEYDOWN or WM_KEYUP windows messages.

continue

Setting this parameter to False (-1 or 0) prevents the default handling.

 

Example

Public Class Form1
    Friend WithEvents AxPDFCreactiveX1 As AxACPDFCREACTIVEX.AxPDFCreactiveX = New AxACPDFCREACTIVEX.AxPDFCreactiveX()
 
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Size = New System.Drawing.Size(400, 500)
 
        ' AxPDFCreactiveX1
        AxPDFCreactiveX1.Enabled = True
        AxPDFCreactiveX1.Location = New System.Drawing.Point(20, 20)
        AxPDFCreactiveX1.Name = "AxPDFCreactiveX1"
        AxPDFCreactiveX1.Parent = Me
        AxPDFCreactiveX1.Size = New System.Drawing.Size(360, 400)
        AxPDFCreactiveX1.TabIndex = 0
 
        ' Constants for Activation codes
        Const strLicenseTo As String = "Amyuni PDF Creator Evaluation"
        Const strActivationCode As String = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC"
 
        ' Set license key
        AxPDFCreactiveX1.SetLicenseKey(strLicenseTo, strActivationCode)
 
        ' Change the PDF object to Design Mode
        AxPDFCreactiveX1.ReportState = ACPDFCREACTIVEX.ReportStateConstants.acReportStateDesign
 
        ' Set CurrentPage
        pdf.CurrentPage = 1
 
        ' Create a Text in the current Page
        AxPDFCreactiveX1.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text1")
        Dim oText As ACPDFCREACTIVEX.IacObject = AxPDFCreactiveX1.GetObjectByName("Text1")
        oText("Left") = 1000
        oText("Right") = 5000
        oText("Top") = 0
        oText("Bottom") = 4000
        oText("BorderColor") = &HFF00FF
        oText("BorderWidth") = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthDouble
        oText("Text") = "Amyuni Technologies"
        oText("Hyperlink") = "http:// www.amyuni.com"
 
        ' Create a Barcode in the current Page
        AxPDFCreactiveX1.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeBarcode, "Barcode1")
        Dim oBarCode As ACPDFCREACTIVEX.IacObject = AxPDFCreactiveX1.GetObjectByName("Barcode1")
        oBarCode("Left") = 100
        oBarCode("Right") = 3100
        oBarCode("Top") = 1000
        oBarCode("Bottom") = 2100
        oBarCode("BarcodeType") = 1  ' PDF417 barcodes are the only type supported
        oBarCode("VerticalScale") = 3.0  ' Amount by which To scale the barcode vertically, Default
        oBarCode("Text") = "Copyright 2015 Amyuni Technologies"
 
        ' Change the PDF object to Run Mode
        AxPDFCreactiveX1.ReportState = ACPDFCREACTIVEX.ReportStateConstants.acReportStateRun
 
 
        oBarCode = Nothing
    End Sub
 
    Private Sub AxPDFCreactiveX1_KeyDownEvent(sender As Object, e As AxACPDFCREACTIVEX._IPDFCreactiveXEvents_KeyDownEvent) Handles AxPDFCreactiveX1.KeyDownEvent
        MessageBox.Show("KeyDown event")
        e.continue = 1
    End Sub
End Class
public partial class Form1 : Form
{
    AxACPDFCREACTIVEX.AxPDFCreactiveX axPDFCreactiveX1 = new AxACPDFCREACTIVEX.AxPDFCreactiveX();
 
    public Form1()
    {
        InitializeComponent();
    }
 
    private void Form1_Load(object sender, EventArgs e)
    {
        this.Size = new System.Drawing.Size(400, 500);
 
        // axPDFCreactiveX1
        axPDFCreactiveX1.Enabled = true;
        axPDFCreactiveX1.Location = new System.Drawing.Point(20, 20);
        axPDFCreactiveX1.Name = "axPDFCreactiveX1";
        axPDFCreactiveX1.Parent = this;
        axPDFCreactiveX1.Size = new System.Drawing.Size(360, 400);
        axPDFCreactiveX1.TabIndex = 0;
 
        // Events
        axPDFCreactiveX1.KeyDownEvent += new AxACPDFCREACTIVEX._IPDFCreactiveXEvents_KeyDownEventHandler(axPDFCreactiveX1_KeyDownEvent);
 
        // Constants for Activation codes
        const string strLicenseTo = "Amyuni PDF Creator Evaluation";
        const string strActivationCode = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC";
 
        // Set license key
        axPDFCreactiveX1.SetLicenseKey(strLicenseTo, strActivationCode);
 
        // Change the PDF object to Design Mode
        axPDFCreactiveX1.ReportState = ACPDFCREACTIVEX.ReportStateConstants.acReportStateDesign;
 
        // Set CurrentPage
        pdf.CurrentPage = 1;
 
        // Create a Text in the current Page
        axPDFCreactiveX1.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text1");
        ACPDFCREACTIVEX.IacObject oText = axPDFCreactiveX1.GetObjectByName("Text1".ToString());
        oText["Left"] = 1000;
        oText["Right"] = 5000;
        oText["Top"] = 0;
        oText["Bottom"] = 4000;
        oText["BorderColor"] = 0xFF00FF;
        oText["BorderWidth"] = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthDouble;
        oText["Text"] = "Amyuni Technologies";
 
        // Create a Barcode in the current Page
        axPDFCreactiveX1.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeBarcode, "Barcode1");
        ACPDFCREACTIVEX.IacObject oBarCode = axPDFCreactiveX1.GetObjectByName("Barcode1".ToString());
        oBarCode["Left"] = 100;
        oBarCode["Right"] = 3100;
        oBarCode["Top"] = 1000;
        oBarCode["Bottom"] = 2100;
        oBarCode["BarcodeType"] = 1;  // PDF417 barcodes are the only type supported
        oBarCode["VerticalScale"] = 3.0;  // Amount by which to scale the barcode vertically, default
        oBarCode["Text"] = "Copyright 2015 Amyuni Technologies";
 
        // Change the PDF object to Run Mode
        axPDFCreactiveX1.ReportState = ACPDFCREACTIVEX.ReportStateConstants.acReportStateRun;
 
 
        oBarCode = null;
    }
 
    private void axPDFCreactiveX1_KeyDownEvent(object sender, AxACPDFCREACTIVEX._IPDFCreactiveXEvents_KeyDownEvent e)
    {
        MessageBox.Show("KeyDown event");
        e.@continue = 1;
    }
}
#import "c:\users\amyuni\pdfcreactivex.dll" no_namespace
 
using namespace std;
 
void CRedrawRect_CppDlg::OnBnClickedOk()
{
    IPDFCreactiveXPtr m_PDF;
 
    // TODO: Add extra initialization here
    m_PDF = GetDlgItem(IDC_PDFCREACTIVEX1)->GetControlUnknown();
 
    // Constants for Activation codes
    bstr_t strLicenseTo = "Amyuni PDF Creator Evaluation";
    bstr_t strActivationCode = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC";
 
    // set license key
    m_PDF->SetLicenseKey(_bstr_t(strLicenseTo), _bstr_t(strActivationCode));
 
    // Change the PDF object to Design Mode
    m_PDF->ReportState = acReportStateDesign;
 
    // Set CurrentPage
    pdf->CurrentPage = 1;
 
    // Set-up variables for attributes
    _variant_t varAttribute;
    varAttribute.vt = VT_I4;  // integers
 
    // Create a text in the current Page
    m_PDF->CreateObject(acObjectTypeText, "Text1");
    IacObjectPtr oText = m_PDF->GetObjectByName("Text1");
    oText->Attribute["Left"] = 1000;
    oText->Attribute["Right"] = 5000;
    oText->Attribute["Top"] = 0;
    oText->Attribute["Bottom"] = 4000;
    varAttribute.lVal = 0xFF00FF;
    oText->Attribute["BorderColor"] = varAttribute;
    varAttribute.lVal = acBorderWidthDouble;
    oText->Attribute["BorderWidth"] = varAttribute;
    oText->Attribute["Text"] = "Amyuni Technologies";
 
    // Create a Barcode in the current Page
    m_PDF->CreateObject(acObjectTypeBarcode, "Barcode1");
    IacObjectPtr oBarcode = m_PDF->GetObjectByName("Barcode1");
    oBarcode->Attribute["Left"] = 100;
    oBarcode->Attribute["Right"] = 3100;
    oBarcode->Attribute["Top"] = 1000;
    oBarcode->Attribute["Bottom"] = 2100;
    varAttribute.lVal = 1;
    oBarcode->Attribute["BarcodeType"] = varAttribute;  // PDF417 barcodes are the only type supported
    oBarcode->Attribute["VerticalScale"] = 3.0;  // Amount by which to scale the barcode vertically, default
    oBarcode->Attribute["Text"] = "Copyright 2015 Amyuni Technologies";
 
    // Change the PDF object to Designe Run
    m_PDF->ReportState = acReportStateRun;
 
    // destroy objects
    oText = NULL;
    oBarcode = NULL;
}
 
BEGIN_EVENTSINK_MAP(CRedrawRect_CppDlg, CDialogEx)
    ON_EVENT(CRedrawRect_CppDlg, IDC_PDFCREACTIVEX1, 19, CRedrawRect_CppDlg::KeyDownPdfcreactivex1, VTS_I4 VTS_I4 VTS_PI4)
END_EVENTSINK_MAP()
 
void CRedrawRect_CppDlg::KeyDownPdfcreactivex1(long key, long lParam, long* Continue)
{
    MessageBox(_T("KeyDown event"), _T(""), MB_YESNO);
    *Continue = 1l;
}