现在的位置: 首页 > 综合 > 正文

平时收获,供需及取(PPC)

2012年11月04日 ⁄ 综合 ⁄ 共 6972字 ⁄ 字号 评论关闭
  1作者:ah, 2007-06-08
  91.初始化转90度:
 10//Sets the screen orientation to portrait.
 11Microsoft.WindowsCE.Forms.SystemSettings.ScreenOrientation = Microsoft.WindowsCE.Forms.ScreenOrientation.Angle90;
 12
 132.
 14// Removes Minimize (X) and Close(OK) buttons.
 15            // Caution: Only way to close the application
 16            // is with the Running Programs memory options under Settings. 
 17           this.ControlBox = false;
 18
 193.背景
 20      protected override void OnPaint(PaintEventArgs e)
 21        {
 22            //Get image compiled as an embedded resource.
 23            System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
 24
 25            // Note that the name for the embedded resource
 26            // is case sensitive and must match the file name.
 27            Bitmap backgroundImage = new Bitmap(asm.GetManifestResourceStream("MySnippets.images.wallpaper.bmp"));
 28            //backgroundImage = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("AYMove.images.indexbg.jpg"));
 29
 30            e.Graphics.DrawImage(backgroundImage, this.ClientRectangle, new Rectangle(00, backgroundImage.Width, backgroundImage.Height), GraphicsUnit.Pixel);
 31        }

 32
 335.取得平台:
 34private string GetDeviceName()
 35        {
 36            return System.Net.Dns.GetHostName();//ppc or smtphone
 37        }

 38
 396.取到程序路径
 40        private string GetApplicationDirectory()
 41        {
 42            return System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
 43        }

 44
 457.Set CenterForm
 46 private void CenterForm()
 47        {
 48            //Set the desired form size.  
 49            this.FormBorderStyle = FormBorderStyle.None;
 50            this.Size = new Size(200200);
 51            this.BackColor = Color.Wheat;
 52            this.FormBorderStyle = FormBorderStyle.None;
 53            //Get the size of the screen for centering the form.
 54            Rectangle rectS = Screen.PrimaryScreen.Bounds;
 55            this.Location = new Point(Convert.ToInt32((rectS.Width - this.Width) / 2), Convert.ToInt32((rectS.Height - this.Height) / 2));
 56        }

 57
 588.
 59 private void SetInputMethod()
 60        {
 61            // Sets the input method to Letter Recognizer.
 62            foreach (Microsoft.WindowsCE.Forms.InputMethod method in inputPanel1.InputMethods)
 63            {
 64                if (method.Name == "Letter Recognizer")
 65                {
 66                    inputPanel1.CurrentInputMethod = method;
 67                    break;
 68                }

 69            }

 70        }

 71
 729.
 73        //Set up file extension filters for a
 74        //DocumentList and set the initial folder
 75        void SetupDocList()
 76        {
 77            documentList1.Parent = this;
 78            documentList1.Filter = " |*.*| |*.txt;*.xml| |*.pwi;*.pdt| |*.pxl; *.psw| |*.jpg;*.gif;*.bmp| |*.wav;*.wmv;*.mpg;";
 79            documentList1.FilterIndex = 0;
 80            documentList1.SelectedDirectory = "Program Files";
 81        }

 82
 83        private void DocList_DocumentActivated(Object sender, Microsoft.WindowsCE.Forms.DocumentListEventArgs docevent)
 84        {
 85            // Add code to open the selected file.
 86
 87        }

 88
 89        private void DocList_DeletingDocument(object sender, Microsoft.WindowsCE.Forms.DocumentListEventArgs docevent)
 90        {
 91            // Add code to close any instances of the file.
 92        }

 93
 94        private void DocList_SelectedDirectoryChanged(object sender, System.EventArgs e)
 95        {
 96            // Add code to access the selected folder to open and close files.
 97        }

 98
 9910.private void SendNotification(string message)
100        {
101            // Set the Text property to the HTML string.
102            notification1.Text = message;
103
104            // Get the icon as an embedded resource.
105            // Note that the icon must be added to the project as an embedded resource.
106            System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
107
108
109            // Note that the name for the embedded resource
110            // is case sensitive and must match the file name.
111            System.IO.Stream stream = asm.GetManifestResourceStream("PocketPCApplication1.notify.ico");
112            notification1.Icon = new Icon(stream, 1616);
113
114            // If the notification is canceled, its icon remains
115            // available for later activating the notification.
116            notification1.InitialDuration = 10;
117            notification1.Visible = true;
118        }

119
12011.
121 private void LoadPicture()
122        {
123            Bitmap bmpSource;
124            System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
125
126            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
127            try
128            {
129                bmpSource = new Bitmap(asm.GetManifestResourceStream("DeviceApplication1.mypicture.bmp"));
130                pictureBox1.Image = bmpSource;
131            }

132            catch (NullReferenceException ex)
133            {
134            }

135        }

136
13712.
138  public int CTL_CODE(int DeviceType, int Func, int Method, int Access)
139        {
140            return (DeviceType << 16| (Access << 14| (Func << 2| Method;
141        }

142
143        [System.Runtime.InteropServices.DllImport("Coredll.dll")]
144        static extern int KernelIoControl(int dwIoControlCode, IntPtr lpInBuf, int nInBufSize, IntPtr lpOutBuf, int nOutBufSize, ref int lpBytesReturned);
145
146        private int ResetPocketPC()
147        {
148            const int FILE_DEVICE_HAL = 257;
149            const int METHOD_BUFFERED = 0;
150            const int FILE_ANY_ACCESS = 0;
151
152            int bytesReturned = 0;
153            int IOCTL_HAL_REBOOT = CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS);
154
155            return KernelIoControl(IOCTL_HAL_REBOOT, IntPtr.Zero, 0, IntPtr.Zero, 0ref bytesReturned);
156        }

157
15813.
159
160        // Shortens the height of a ListBox when the SIP
161        // (Soft Input Panel) is displayed so that the vertical
162        // scroll bar of the ListBox is not obscured by the SIP.
163
164        // Size the ListBox to about the height of the form.
165        // Put the TextBox to the upper right or left of the list box.
166
167        // When the TextBox receives focus, the SIP is enabled.
168        //  When the ListBox receives focus, the SIP is disabled.
169
170        int ListBoxFullHeight = 0;
171        // Call this method from the constructor, 
172        // or Form_Load event, of your form
173
174        private void SetListBoxFullHeight()
175        {
176            // Determine the original height of the list box.
177            ListBoxFullHeight = listBox1.Height;
178        }

179

抱歉!评论已关闭.