Prod.: Engine, ver.: 6, ID: 60000975, HowTo : How can I change the mouse cursor or hide it

HowTo : How can I change the mouse cursor or hide it

Article60000975
TypeHowTo
ProductEngine
Version6
Date Added10/12/2009
Submitted byEsen Karaduman
Keywords

Subject

How can I change the mouse cursor or hide it

Summary

How can I change the mouse cursor or hide it ?

Solution

You can change the cursor to whatever Cursor (in the code below changed to Cursors.PanNW) using SetCustomMousePointer method. In order to Hide the cursor you need to use the property ShowCursor and the vdMouseEnter event.
 
 
See the code :

private void Form1_Load(object sender, EventArgs e)
{
    vdFramedControl1.BaseControl.vdMouseEnter +=
new VectorDraw.Professional.Control.MouseEnterEventHandler(BaseControl_vdMouseEnter);
}

private bool show_pointer = true; // a flag in the form that controls if the cursor will be visible or not.

void BaseControl_vdMouseEnter(EventArgs e, ref bool cancel)
{
    if (show_pointer) return; // show the cursor
        //else hide the cursor with the code below
    cancel =
true;
    vdFramedControl1.BaseControl.ActiveDocument.GlobalRenderProperties.ShowCursor =
false; //Hide cursor
    vdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.MouseEnter(this, e); // this is needed
}

private void button7_Click(object sender, EventArgs e) // Button to set the cursor to another cursor
{
    vdFramedControl1.BaseControl.SetCustomMousePointer(
Cursors.PanNW); // set the cursor to another cursor
    //using GetCustomeMousePointer you can get the cursor.
}

private void button8_Click(object sender, EventArgs e) //Button to set the cursor to default VDF cross
{
    vdFramedControl1.BaseControl.SetCustomMousePointer(
null); // set the cursor to VDF cross
}

private void button9_Click(object sender, EventArgs e)//Button to Hide the cursor
{
show_pointer =
false;
vdFramedControl1.BaseControl.ActiveDocument.GlobalRenderProperties.ShowCursor=
false; //Hide cursor
}

private void button10_Click(object sender, EventArgs e) //Button to show the cursor
{
    show_pointer =
true;
    vdFramedControl1.BaseControl.ActiveDocument.GlobalRenderProperties.ShowCursor=
true; //Show cursor
}

 
 
Another way to hide the cursor, is to change it to an "empty"/"transparent" cursor that you will add to your project resources. In this case you will not need the vdMouseEnter event and the global flag and your code should be :

private void button9_Click(object sender, EventArgs e)
{
    vdFramedControl1.BaseControl.SetCustomMousePointer(
new Cursor(WindowsApplication1.Properties.Resources.Icon1.Handle)); // set the cursor to an "empty/transparent" cursor Icon1.
}

private void button10_Click(object sender, EventArgs e)
{
    vdFramedControl1.BaseControl.SetCustomMousePointer(
null); // set it to the default (visible)
}