Esempio n. 1
0
        // ************************************************************************


        // ************************************************************************
        // Prepare the event data structure
        private void PrepareEventData(CbtEventArgs e)
        {
            e.Handle         = m_hwnd;
            e.Title          = m_title;
            e.ClassName      = m_class;
            e.IsDialogWindow = m_isDialog;
        }
Esempio n. 2
0
        //public DialogResult Show(string strKey, string strValue, DialogResult dr, string strCheck, string strText, string strTitle, MessageBoxButtons buttons, MessageBoxIcon icon)
        //{
        //    RegistryKey regKey = Registry.CurrentUser.CreateSubKey(strKey);
        //    try
        //    {
        //        if(Convert.ToBoolean(regKey.GetValue(strValue,false)))
        //            return dr;
        //    }
        //    catch
        //    {
        //        // No processing needed...the convert might throw an exception,
        //        // but if so we proceed as if the value was false.
        //    }

        //    m_strCheck = strCheck;
        //    m_cbt.Install();
        //    dr = System.Windows.Forms.MessageBox.Show(strText, strTitle, buttons, icon);
        //    m_cbt.Uninstall();

        //    regKey.SetValue(strValue,m_bCheck);
        //    return dr;
        //}

        //public DialogResult Show(string strKey, string strValue, DialogResult dr, string strCheck, string strText, string strTitle, MessageBoxButtons buttons)
        //{
        //    return Show(strKey, strValue, dr, strCheck, strText, strTitle, buttons, MessageBoxIcon.None);
        //}

        //public DialogResult Show(string strKey, string strValue, DialogResult dr, string strCheck, string strText, string strTitle)
        //{
        //    return Show(strKey, strValue, dr, strCheck, strText, strTitle, MessageBoxButtons.OK, MessageBoxIcon.None);
        //}

        //public DialogResult Show(string strKey, string strValue, DialogResult dr, string strCheck, string strText)
        //{
        //    return Show(strKey, strValue, dr, strCheck, strText, "", MessageBoxButtons.OK, MessageBoxIcon.None);
        //}

        private void WndCreated(object sender, CbtEventArgs e)
        {
            if (e.IsDialogWindow)
            {
                m_bInit = false;
                m_hwnd  = e.Handle;
            }
        }
Esempio n. 3
0
		private void WndCreated(object sender, CbtEventArgs e)
		{
			if (e.IsDialogWindow)
			{
				m_bInit = false;
				m_hwnd = e.Handle;
			}
		}
Esempio n. 4
0
 protected virtual void OnWindowActivated()
 {
     if (WindowActivated != null)
     {
         CbtEventArgs e = new CbtEventArgs();
         PrepareEventData(e);
         WindowActivated(this, e);
     }
 }
Esempio n. 5
0
		private void WndDestroyed(object sender, CbtEventArgs e)
		{
			if (e.Handle == m_hwnd)
			{
				m_bInit = false;
				m_hwnd = IntPtr.Zero;
				if(BST_CHECKED == (int)SendMessage(m_hwndBtn,BM_GETCHECK,IntPtr.Zero,IntPtr.Zero))
					m_bCheck = true;
			}
		}
Esempio n. 6
0
		private void WndActivated(object sender, CbtEventArgs e)
		{
			if (m_hwnd != e.Handle)
				return;

			// Not the first time
			if (m_bInit)
				return;
			else
				m_bInit = true;

			// Get the current font, either from the static text window
			// or the message box itself
			IntPtr hFont;
			IntPtr hwndText = GetDlgItem(m_hwnd, 0xFFFF);
			if(hwndText != IntPtr.Zero)
				hFont = SendMessage(hwndText, WM_GETFONT, IntPtr.Zero, IntPtr.Zero);			
			else
				hFont = SendMessage(m_hwnd, WM_GETFONT, IntPtr.Zero, IntPtr.Zero);			
			Font fCur = Font.FromHfont(hFont);
	
			// Get the x coordinate for the check box.  Align it with the icon if possible,
			// or one character height in
			int x = 0;
			IntPtr hwndIcon = GetDlgItem(m_hwnd, 0x0014);
			if(hwndIcon != IntPtr.Zero)
			{
				RECT rcIcon = new RECT();
				GetWindowRect(hwndIcon, rcIcon);
				POINT pt = new POINT();
				pt.x = rcIcon.left;
				pt.y = rcIcon.top;
				ScreenToClient(m_hwnd, pt);
				x = pt.x;
			}
			else
				x = (int)fCur.GetHeight();

			// Get the y coordinate for the check box, which is the bottom of the
			// current message box client area
			RECT rc = new RECT();
			GetClientRect(m_hwnd, rc);
			int y = rc.bottom - rc.top;

			// Resize the message box with room for the check box
			GetWindowRect(m_hwnd, rc);
			MoveWindow(m_hwnd,rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top + (int)fCur.GetHeight()*2,true);

			m_hwndBtn = CreateWindowEx(0, "button", m_strCheck, BS_AUTOCHECKBOX|WS_CHILD|WS_VISIBLE|WS_TABSTOP, 
				x, y , rc.right-rc.left-x, (int)fCur.GetHeight(),
				m_hwnd, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);

			SendMessage(m_hwndBtn, WM_SETFONT, hFont, new IntPtr(1));			
		}
Esempio n. 7
0
 private void WndDestroyed(object sender, CbtEventArgs e)
 {
     if (e.Handle == m_hwnd)
     {
         m_bInit = false;
         m_hwnd  = IntPtr.Zero;
         if (BST_CHECKED == (int)SendMessage(m_hwndBtn, BM_GETCHECK, IntPtr.Zero, IntPtr.Zero))
         {
             m_bCheck = true;
         }
     }
 }
Esempio n. 8
0
        private void WndActivated(object sender, CbtEventArgs e)
        {
            if (m_hwnd != e.Handle)
            {
                return;
            }

            // Not the first time
            if (m_bInit)
            {
                return;
            }
            else
            {
                m_bInit = true;
            }

            // Get the current font, either from the static text window
            // or the message box itself
            IntPtr hFont;
            IntPtr hwndText = GetDlgItem(m_hwnd, 0xFFFF);

            if (hwndText != IntPtr.Zero)
            {
                hFont = SendMessage(hwndText, WM_GETFONT, IntPtr.Zero, IntPtr.Zero);
            }
            else
            {
                hFont = SendMessage(m_hwnd, WM_GETFONT, IntPtr.Zero, IntPtr.Zero);
            }
            Font fCur = Font.FromHfont(hFont);

            // Get the x coordinate for the check box.  Align it with the icon if possible,
            // or one character height in
            int    x        = 0;
            IntPtr hwndIcon = GetDlgItem(m_hwnd, 0x0014);

            if (hwndIcon != IntPtr.Zero)
            {
                RECT rcIcon = new RECT();
                GetWindowRect(hwndIcon, rcIcon);
                POINT pt = new POINT();
                pt.x = rcIcon.left;
                pt.y = rcIcon.top;
                ScreenToClient(m_hwnd, pt);
                x = pt.x;
            }
            else
            {
                x = (int)fCur.GetHeight();
            }

            // Get the y coordinate for the check box, which is the bottom of the
            // current message box client area
            RECT rc = new RECT();

            GetClientRect(m_hwnd, rc);
            int y = rc.bottom - rc.top;

            // Resize the message box with room for the check box
            GetWindowRect(m_hwnd, rc);
            MoveWindow(m_hwnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top + (int)fCur.GetHeight() * 2, true);

            m_hwndBtn = CreateWindowEx(0, "button", m_strCheck, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP,
                                       x, y, rc.right - rc.left - x, (int)fCur.GetHeight(),
                                       m_hwnd, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);

            SendMessage(m_hwndBtn, WM_SETFONT, hFont, new IntPtr(1));
        }
Esempio n. 9
0
        // ************************************************************************


        // ************************************************************************
        // Prepare the event data structure
        private void PrepareEventData(CbtEventArgs e)
        {
            e.Handle = m_hwnd;
            e.Title = m_title;
            e.ClassName = m_class;
            e.IsDialogWindow = m_isDialog;
        }
Esempio n. 10
0
 protected virtual void OnWindowActivated()
 {
     if (WindowActivated != null)
     {
         CbtEventArgs e = new CbtEventArgs();
         PrepareEventData(e);
         WindowActivated(this, e);
     }
 }