Click here to Skip to main content
15,893,594 members

Win8 RDP session freezes using custom cursor

vmp5 asked:

Open original thread
Hi,

I use custom cursors for dragdrop-operations. In remote desktop sessions only if remote machine runs Win8 the session completely freezes, if the cursor exceeds a certain size.
It works fine, if you work on physical Win8 machine or e.g. Xen Console. Also works fine on RDP with other target operating systems (Win7, Server 2008R2...)

I tried to break down the problem to the most simple case.
In the example below Cursors of 32x32 and 64x64 work fine, 200x200 just dont display anything, 500x500 will freeze everything (system hangs).

I debugged and logged everything, hang occurs _after_ code is completed and cursor is returned.

Can anyone give me some advice in which direction to go, as I'm quite clueless meanwhile. Is there another state-of-the-art way meanwhile to manipulate mouse cursors in winforms applications (i use .net 3.5)?

Thanks!

C#
private void button_Click(object sender, EventArgs e)
{
    //will be 32 from firstbutton, 64 from second, 200 from third, 500 from fourth
    int iCursorSizeFromButton = int.Parse((string)(sender as Button).Tag);

    Bitmap bnew = new Bitmap(iCursorSizeFromButton, iCursorSizeFromButton);
    using (Graphics g = Graphics.FromImage(bnew))
    {
        using (Brush b = new SolidBrush(Color.FromArgb(127, Color.LightBlue)))
        {
            g.FillRectangle(b, new Rectangle(0, 0, bnew.Width, bnew.Height)); //make bitmap for simple custom cursor
            g.DrawEllipse(Pens.Black, new Rectangle(bnew.Width / 2 - 2, bnew.Height / 2 - 2, 4, 4)); //show hotspot, to know how to click
        }
        IntPtr Hicon = bnew.GetHicon();
        Cursor c = new Cursor(Hicon);
        this.Cursor = c;

        //we dont call "extern static bool DestroyIcon(IntPtr handle)" for old cursors in this sample, because it's irrelevant for test
    }
}
Tags: C#, .NET (.NET 3.5), Windows, Win8, GDI+, Windows Forms

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900