示例#1
0
        /// <summary>
        /// Overridden. Displays the modal dialog.
        /// </summary>
        /// <param name="hwndOwner">The handle of the window that owns the dialog box.</param>
        /// <returns><b>true</b> if the user completed the entry successfully, otherwise <b>false</b>.</returns>
        protected override bool RunDialog(IntPtr hwndOwner)
        {
            var dlg = new NativeMethods.RASDIALDLG
            {
                size       = Marshal.SizeOf(typeof(NativeMethods.RASDIALDLG)),
                hwndOwner  = hwndOwner,
                subEntryId = SubEntryId
            };

            if (Location != Point.Empty)
            {
                dlg.left = Location.X;
                dlg.top  = Location.Y;

                dlg.flags |= NativeMethods.RASDDFLAG.PositionDlg;
            }

            var retval = false;

            try
            {
                retval = UnsafeNativeMethods.Instance.DialDlg(PhoneBookPath, EntryName, PhoneNumber, ref dlg);
                if (!retval && dlg.error != NativeMethods.SUCCESS)
                {
                    var e = new RasErrorEventArgs(dlg.error, RasHelper.Instance.GetRasErrorString(dlg.error));
                    OnError(e);
                }
            }
            catch (EntryPointNotFoundException)
            {
                ThrowHelper.ThrowNotSupportedException(Resources.Exception_NotSupportedOnPlatform);
            }

            return(retval);
        }
示例#2
0
        /// <summary>
        /// Overridden. Displays the modal dialog.
        /// </summary>
        /// <param name="hwndOwner">The handle of the window that owns the dialog box.</param>
        /// <returns><b>true</b> if the user completed the entry successfully, otherwise <b>false</b>.</returns>
        protected override bool RunDialog(IntPtr hwndOwner)
        {
            NativeMethods.RASDIALDLG dlg = new NativeMethods.RASDIALDLG();
            dlg.size = Marshal.SizeOf(typeof(NativeMethods.RASDIALDLG));
            dlg.hwndOwner = hwndOwner;
            dlg.subEntryId = this.SubEntryId;

            if (this.Location != Point.Empty)
            {
                dlg.left = this.Location.X;
                dlg.top = this.Location.Y;

                dlg.flags |= NativeMethods.RASDDFLAG.PositionDlg;
            }

            bool retval = false;
            try
            {
                retval = UnsafeNativeMethods.Instance.DialDlg(this.PhoneBookPath, this.EntryName, this.PhoneNumber, ref dlg);
                if (!retval && dlg.error != NativeMethods.SUCCESS)
                {
                    RasErrorEventArgs e = new RasErrorEventArgs(dlg.error, RasHelper.Instance.GetRasErrorString(dlg.error));
                    this.OnError(e);
                }
            }
            catch (EntryPointNotFoundException)
            {
                ThrowHelper.ThrowNotSupportedException(Resources.Exception_NotSupportedOnPlatform);
            }

            return retval;
        }