How to hide the OK button in the dialog in .Net Compact Framework application?
来源:互联网 发布:程序员需要学多久 编辑:程序博客网 时间:2024/05/01 22:53
Question
Some dialogs like wizards should contain neither OK nor X button. How can I the OK or X button in the dialog in .Net Compact Framework application?
Answer
A. We have to import three functions from aygshell coredll DLLs:
{
[DllImport("aygshell.dll")]
private static extern bool SHDoneButton(
IntPtr hWnd,
UInt32 dwState);
[DllImport("coredll.dll")]
public static extern UInt32 SetWindowLong(
IntPtr hWnd,
int nIndex,
UInt32 dwNewLong);
[DllImport("coredll.dll")]
public static extern UInt32 GetWindowLong(
IntPtr hWnd,
int nIndex);
}
B. Then we write 2 functions (HideDoneButton and HideXButton) and add several constants:
{
public const UInt32 SHDB_SHOW = 0x0001;
public const UInt32 SHDB_HIDE = 0x0002;
public const int GWL_STYLE = -16;
public const UInt32 WS_NONAVDONEBUTTON = 0x00010000;
public static void HideDoneButton(IntPtr hWnd)
{
SHDoneButton(hWnd, SHDB_HIDE);
}
public static void HideXButton(IntPtr hWnd)
{
UInt32 dwStyle = GetWindowLong(hWnd, GWL_STYLE);
if ((dwStyle & WS_NONAVDONEBUTTON) == 0)
SetWindowLong(hWnd, GWL_STYLE, dwStyle | WS_NONAVDONEBUTTON);
}
}
C. To hide the done (OK) button in the dialog you should add Paint event handler to the dialog and call HideDoneButton and HideXButton functions from there:
{
private void MyForm_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
WinAPI.HideDoneButton();
WinAPI.HideXButton();
}
}
If the Paint handler is not called then you should call there functions yourself from somewhere between the dialog creation and its destruction - one of the ideas is to create a timer and to call the functions from its handler.
Done!
- How to hide the OK button in the dialog in .Net Compact Framework application?
- Bitmaps in the Compact Framework
- How to hide the "Repair" option in the .NET installation package
- How to hide the address bar in MobileSafari
- How to: Hide the Ribbon in SharePoint 2010
- Application Blocks for the .NET Compact Framework
- How to set the QT Application icon in the windows.
- The Definitive Guide to the .NET Compact Framework
- Hide in the shadow
- How to programmatically remove/hide the system bar in Honeycomb (requires root)
- How to alignment the center position of the button in Android?
- How to achive the CRUD in ASP.NET MVC(VS2010)
- How do I hide a menu item in the actionbar?
- How to access a value defined in the application.properties file in Spring Boot ( Externalized Conf)
- How to show/hide a control in the Column's DataItemTemplate based on the value of another control
- How to set the sequence value while saving the record in OA Framework
- How to Animate the Up-Button to Hamburger like in Gmail
- Hide the console in windows
- Template Metaprogramming - cont.1铪
- Template Metaprogramming
- autoconf 和automake生成Makefile文件(ZZ,转自模范SB网)
- 模板元编程 --- 用 MPL 解决实际问题
- 凤凰涅磐 --- Phoenix 2 发布预览
- How to hide the OK button in the dialog in .Net Compact Framework application?
- 简单常识——关于stream
- unspecified_bool_type 手法
- Java Double-Checked Locking 已死,C++ 呢?
- C++ Multithreading
- Putty使用技巧总结
- What you can do is more important than who your parents are.
- DiskDefrag: the problem铪铪
- SimpleRouter: the problem铪