Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FreeRDP/GdiTest.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Moreau <marcandre.moreau@gmail.com>2011-03-26 03:39:40 +0300
committerMarc-André Moreau <marcandre.moreau@gmail.com>2011-03-26 03:39:40 +0300
commit0a707ce087ade3e2ff54d64ee038af72d3de955e (patch)
tree1ff9e67be1cf41c2bab84dcf342155eaf32cccc1
parent547f19bdfc234390a07269b83f4c1fb859ee0260 (diff)
Wrapping native gdi32.dll calls in a wrapper class
-rw-r--r--GdiTest/BitBltDrawingArea.cs21
-rw-r--r--GdiTest/Gdi32.cs59
-rw-r--r--GdiTest/GdiTest.csproj1
-rw-r--r--GdiTest/Main.cs1
4 files changed, 64 insertions, 18 deletions
diff --git a/GdiTest/BitBltDrawingArea.cs b/GdiTest/BitBltDrawingArea.cs
index a5b8dab..3e7c4ec 100644
--- a/GdiTest/BitBltDrawingArea.cs
+++ b/GdiTest/BitBltDrawingArea.cs
@@ -2,26 +2,11 @@ using Gtk;
using Cairo;
using System;
using System.Drawing;
-using System.Runtime.InteropServices;
namespace GdiTest
{
public class BitBltDrawingArea : DrawingArea
- {
- [System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
-
- private static extern int BitBlt(
- IntPtr hdcDest,
- int nXDest,
- int nYDest,
- int nWidth,
- int nHeight,
- IntPtr hdcSrc,
- int nXSrc,
- int nYSrc,
- System.Int32 dwRop
- );
-
+ {
public BitBltDrawingArea ()
{
}
@@ -47,11 +32,11 @@ namespace GdiTest
cg.MoveTo (10, 10);
cg.LineTo (110, 110);
cg.Stroke ();
-
+
System.Drawing.Graphics wg = Gtk.DotNet.Graphics.FromDrawable(this.GdkWindow, true);
IntPtr dc = wg.GetHdc();
- BitBlt(dc, 70, 0, 60, 60, dc, 0, 0, 0xCC0020);
+ Gdi32._BitBlt(dc, 70, 0, 60, 60, dc, 0, 0, 0xCC0020);
}
return true;
}
diff --git a/GdiTest/Gdi32.cs b/GdiTest/Gdi32.cs
new file mode 100644
index 0000000..74d822d
--- /dev/null
+++ b/GdiTest/Gdi32.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace GdiTest
+{
+ public class Gdi32
+ {
+ [DllImport("gdi32.dll")]
+
+ private static extern int BitBlt(
+ IntPtr hdcDest,
+ int nXDest,
+ int nYDest,
+ int nWidth,
+ int nHeight,
+ IntPtr hdcSrc,
+ int nXSrc,
+ int nYSrc,
+ System.Int32 dwRop
+ );
+
+ static bool win32 = false;
+
+ public Gdi32 ()
+ {
+ }
+
+ public static void init()
+ {
+ int p = (int) Environment.OSVersion.Platform;
+
+ if ((p == 4) || (p == 6) || (p == 128)) {
+ win32 = false;
+ } else {
+ win32 = true;
+ }
+ }
+
+ public static void setWin32(bool pWin32)
+ {
+ win32 = pWin32;
+ }
+
+ public static bool getWin32()
+ {
+ return win32;
+ }
+
+ public static int _BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight,
+ IntPtr hdcSrc, int nXSrc, int nYSrc, System.Int32 dwRop)
+ {
+ if (win32)
+ return BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
+ else
+ return -1;
+ }
+ }
+}
+
diff --git a/GdiTest/GdiTest.csproj b/GdiTest/GdiTest.csproj
index fda40e2..b92424e 100644
--- a/GdiTest/GdiTest.csproj
+++ b/GdiTest/GdiTest.csproj
@@ -57,6 +57,7 @@
<Compile Include="AssemblyInfo.cs" />
<Compile Include="LineDrawingArea.cs" />
<Compile Include="BitBltDrawingArea.cs" />
+ <Compile Include="Gdi32.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project> \ No newline at end of file
diff --git a/GdiTest/Main.cs b/GdiTest/Main.cs
index 7e1b01e..a72d184 100644
--- a/GdiTest/Main.cs
+++ b/GdiTest/Main.cs
@@ -8,6 +8,7 @@ namespace GdiTest
{
public static void Main (string[] args)
{
+ Gdi32.init();
Application.Init ();
MainWindow w = new MainWindow ();