Share via

Forms Controls and Remote Desktop

Frank Holub 1 Reputation point
2021-05-31T20:22:25.64+00:00

I have a C# Windows Forms App that auto-starts and runs on a headless PC with a single user account. There are a good number of form controls that are either bound to app settings or are set programmatically via Properties.Settings.Default... The form controls are located on a TabPage and the form controls are often used to control various settings & behaviors of the program.
The issue is that when I access the PC via Remote Desktop. The many of controls on the app seem reset to default settings and screw up the functionality. When I hit the settings tabs, then the bound settings seem to "correct" and normal behavior resumes.
I sure I have some kind of fundamental "bad practice" going on here and/or I am missing something. Any suggestions?

Developer technologies | Windows Forms
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.


1 answer

Sort by: Most helpful
  1. Frank Holub 1 Reputation point
    2021-06-01T17:37:40.933+00:00

    I apologize but there are several thousand lines of code that is bound in part by an NDA so there is little specific code I can share. But I can describe in general terms what I am seeing.

    The app reads raw image data from a camera every 20 seconds, processes the image and saves it as a JPEG. The app has approximately 40 application settings which are bound to form control properties (check boxes, sliders, text boxes, etc) that are used to control (among other things) how the image is processed. These form controls are all on a tabpage that is usually not the selected tabpage.

    For example the Form1.Designer.cs has the following auto-generated line to bind the control to the settings...

    this.cbMono.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::AllSkyCam.Properties.Settings.Default, "Mono", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
    

    This "Mono" checkbox informs the image processing code that the camera is a monochrome and not color.

    if(cbMono.checked)
       ConvertMono();
    else
       ConvertColor();
    

    The issue is that when the computer is accessed by Remote Desktop, the controls on the background tabpage seem to revert to "default" states regardless of the Properties.Settings' values. So as far as I can tell, the process of "moving" or "redrawing" the app's form on the Remote Desktop from the "local" desktop does not preserve/update the bindings. So... The above Mono checkbox is unchecked in the "move" to RD and the processing is sent to the wrong routine. However, if I select the "settings" tab, the controls redraw to the correct bound values and the correct routine is used again.

    I guess the real question is, what does the "move" to RD subject a Windows Form App to?

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.