. NET Compact framework tips (1)

Source: Internet
Author: User

Some minor problems may occur during the development process. This problem may seem simple, but it may be quite troublesome to handle.
I will write some tips I have developed to help you.

This articleArticleThis section describes how to hide the OK/X button in the upper-right corner of the form. If you do not need this button, remove it ~~~~

Next we will introduce the function of this button again. X indicates minimization, and OK indicates confirmation and closure. generally, after a new form is created, the minimum value of the default form is true. Therefore, if you want to display OK, set this attribute to false.

To hide this button, you need to call three APIs.

1 [Dllimport ( " Aygshell. dll " )]
2 Private   Static   Extern   Bool Shdonebutton (intptr hwnd, uint32 dwstate );
3
4 [Dllimport ( " Coredll. dll " )]
5 Public   Static   Extern Uint32 setwindowlong (intptr hwnd, Int Nindex, uint32 dwnewlong );
6
7 [Dllimport ( " Coredll. dll " )]
8 Public   Static   Extern Uint32 getwindowlong (intptr hwnd, Int Nindex );

Shdonebutton -- call this method when the form is OK.
Getwindowlong -- get the information of the specified window
Setwindowlong -- set the information of the specified window. The two methods can be used together to hide the X button.

Usage

1 Public   Const Uint32 shdb_show =   Zero X 0001 ;
2 Public   Const Uint32 shdb_hide =   Zero X 0002 ;
3 Public   Const   Int Gwl_style =   - 16 ;
4 Public   Const Uint32 ws_nonavdonebutton =   Zero X 00010000 ;
5
6 ///   <Summary>
7 /// Hide OK button
8 ///   </Summary>
9 ///   <Param name = "hwnd"> </param>
10 Public   Static   Void Hidedonebutton (intptr hwnd)
11 {
12 Shdonebutton (hwnd, shdb_hide );
13 }
14
15 ///   <Summary>
16 /// Hide X button
17 ///   </Summary>
18 ///   <Param name = "hwnd"> </param>
19 Public   Static   Void Hidexbutton (intptr hwnd)
20 {
21 Uint32 dwstyle = Getwindowlong (hwnd, gwl_style );
22
23 If (Dwstyle & Ws_nonavdonebutton) =   0 )
24 Setwindowlong (hwnd, gwl_style, dwstyle | Ws_nonavdonebutton );
25 }

In actual calls, you only need to pass in the form handle as a parameter.

How can I open the hidden button?
You only need to set the minimizebox attribute of the Form. To display OK, set it to false. To display X, set it to true.

Display Effect:
Show OK button

Show X button

Hide button

CodeDownload:Devicetechdemo.rar

Running Environment: vs2008+ Wm6.0 +. Net cf3.5

Author: appleseeker (Feng)

Date: 2009-2-2

Article introduction:Mobile Development Index stickers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.