// Retrieves a new object from a Form object public static SystemMenu FromForm(Form Frm) { SystemMenu cSysMenu = new SystemMenu(); cSysMenu.m_SysMenu = apiGetSystemMenu(Frm.Handle, 0); if (cSysMenu.m_SysMenu == IntPtr.Zero) { // Throw an exception on failure throw new NoSystemMenuException(); } return(cSysMenu); }
private void OnLoad(object sender, EventArgs e) { Rectangle rcScreen = SystemInformation.WorkingArea; // center screen Int32 nNormalLeft = (rcScreen.Width - this.Size.Width) / 2; Int32 nNormalTop = (rcScreen.Height - this.Size.Height) / 2; Int32 nTextSize = 68; String strFontFace = "Book Antiqua"; String strTextLogo = "CSI"; Int32 nOffsetX = 4; Int32 nOffsetY = 4; Int32 nOpacity = 50; Int32 nBlur = 4; Int32 nAzimuth = 135; Int32 nElevation = 45; Int32 nWidth = 3; Color crBack = Color.White; Color crChar1 = Color.DodgerBlue; Color crChar2 = Color.Red; Color crChar3 = Color.Gold; Color crChar4 = Color.DodgerBlue; Color crChar5 = Color.LawnGreen; Color crChar6 = Color.Red; Color crChar7 = Color.DarkOrchid; Color crChar8 = Color.LimeGreen; // attempt to read options from the registry RegistryKey hKey = Registry.CurrentUser.OpenSubKey(@"Software\ITSoftware\ColorLogoMaker"); if (hKey != null) { nNormalLeft = (int)hKey.GetValue("Left", this.Left); nNormalTop = (int)hKey.GetValue("Top", this.Top); nTextSize = (int)hKey.GetValue("TextSize", 68); strTextLogo = (String)hKey.GetValue("TextLogo", "CSI"); strFontFace = (String)hKey.GetValue("FontFace", "Book Antiqua"); nOffsetX = (int)hKey.GetValue("ShadowOffsetX", 4); nOffsetY = (int)hKey.GetValue("ShadowOffsetY", 4); nOpacity = (int)hKey.GetValue("ShadowOpacity", 50); nBlur = (int)hKey.GetValue("ShadowBlur", 4); nAzimuth = (int)hKey.GetValue("BumpAzimuth", 135); nElevation = (int)hKey.GetValue("BumpElevation", 45); nWidth = (int)hKey.GetValue("BumpWidth", 3); crBack = Color.FromArgb((int)hKey.GetValue("BackColor", Color.White.ToArgb())); crChar1 = Color.FromArgb((int)hKey.GetValue("Char1Color", Color.DodgerBlue.ToArgb())); crChar2 = Color.FromArgb((int)hKey.GetValue("Char2Color", Color.Red.ToArgb())); crChar3 = Color.FromArgb((int)hKey.GetValue("Char3Color", Color.Gold.ToArgb())); crChar4 = Color.FromArgb((int)hKey.GetValue("Char4Color", Color.DodgerBlue.ToArgb())); crChar5 = Color.FromArgb((int)hKey.GetValue("Char5Color", Color.LawnGreen.ToArgb())); crChar6 = Color.FromArgb((int)hKey.GetValue("Char6Color", Color.Red.ToArgb())); crChar7 = Color.FromArgb((int)hKey.GetValue("Char7Color", Color.DarkOrchid.ToArgb())); hKey.Close(); } this.Location = new Point(nNormalLeft, nNormalTop); int nIndex = m_cmbFont.FindString(strFontFace); if (nIndex != -1) { m_cmbFont.SelectedIndex = nIndex; } m_textBoxSize.Text = nTextSize.ToString(); m_textBoxLogo.Text = strTextLogo; m_textBoxOffsetX.Text = nOffsetX.ToString(); m_textBoxOffsetY.Text = nOffsetY.ToString(); m_textBoxOpacity.Text = nOpacity.ToString(); m_textBoxBlur.Text = nBlur.ToString(); m_textBoxAzimuth.Text = nAzimuth.ToString(); m_textBoxElevation.Text = nElevation.ToString(); m_textBoxWidth.Text = nWidth.ToString(); m_labelColorBack.BackColor = crBack; m_labelColor1.BackColor = crChar1; m_labelColor2.BackColor = crChar2; m_labelColor3.BackColor = crChar3; m_labelColor4.BackColor = crChar4; m_labelColor5.BackColor = crChar5; m_labelColor6.BackColor = crChar6; m_labelColor7.BackColor = crChar7; try { m_SystemMenu = SystemMenu.FromForm(this); m_SystemMenu.AppendSeparator(); m_SystemMenu.AppendMenu(m_AboutID, "About Color Logo Maker..."); } catch (NoSystemMenuException /* err */) { // Do some error handling } }