mirror of
https://github.com/raylib-cs/raylib-cs
synced 2025-09-09 03:01:41 -04:00
Setup basic class to test with windows forms
- Added DrawControl class to test windows forms with raylib. Need a way to get the window handle?
This commit is contained in:
38
ExampleApplication/Raylib-cs/DrawControl.cs
Normal file
38
ExampleApplication/Raylib-cs/DrawControl.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Raylib
|
||||
{
|
||||
class DrawControl : Form
|
||||
{
|
||||
private Panel panel;
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr SetParent(IntPtr child, IntPtr newParent);
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr ShowWindow(IntPtr handle, int command);
|
||||
|
||||
public static void Run()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new DrawControl());
|
||||
}
|
||||
|
||||
public DrawControl()
|
||||
{
|
||||
panel = new Panel();
|
||||
panel.Size = new Size(640, 480);
|
||||
panel.Location = new Point(80, 10);
|
||||
panel.BackColor = System.Drawing.Color.Red;
|
||||
Controls.Add(panel);
|
||||
|
||||
// TODO: get raylib window handle?
|
||||
IntPtr winHandle = IntPtr.Zero;
|
||||
SetParent(winHandle, panel.Handle);
|
||||
ShowWindow(winHandle, 1);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user