本文整理汇总了C#中Win32类的典型用法代码示例。如果您正苦于以下问题:C# Win32类的具体用法?C# Win32怎么用?C# Win32使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Win32类属于命名空间,在下文中一共展示了Win32类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CaptureWindow
private Tree CaptureWindow(IntPtr hwnd, Win32.WINDOWINFO windowinfo, bool usePrintWindow, bool fixedSize = false)
{
BoundingBox windowRect = new BoundingBox(windowinfo.rcWindow.left, windowinfo.rcWindow.top,
windowinfo.rcWindow.right - windowinfo.rcWindow.left + 1, windowinfo.rcWindow.bottom - windowinfo.rcWindow.top + 1);
var attributes = GetWindowAttributes(hwnd, windowinfo);
if (windowRect.Width > 0 && windowRect.Height > 0)
{
System.Drawing.Bitmap bmp;
int width = windowRect.Width;
int height = windowRect.Height;
if(fixedSize)
{
width = (int)System.Windows.SystemParameters.VirtualScreenWidth;
height = (int)System.Windows.SystemParameters.VirtualScreenHeight;
}
if (!usePrintWindow)
bmp = GetBitmapFromScreen(hwnd, null, width, height);
else
bmp = GetBitmapFromPrintWindow(hwnd, null, width, height);
Tree window = _bitmapToTree.GetScreenshotAndCreateTree(windowRect.Width, windowRect.Height, bmp, attributes);
//_pool.ReturnInstance(bmp);
return window;
}
return null;
}
示例2: ColorOperation
// Methods
public ColorOperation()
{
this.mouseAreaControl = null;
this.translatePath = new GraphicsPath();
this.scalePath = new GraphicsPath();
this.rotatePath = new GraphicsPath();
this.equalPath = new GraphicsPath();
this.skewxPath = new GraphicsPath();
this.skewyPath = new GraphicsPath();
this.anglescalePath = new GraphicsPath();
this.vscalPath = new GraphicsPath();
this.controlPoints = null;
this.reversePath = new GraphicsPath();
this.startPoint = PointF.Empty;
this.win32 = new Win32();
this.ratiomatrix = new Matrix();
this.graphMatrix = new Matrix();
this.selectMatrix = new Matrix();
this.gradientMatrix = new Matrix();
this.gradientPath = new GraphicsPath();
this.gradientheight = 1f;
this.centerPoint = PointF.Empty;
this.gradientstr = string.Empty;
this.colorpickerstr = string.Empty;
this.gradientstr = DrawAreaConfig.GetLabelForName("gradienttransform").Trim();
this.colorpickerstr = DrawAreaConfig.GetLabelForName("colorpicker").Trim();
}
示例3: Monitor
public Monitor(Win32.DISPLAY_DEVICE device, Win32.DEVMODE currentDisplaySettings, List<Win32.DEVMODE> availableDisplaySettings)
{
Device = device;
AvailableDisplaySettings = availableDisplaySettings;
CurrentDisplaySettings = currentDisplaySettings;
IsPrimary = CurrentDisplaySettings.dmPositionX == 0 && CurrentDisplaySettings.dmPositionY == 0;
}
示例4: GetPreferences
bool GetPreferences(string section, out Win32.RECT rect, out long style, out long exStyle)
{
rect = new Win32.RECT();
style = 0;
exStyle = 0;
if (!Preferences.HasSection(section))
{
return false;
}
string[] keys = { "rectLeft", "rectTop", "rectRight", "rectBottom", "style", "exStyle" };
foreach (string key in keys)
{
if (!Preferences[section].HasKey(key))
{
return false;
}
}
if (!int.TryParse(Preferences[section]["rectLeft"].Value, out rect.Left)) { return false; }
if (!int.TryParse(Preferences[section]["rectTop"].Value, out rect.Top)) { return false; }
if (!int.TryParse(Preferences[section]["rectRight"].Value, out rect.Right)) { return false; }
if (!int.TryParse(Preferences[section]["rectBottom"].Value, out rect.Bottom)) { return false; }
if (!long.TryParse(Preferences[section]["style"].Value, out style)) { return false; }
if (!long.TryParse(Preferences[section]["exStyle"].Value, out exStyle)) { return false; }
return true;
}
示例5: GetImageSource
/// <summary>
/// Gets the icon as an <see cref="ImageSource"/> for the specified path.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="info">The shell file info.</param>
/// <returns>The icon as an <see cref="ImageSource"/> for the specified path.</returns>
public static ImageSource GetImageSource(string path, out Win32.SHFILEINFO info)
{
info = new Win32.SHFILEINFO();
int attr;
if (Directory.Exists(path))
attr = (int)Win32.FILE_ATTRIBUTE_DIRECTORY;
else if (File.Exists(path))
attr = (int)Win32.FILE_ATTRIBUTE_NORMAL;
else if (path.Length == 3) // drive not ready
attr = (int)Win32.FILE_ATTRIBUTE_DIRECTORY;
else
return null;
Win32.SHGetFileInfo(path, attr, out info, (uint)Marshal.SizeOf(typeof(Win32.SHFILEINFO)), Win32.SHGFI_DISPLAYNAME | Win32.SHGFI_ICON | Win32.SHGFI_TYPENAME | Win32.SHGFI_SMALLICON | Win32.SHGFI_USEFILEATTRIBUTES);
ImageSource img = null;
if (info.hIcon != IntPtr.Zero)
{
using (Icon icon = Icon.FromHandle(info.hIcon))
{
img = Imaging.CreateBitmapSourceFromHIcon(icon.Handle, new Int32Rect(0, 0, icon.Width, icon.Height), BitmapSizeOptions.FromEmptyOptions());
}
Win32.DestroyIcon(info.hIcon);
}
return img;
}
示例6: ViewOperation
// Methods
public ViewOperation()
{
this.mouseAreaControl = null;
this.startPoint = Point.Empty;
this.oldleft = 0f;
this.oldtop = 0f;
this.reversePath =new GraphicsPath();
this.win32 = new Win32();
}
示例7: Click
public static bool Click(Win32.Point point)
{
if (bshandle == IntPtr.Zero)
bshandle = GetBlueStackWindowHandle();
if (bshandle == IntPtr.Zero)
return false;
MouseHelper.ClickOnPoint(bshandle, point);
return true;
}
示例8: HandleCtrl
static bool HandleCtrl(Win32.CtrlTypes type)
{
var name = Enum.GetName(type.GetType(), type);
Console.WriteLine("\nExiting due to {0} event from system!\n", name);
if (f != null)
f.TerminateBots();
return true;
}
示例9: SetPreferences
bool SetPreferences(string section, Win32.RECT rect, long style, long exStyle)
{
Preferences[section]["rectLeft"].Value = rect.Left.ToString();
Preferences[section]["rectTop"].Value = rect.Top.ToString();
Preferences[section]["rectRight"].Value = rect.Right.ToString();
Preferences[section]["rectBottom"].Value = rect.Bottom.ToString();
Preferences[section]["style"].Value = style.ToString();
Preferences[section]["exStyle"].Value = exStyle.ToString();
return true;
}
示例10: DwmExtendFrameIntoClientArea
public static int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref Win32.MARGINS margins)
{
IntPtr hModule = Win32.LoadLibrary("dwmapi");
if (hModule == IntPtr.Zero)
return 0;
IntPtr procAddress = Win32.GetProcAddress(hModule, "DwmExtendFrameIntoClientArea");
if (procAddress == IntPtr.Zero)
return 0;
else
return ((Win32.DwmExtendFrameIntoClientAreaDelegate) Marshal.GetDelegateForFunctionPointer(procAddress, typeof (Win32.DwmExtendFrameIntoClientAreaDelegate)))(hwnd, ref margins);
}
示例11: EnumWindowByName
private IntPtr EnumWindowByName(Win32.EnumWindowsProc filter)
{
IntPtr WindowHwnd = IntPtr.Zero;
Win32.EnumWindows(delegate(IntPtr hwnd, IntPtr lparam)
{
if (filter(hwnd, lparam))
{
WindowHwnd = hwnd;
return false;
}
return true;
}, IntPtr.Zero);
return WindowHwnd;
}
示例12: EnumChildWindowByName
private IntPtr EnumChildWindowByName(IntPtr parent, Win32.EnumWindowsProc filter)
{
IntPtr WindowHwnd = IntPtr.Zero;
Win32.EnumChildWindows(parent, delegate(IntPtr hwnd, IntPtr lparam)
{
if (filter(hwnd, lparam))
{
WindowHwnd = hwnd;
return false;
}
else
{
EnumChildWindowByName(hwnd, filter);
}
return true;
}, IntPtr.Zero);
return WindowHwnd;
}
示例13: SelectOperation
// Methods
public SelectOperation()
{
this.mouseAreaControl = null;
this.toBeSelectedGraph = null;
this.toBeSelectedPath = null;
this.currentMousePoint = MousePoint.None;
this.reversePath = new GraphicsPath();
this.oriPath = new GraphicsPath();
this.startpoint = PointF.Empty;
this.movePoint = PointF.Empty;
this.selectMatrix = new Matrix();
this.totalmatrix = new Matrix();
this.controlPoint = PointF.Empty;
this.selectAreaPath = new GraphicsPath();
this.win32 = new Win32();
this.AreaPoints = new ArrayList(0x10);
this.ps = new PointF[8];
this.rotateindex = 0;
this.selectCollection = new SvgElementCollection();
this.tooltips = new Hashtable(0x10);
this.rotatepath = new GraphicsPath();
}
示例14: GetWindowAttributes
private Dictionary<string, object> GetWindowAttributes(IntPtr hwnd, Win32.WINDOWINFO windowinfo)
{
Dictionary<string, object> attributes = new Dictionary<string, object>();
attributes["handle"] = hwnd;
ExpensiveWindowInfo expensiveInfo;
if (!_windowInfo.TryGetValue(hwnd, out expensiveInfo))
{
expensiveInfo = new ExpensiveWindowInfo(Win32.GetClassName(hwnd), Win32.GetWindowText(hwnd), Win32.GetProcessPathFromWindowHandle(hwnd));
_windowInfo.Add(hwnd, expensiveInfo);
}
attributes["processfilename"] = expensiveInfo.ProcessFilePath;
attributes["title"] = expensiveInfo.Title;
attributes["classname"] = expensiveInfo.ClassName;
attributes["style"] = windowinfo.dwStyle;
attributes["exstyle"] = windowinfo.dwExStyle;
return attributes;
}
示例15: Hooked
int Hooked(int code, IntPtr wparam, ref Win32.CWPSTRUCT cwp)
{
switch(code) {
case 0:
switch(cwp.message) {
case Win32.WM_CREATE:
string s = string.Empty;
char[] className = new char[10];
int length = Win32.GetClassName( cwp.hwnd, className, 9 );
for( int i = 0; i < length; i++ )
s += className[i];
if( s == "#32768" ) { // System class for menu
defaultWndProc = Win32.SetWindowLong( cwp.hwnd, (-4), subWndProc );
//int old = Win32.GetWindowLong( cwp.hwnd, (-20) );
//Win32.SetWindowLong2( cwp.hwnd, (-20)/*GWL_EXSTYLE=(-20)*/, 0x20/*WS_EX_TRANSPARENT=0x20*/ );
}
break;
}
break;
}
return Win32.CallNextHookEx(hookHandle,code,wparam, ref cwp);
}