@@ -17,14 +17,24 @@ public class Program
17
17
[ STAThread ]
18
18
public static int Main ( string [ ] args )
19
19
{
20
+ // DEMO: Change to true to self host the BrowserSubprocess.
21
+ // instead of using CefSharp.BrowserSubprocess.exe, your applications exe will be used.
22
+ // In this case CefSharp.WinForms.Example.exe
20
23
const bool selfHostSubProcess = false ;
21
24
22
- Cef . EnableHighDPISupport ( ) ;
23
-
24
- //NOTE: Using a simple sub processes uses your existing application executable to spawn instances of the sub process.
25
- //Features like JSB, EvaluateScriptAsync, custom schemes require the CefSharp.BrowserSubprocess to function
26
25
if ( selfHostSubProcess )
27
26
{
27
+ var processType = CefSharp . Internals . CommandLineArgsParser . GetArgumentValue ( args , CefSharp . Internals . CefSharpArguments . SubProcessTypeArgument ) ;
28
+
29
+ if ( processType == "gpu-process" )
30
+ {
31
+ // Enable DPI Awareness for GPU process.
32
+ // Our main application is already DPI aware using WinForms specific features
33
+ // **IMPORTANT** There's a mistake in the following doc https://github.com/dotnet/docs-desktop/issues/1485
34
+ // https://docs.microsoft.com/en-us/dotnet/desktop/winforms/high-dpi-support-in-windows-forms
35
+ Cef . EnableHighDPISupport ( ) ;
36
+ }
37
+
28
38
var exitCode = CefSharp . BrowserSubprocess . SelfHost . Main ( args ) ;
29
39
30
40
if ( exitCode >= 0 )
@@ -45,6 +55,7 @@ public static int Main(string[] args)
45
55
46
56
Cef . Initialize ( settings ) ;
47
57
58
+ Application . EnableVisualStyles ( ) ;
48
59
var browser = new SimpleBrowserForm ( ) ;
49
60
Application . Run ( browser ) ;
50
61
}
@@ -58,11 +69,14 @@ public static int Main(string[] args)
58
69
}
59
70
#endif
60
71
61
- //When multiThreadedMessageLoop = true then externalMessagePump must be set to false
62
- // To enable externalMessagePump set multiThreadedMessageLoop = false and externalMessagePump = true
72
+ // DEMO: To integrate CEF into your applications existing message loop
73
+ // set multiThreadedMessageLoop = false;
63
74
const bool multiThreadedMessageLoop = true ;
75
+ // When multiThreadedMessageLoop = true then externalMessagePump must be set to false
76
+ // To enable externalMessagePump set multiThreadedMessageLoop = false and externalMessagePump = true
64
77
const bool externalMessagePump = false ;
65
78
79
+ //TEST: There are a number of different Forms for testing purposes.
66
80
var browser = new BrowserForm ( multiThreadedMessageLoop ) ;
67
81
//var browser = new SimpleBrowserForm(multiThreadedMessageLoop);
68
82
//var browser = new TabulationDemoForm();
@@ -95,6 +109,7 @@ public static int Main(string[] args)
95
109
96
110
CefExample . Init ( settings , browserProcessHandler : browserProcessHandler ) ;
97
111
112
+ Application . EnableVisualStyles ( ) ;
98
113
//Application.Run(new MultiFormAppContext());
99
114
Application . Run ( browser ) ;
100
115
}
0 commit comments