File tree Expand file tree Collapse file tree 3 files changed +31
-2
lines changed
CefSharp.WinForms/Internals Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 66using System . Drawing ;
77using System . Runtime . InteropServices ;
88using System . Windows . Forms ;
9+ using CefSharp . Internals ;
910
1011namespace CefSharp . WinForms . Internals
1112{
@@ -149,8 +150,14 @@ protected override void WndProc(ref Message m)
149150 }
150151 case NativeMethods . WM_MOVE :
151152 {
152- x = ( m . LParam . ToInt32 ( ) & 0xffff ) ;
153- y = ( ( m . LParam . ToInt32 ( ) >> 16 ) & 0xffff ) ;
153+ // Convert IntPtr into 32bit int safely without
154+ // exceptions:
155+ int dwLParam = m . LParam . CastToInt32 ( ) ;
156+
157+ // Extract coordinates from lo/hi word:
158+ x = dwLParam & 0xffff ;
159+ y = ( dwLParam >> 16 ) & 0xffff ;
160+
154161 isMovingMessage = true ;
155162 break ;
156163 }
Original file line number Diff line number Diff line change 9292 <Compile Include =" CefFileDialogMode.cs" />
9393 <Compile Include =" DefaultResourceHandlerFactory.cs" />
9494 <Compile Include =" IJavascriptCallback.cs" />
95+ <Compile Include =" Internals\IntPtrExtensions.cs" />
9596 <Compile Include =" Internals\JavascriptCallbackProxy.cs" />
9697 <Compile Include =" Internals\JavascriptCallback.cs" />
9798 <Compile Include =" Internals\JavascriptCallbackEndpointBehavior.cs" />
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Linq ;
4+ using System . Text ;
5+
6+ namespace CefSharp . Internals
7+ {
8+ public static class IntPtrExtensions
9+ {
10+ /// <summary>
11+ /// Do an unchecked conversion from IntPtr to int
12+ /// so overflow exceptions don't get thrown.
13+ /// </summary>
14+ /// <param name="intPtr"></param>
15+ /// <returns></returns>
16+ public static int CastToInt32 ( this IntPtr intPtr )
17+ {
18+ return unchecked ( ( int ) intPtr . ToInt64 ( ) ) ;
19+ }
20+ }
21+ }
You can’t perform that action at this time.
0 commit comments