本文整理汇总了C#中System.Windows.Interop.HwndSource类的典型用法代码示例。如果您正苦于以下问题:C# HwndSource类的具体用法?C# HwndSource怎么用?C# HwndSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HwndSource类属于System.Windows.Interop命名空间,在下文中一共展示了HwndSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: HorizontalMouseScrollHelper
public HorizontalMouseScrollHelper(ScrollViewer scrollviewer, DependencyObject d)
{
scrollViewer = scrollviewer;
source = (HwndSource)PresentationSource.FromDependencyObject(d);
if (source != null)
source.AddHook(WindowProc);
}
开发者ID:jayhill,项目名称:FluentFilters,代码行数:7,代码来源:HorizontalMouseScrollHelper.cs
示例2: ClipboardListenerBasic
// Constructor
public ClipboardListenerBasic(Window wnd,EventHandler handler=null)
{
WindowListener=wnd;
Source=PresentationSource.FromVisual(wnd) as HwndSource;
ClipboardUpdated=handler;
Listening=false;
}
开发者ID:DP458,项目名称:Clipboard_Watcher,代码行数:8,代码来源:BasicRealization.cs
示例3: Initialize3D
private void Initialize3D()
{
HwndSource hwnd = new HwndSource(0, 0, 0, 0, 0, "D3", IntPtr.Zero);
pp.SwapEffect = SwapEffect.Discard;
pp.DeviceWindowHandle = hwnd.Handle;
pp.Windowed = true;
pp.BackBufferWidth = (int)ActualWidth;
pp.BackBufferHeight = (int)ActualHeight;
pp.BackBufferFormat = Format.X8R8G8B8;
try
{
var direct3DEx = new Direct3DEx();
direct3D = direct3DEx;
device = new DeviceEx(direct3DEx, 0, DeviceType.Hardware, hwnd.Handle, CreateFlags.HardwareVertexProcessing, pp);
}
catch
{
direct3D = new Direct3D();
device = new Device(direct3D, 0, DeviceType.Hardware, hwnd.Handle, CreateFlags.HardwareVertexProcessing, pp);
}
System.Windows.Media.CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);
}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:25,代码来源:DirectXHost.cs
示例4: OnSourceInitialized
protected override void OnSourceInitialized(EventArgs e)
{
_hwndSource = (HwndSource) PresentationSource.FromVisual(this);
_hwndSource?.AddHook(WndProcHook);
UpdateWindowStyle();
base.OnSourceInitialized(e);
}
开发者ID:vebin,项目名称:ModernApplicationFramework,代码行数:7,代码来源:WindowBase.cs
示例5: HotKeyManager
//private Window window;
//stack overflow http://stackoverflow.com/questions/2450373/set-global-hotkeys-using-c-sharp
//private class Window : NativeWindow, IDisposable
//{
// private static int WM_HOTKEY = 0x0312;
// private IHotKeyOwner owner;
// public Window(IHotKeyOwner owner)
// {
// this.owner = owner;
// // create the handle for the window.
// this.CreateHandle(new CreateParams());
// }
// /// <summary>
// /// Overridden to get the notifications.
// /// </summary>
// /// <param name="m"></param>
// protected override void WndProc(ref Message m)
// {
// base.WndProc(ref m);
// // check if we got a hot key pressed.
// if (m.Msg == WM_HOTKEY)
// {
// MessageBox.Show("asdasd");
// // get the keys.
// Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
// ModifierKeys modifier = (ModifierKeys)((int)m.LParam & 0xFFFF);
// owner.HotKeyPressed(0);
// }
// }
// #region IDisposable Members
// public void Dispose()
// {
// this.DestroyHandle();
// }
// #endregion
//}
public HotKeyManager(IHotKeyOwner owner, IntPtr handle)
{
this.owner = owner;
this.hook = new HwndSourceHook(WndProc);
this.hwndsource = HwndSource.FromHwnd(handle);
hwndsource.AddHook(hook);
}
开发者ID:allisharp,项目名称:as_autoclicker,代码行数:43,代码来源:HotKeyManager.cs
示例6: Start
private void Start()
{
if (hwndSource != null)
return;
var window = Application.Current.Windows[0];
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() =>
{
if (!window.IsInitialized)
window.SourceInitialized += (sender, args) =>
{
hwndSource = HwndSource.FromHwnd(new WindowInteropHelper(window).Handle);
hwndSource.AddHook(WndProc);
};
else
{
hwndSource = HwndSource.FromHwnd(new WindowInteropHelper(window).Handle);
hwndSource.AddHook(WndProc);
}
}));
}
开发者ID:heinzsack,项目名称:DEV,代码行数:26,代码来源:DeviceChangeDetector.cs
示例7: ClipboardWatcher
/// <summary>
/// ClipBoardWatcherクラスを初期化して
/// クリップボードビューアチェインに登録します。
/// 使用後は必ずDispose()メソッドを呼び出して下さい。
/// </summary>
public ClipboardWatcher(IntPtr handle)
{
this.hwndSource = HwndSource.FromHwnd(handle);
this.hwndSource.AddHook(this.WndProc);
this.handle = handle;
this.nextHandle = SetClipboardViewer(this.handle);
}
开发者ID:yasumo,项目名称:ClipBoardReplacer,代码行数:12,代码来源:ClipboardWatcher.cs
示例8: HwndStylusInputProvider
internal HwndStylusInputProvider(HwndSource source)
{
InputManager inputManager = InputManager.Current;
StylusLogic stylusLogic = inputManager.StylusLogic;
IntPtr sourceHandle;
(new UIPermission(PermissionState.Unrestricted)).Assert();
try //Blessed Assert this is for RegisterInputManager and RegisterHwndforinput
{
// Register ourselves as an input provider with the input manager.
_site = new SecurityCriticalDataClass<InputProviderSite>(inputManager.RegisterInputProvider(this));
sourceHandle = source.Handle;
}
finally
{
UIPermission.RevertAssert();
}
stylusLogic.RegisterHwndForInput(inputManager, source);
_source = new SecurityCriticalDataClass<HwndSource>(source);
_stylusLogic = new SecurityCriticalDataClass<StylusLogic>(stylusLogic);
// Enables multi-touch input
UnsafeNativeMethods.SetProp(new HandleRef(this, sourceHandle), "MicrosoftTabletPenServiceProperty", new HandleRef(null, new IntPtr(MultiTouchEnabledFlag)));
}
开发者ID:JianwenSun,项目名称:cc,代码行数:27,代码来源:HwndStylusInputProvider.cs
示例9: Recorder
public Recorder(string fileName,
FourCC codec, int quality,
int audioSourceIndex, SupportedWaveFormat audioWaveFormat, bool encodeAudio, int audioBitRate)
{
System.Windows.Media.Matrix toDevice;
using (var source = new HwndSource(new HwndSourceParameters()))
{
toDevice = source.CompositionTarget.TransformToDevice;
}
screenWidth = (int)Math.Round(SystemParameters.PrimaryScreenWidth * toDevice.M11);
screenHeight = (int)Math.Round(SystemParameters.PrimaryScreenHeight * toDevice.M22);
// Create AVI writer and specify FPS
writer = new AviWriter(fileName)
{
FramesPerSecond = 10,
EmitIndex1 = true,
};
// Create video stream
videoStream = CreateVideoStream(codec, quality);
// Set only name. Other properties were when creating stream,
// either explicitly by arguments or implicitly by the encoder used
videoStream.Name = "Screencast";
if (audioSourceIndex >= 0)
{
var waveFormat = ToWaveFormat(audioWaveFormat);
audioStream = CreateAudioStream(waveFormat, encodeAudio, audioBitRate);
// Set only name. Other properties were when creating stream,
// either explicitly by arguments or implicitly by the encoder used
audioStream.Name = "Voice";
audioSource = new WaveInEvent
{
DeviceNumber = audioSourceIndex,
WaveFormat = waveFormat,
// Buffer size to store duration of 1 frame
BufferMilliseconds = (int)Math.Ceiling(1000 / writer.FramesPerSecond),
NumberOfBuffers = 3,
};
audioSource.DataAvailable += audioSource_DataAvailable;
}
screenThread = new Thread(RecordScreen)
{
Name = typeof(Recorder).Name + ".RecordScreen",
IsBackground = true
};
if (audioSource != null)
{
videoFrameWritten.Set();
audioBlockWritten.Reset();
audioSource.StartRecording();
}
screenThread.Start();
}
开发者ID:bobahml,项目名称:SharpAvi,代码行数:60,代码来源:Recorder.cs
示例10: Show
public void Show(Int32Rect rpRect)
{
var rMainWindowHandle = new WindowInteropHelper(App.Current.MainWindow).Handle;
if (r_HwndSource == null)
{
var rParam = new HwndSourceParameters(nameof(ScreenshotToolOverlayWindow))
{
Width = 0,
Height = 0,
PositionX = 0,
PositionY = 0,
WindowStyle = 0,
UsesPerPixelOpacity = true,
HwndSourceHook = WndProc,
ParentWindow = rMainWindowHandle,
};
r_HwndSource = new HwndSource(rParam) { SizeToContent = SizeToContent.Manual, RootVisual = this };
}
var rBrowserWindowHandle = ServiceManager.GetService<IBrowserService>().Handle;
NativeStructs.RECT rBrowserWindowRect;
NativeMethods.User32.GetWindowRect(rBrowserWindowHandle, out rBrowserWindowRect);
var rHorizontalRatio = rBrowserWindowRect.Width / GameConstants.GameWidth;
var rVerticalRatio = rBrowserWindowRect.Height / GameConstants.GameHeight;
rpRect.X = (int)(rpRect.X * rHorizontalRatio);
rpRect.Y = (int)(rpRect.Y * rVerticalRatio);
rpRect.Width = (int)(rpRect.Width * rHorizontalRatio);
rpRect.Height = (int)(rpRect.Height * rVerticalRatio);
NativeMethods.User32.SetWindowPos(r_HwndSource.Handle, IntPtr.Zero, rBrowserWindowRect.Left + rpRect.X, rBrowserWindowRect.Top + rpRect.Y, rpRect.Width, rpRect.Height, NativeEnums.SetWindowPosition.SWP_NOZORDER | NativeEnums.SetWindowPosition.SWP_NOACTIVATE | NativeEnums.SetWindowPosition.SWP_SHOWWINDOW);
}
开发者ID:amatukaze,项目名称:IntelligentNavalGun,代码行数:35,代码来源:ScreenshotToolOverlayWindow.cs
示例11: OnLoaded
protected void OnLoaded(object sender, EventArgs e)
{
WindowInteropHelper helper = new WindowInteropHelper(this);
_hwndSource = HwndSource.FromHwnd(helper.Handle);
_wndProcHandler = new HwndSourceHook(HookHandler);
_hwndSource.AddHook(_wndProcHandler);
}
开发者ID:vebin,项目名称:PhotoBrushProject,代码行数:7,代码来源:FloatingWindow.xaml.cs
示例12: HotKeyManager
/// <summary>
/// Initializes a new instance of the <see cref="HotKeyManager"/> class.
/// </summary>
public HotKeyManager()
{
_windowHandleSource = new HwndSource(new HwndSourceParameters());
_windowHandleSource.AddHook(messagesHandler);
_registered = new Dictionary<HotKey, int>();
}
开发者ID:kirmir,项目名称:GlobalHotKey,代码行数:10,代码来源:HotKeyManager.cs
示例13: StartListeningToClipboard
private void StartListeningToClipboard()
{
var lWindowInteropHelper = new WindowInteropHelper(this);
_HWndSource = HwndSource.FromHwnd(lWindowInteropHelper.Handle);
_HWndSource.AddHook(WinProc);
_HWndNextViewer = SetClipboardViewer(_HWndSource.Handle); // set this window as a viewer
} //
开发者ID:huoxudong125,项目名称:HQF.Tutorial.WPF,代码行数:7,代码来源:MainWindow.xaml.cs
示例14: HotkeyManager
public HotkeyManager(Window window)
{
source = (HwndSource)PresentationSource.FromVisual(window);
hook = new HwndSourceHook(WndProc);
source.AddHook(hook);
ids = new List<int>();
}
开发者ID:alexhorn,项目名称:BrightnessControl,代码行数:7,代码来源:HotkeyManager.cs
示例15: ShadowedWindow_OnLoaded
private void ShadowedWindow_OnLoaded(object sender, RoutedEventArgs e)
{
hwndSource = PresentationSource.FromVisual((Visual) sender) as HwndSource;
if (hwndSource != null)
hwndSource.AddHook(WndProc);
}
开发者ID:maxschmeling,项目名称:flamecage,代码行数:7,代码来源:ShadowedWindow.cs
示例16: App_OnStartup
private void App_OnStartup(object sender, StartupEventArgs e)
{
var mode = e.Args.Any() ? e.Args[0] : "/s";
// Preview mode--display in little window in Screen Saver dialog
// (Not invoked with Preview button, which runs Screen Saver in
// normal /s mode).
if (mode.ToLower().StartsWith("/p"))
{
m_winSaver = new MainWindow();
Int32 previewHandle = Convert.ToInt32(e.Args[1]);
//WindowInteropHelper interopWin1 = new WindowInteropHelper(win);
//interopWin1.Owner = new IntPtr(previewHandle);
var pPreviewHnd = new IntPtr(previewHandle);
var lpRect = new RECT();
Win32API.GetClientRect(pPreviewHnd, ref lpRect);
var sourceParams = new HwndSourceParameters("sourceParams")
{
PositionX = 0,
PositionY = 0,
Height = lpRect.Bottom - lpRect.Top,
Width = lpRect.Right - lpRect.Left,
ParentWindow = pPreviewHnd,
WindowStyle = (int)(WindowStyles.WS_VISIBLE | WindowStyles.WS_CHILD | WindowStyles.WS_CLIPCHILDREN)
};
m_winWpfContent = new HwndSource(sourceParams);
m_winWpfContent.Disposed += winWPFContent_Disposed;
m_winWpfContent.RootVisual = m_winSaver.Grid;
// ReSharper disable once CSharpWarnings::CS4014
m_winSaver.StartAnimation();
}
// Normal screensaver mode. Either screen saver kicked in normally,
// or was launched from Preview button
else if (mode.ToLower().StartsWith("/s"))
{
var win = new MainWindow { WindowState = WindowState.Maximized };
win.Show();
}
// Config mode, launched from Settings button in screen saver dialog
else if (mode.ToLower().StartsWith("/c"))
{
var win = new SettingsWindow();
win.Show();
}
// If not running in one of the sanctioned modes, shut down the app
// immediately (because we don't have a GUI).
else
{
Current.Shutdown();
}
}
开发者ID:EdwardSalter,项目名称:NCubeSolver,代码行数:59,代码来源:App.xaml.cs
示例17: InitCBViewer
private void InitCBViewer()
{
WindowInteropHelper wih = new WindowInteropHelper(this);
hWndSource = HwndSource.FromHwnd(wih.Handle);
hWndSource.AddHook(this.WndProc); // start processing window messages
hWndNextViewer = Win32.SetClipboardViewer(hWndSource.Handle); // set this window as a viewer
}
开发者ID:CharlesLiyh,项目名称:MakeItStar,代码行数:8,代码来源:MainWindow.xaml.cs
示例18: OnSourceInitialized
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
var helper = new WindowInteropHelper(this);
_source = HwndSource.FromHwnd(helper.Handle);
_source.AddHook(HwndHook);
RegisterHotKey();
}
开发者ID:markashleybell,项目名称:openthings,代码行数:8,代码来源:MainWindow.xaml.cs
示例19: OnSourceDisconnected
protected override sealed void OnSourceDisconnected(HwndSource disconnectedSource)
{
var window = disconnectedSource.RootVisual as Window;
if (window != null)
{
OnWindowDisconnected(window);
}
}
开发者ID:Kryptos-FR,项目名称:hwnd-adorner,代码行数:8,代码来源:WindowConnector.cs
示例20: SetCompositionFont
public static bool SetCompositionFont(HwndSource source, IntPtr hIMC, TextArea textArea)
{
if (textArea == null)
throw new ArgumentNullException("textArea");
// LOGFONT font = new LOGFONT();
// ImmGetCompositionFont(hIMC, out font);
return false;
}
开发者ID:joazlazer,项目名称:ModdingStudio,代码行数:8,代码来源:ImeNativeWrapper.cs
注:本文中的System.Windows.Interop.HwndSource类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论