English 中文(简体)
使调整大小捕捉到窗口的特定宽度
原标题:Make resizing snap to certain widths of a Window

Background: I have a window that starts out with a width of 240px, some visual elements can only be displayed a particular way at this width, however resizing is allowed and must be allowed.

如果有人决定调整大小,那么我需要某种“捕捉”来恢复到原始宽度。为了恢复完整的视觉效果,要求用户获得准确的像素是一件痛苦/几乎不可能的事情。

问题:那么,如果它们在任何方向上距离240px一定距离(比方说,在4px以内),它将捕捉到该宽度,并且只有当调整大小的光标偏离宽度超过4px时,才调整到不同的大小。。

失败的想法:我玩了几个不同的东西,在sizeChanged事件中将窗口的宽度设置为240,如果它在4px内,但由于这是在size事件上,它将在窗口已经调整大小后进行计算。这意味着当它被调整为/远离默认宽度时,你会得到一个非常不稳定的效果。

最佳回答

以下消息解释了如何通过在自己的窗口过程中处理WM_SIZING消息来获得对调整大小的细粒度控制:

主持人的示例代码是用VB编写的,但是有很多C#/WinForms示例可以用来入门。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签