Click here to Skip to main content
15,879,474 members
Home / Discussions / C#
   

C#

 
QuestionHow to use IWin32Window Pin
mhd almidani31-Mar-13 23:31
mhd almidani31-Mar-13 23:31 
AnswerRe: How to use IWin32Window Pin
Eddy Vluggen1-Apr-13 0:03
professionalEddy Vluggen1-Apr-13 0:03 
GeneralRe: How to use IWin32Window Pin
mhd almidani1-Apr-13 5:09
mhd almidani1-Apr-13 5:09 
GeneralRe: How to use IWin32Window Pin
Alan N1-Apr-13 5:24
Alan N1-Apr-13 5:24 
GeneralRe: How to use IWin32Window Pin
mhd almidani1-Apr-13 20:35
mhd almidani1-Apr-13 20:35 
GeneralRe: How to use IWin32Window Pin
Eddy Vluggen1-Apr-13 11:34
professionalEddy Vluggen1-Apr-13 11:34 
AnswerRe: How to use IWin32Window Pin
Richard MacCutchan1-Apr-13 0:03
mveRichard MacCutchan1-Apr-13 0:03 
QuestionCustom TabControl: Designer adds TabPages in wrong order! Pin
Revolty31-Mar-13 9:33
Revolty31-Mar-13 9:33 
Hey

I've a custom TabControl that inherites Forms.UserControl, not Forms.TabControl. This shall behave just as a normal TabControl codewice. The issue is that TabPages beeing added in the wrong order by the designer. At first it is ok, 2 pages beeing added as expected, #1 and then #2, but when I make any changes to a Page #2, the Text for example - Page #2 beeing added as #1 in designer (the order is now incorrect):

C#
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage1);


Pages beeing added like this in my control:

C#
protected override void OnControlAdded(ControlEventArgs e)
{
    base.OnControlAdded(e);

    m_Pages.Add(e.Control as TabPage);
}


And the control designer looks like this:

public class TabControlDesigner : ParentControlDesigner
{
    private DesignerVerbCollection m_Verbs;

    public override void InitializeNewComponent(IDictionary defaultValues)
    {
        base.InitializeNewComponent(defaultValues);

        OnAddTabPage(this, EventArgs.Empty);
        OnAddTabPage(this, EventArgs.Empty); 
    }

    public override DesignerVerbCollection Verbs
    {
        get
        {
            return m_Verbs != null ? m_Verbs : m_Verbs = new DesignerVerbCollection(new DesignerVerb[] { new DesignerVerb("Add Tab", OnAddTabPage) });
        }
    }

    protected void OnAddTabPage(Object sender, EventArgs e)
    {
        IDesignerHost Host = (IDesignerHost)GetService(typeof(IDesignerHost));

        if (Host == null)
            return;

        TabControl Control = Component as TabControl;

        if (Control == null)
            return;

        TabPage newPage = Host.CreateComponent(typeof(TabPage)) as TabPage;

        MemberDescriptor Descriptor = TypeDescriptor.GetProperties(Control)["Controls"];

        RaiseComponentChanging(Descriptor);

        newPage.Text = newPage.Name;
        newPage.Owner = Component as TabControl;
        newPage.BackColor = Color.White;

        Control.Controls.Add(newPage);
                
        RaiseComponentChanged(Descriptor, null, null);
    }

    public override bool CanParent(Control c)
    {
        if (c is TabPage)
            return !Control.Contains(c);
        else
            return false;
    }

    protected override void WndProc(ref Message m)
    { 
        if (m.Msg == 0x201 /*WM_LBUTTONDOWN*/)
        {
            TabControl c = Component as TabControl;

            int lParam = m.LParam.ToInt32();
            Point p = new Point(lParam & 0xffff, lParam >> 0x10);


            for (int i = 0; i < c.Controls.Count; i++)
            {
                 if (c.GetTabRect(i).Contains(p))
                 {
                     c.SelectedIndex = i;
                     return;
                 }
            }
            
        }

        base.WndProc(ref m);
    }

    protected override void OnDragDrop(DragEventArgs e)
    {
        ((IDropTarget)((TabControl)Component).SelectedPage).OnDragDrop(e);
    }

    protected override void OnDragEnter(DragEventArgs e)
    {
        ((IDropTarget)((TabControl)Component).SelectedPage).OnDragEnter(e);
    }

    protected override void OnDragLeave(EventArgs e)
    {
        ((IDropTarget)((TabControl)Component).SelectedPage).OnDragLeave(e);
    }

    protected override void OnDragOver(DragEventArgs e)
    {
        ((IDropTarget)((TabControl)Component).SelectedPage).OnDragOver(e);
    }
}        


modified 31-Mar-13 16:58pm.

AnswerRe: Custom TabControl: Designer adds TabPages in wrong order! Pin
Revolty7-Apr-13 5:18
Revolty7-Apr-13 5:18 
Questionكيف البحث عن ملفات محرر التسجيل Pin
reemaziz31-Mar-13 6:13
reemaziz31-Mar-13 6:13 
AnswerRe: كيف البحث عن ملفات محرر التسجيل Pin
Kenneth Haugland31-Mar-13 6:49
mvaKenneth Haugland31-Mar-13 6:49 
AnswerRe: كيف البحث عن ملفات محرر التسجيل Pin
Richard MacCutchan31-Mar-13 8:02
mveRichard MacCutchan31-Mar-13 8:02 
Questioninsatling mssql server 2008r2 Pin
Ashbinsapkota31-Mar-13 5:39
Ashbinsapkota31-Mar-13 5:39 
AnswerRe: insatling mssql server 2008r2 Pin
Pete O'Hanlon31-Mar-13 5:52
mvePete O'Hanlon31-Mar-13 5:52 
AnswerRe: insatling mssql server 2008r2 Pin
Abhinav S31-Mar-13 22:40
Abhinav S31-Mar-13 22:40 
QuestionSqlDependency. Can't realize. Pin
Jeka Developer31-Mar-13 0:05
Jeka Developer31-Mar-13 0:05 
AnswerRe: SqlDependency. Can't realize. Pin
Eddy Vluggen31-Mar-13 0:31
professionalEddy Vluggen31-Mar-13 0:31 
GeneralRe: SqlDependency. Can't realize. Pin
Jeka Developer1-Apr-13 2:43
Jeka Developer1-Apr-13 2:43 
AnswerRe: SqlDependency. Can't realize. Pin
Eddy Vluggen1-Apr-13 2:55
professionalEddy Vluggen1-Apr-13 2:55 
GeneralRe: SqlDependency. Can't realize. Pin
Jeka Developer1-Apr-13 4:57
Jeka Developer1-Apr-13 4:57 
GeneralRe: SqlDependency. Can't realize. Pin
Eddy Vluggen1-Apr-13 11:41
professionalEddy Vluggen1-Apr-13 11:41 
GeneralRe: SqlDependency. Can't realize. Pin
Jeka Developer2-Apr-13 10:24
Jeka Developer2-Apr-13 10:24 
GeneralRe: SqlDependency. Can't realize. Pin
Eddy Vluggen3-Apr-13 6:52
professionalEddy Vluggen3-Apr-13 6:52 
AnswerRe: SqlDependency. Can't realize. Pin
jschell1-Apr-13 8:12
jschell1-Apr-13 8:12 
GeneralRe: SqlDependency. Can't realize. Pin
Jeka Developer2-Apr-13 10:26
Jeka Developer2-Apr-13 10:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.