Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 340757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:38:45+00:00 2026-05-12T10:38:45+00:00

In the below code, i am trying to reference an external .dll, which creates

  • 0

In the below code, i am trying to reference an external .dll, which creates a custom taskbar in the desktop. After which i am creating tabs on the taskbar as per my requirement.

Everything works fine, but after i terminate my application for creating the taskbar, the space which is occupied by the custom taskbar is blocked. which means that, the resources are not released after exiting the application.

I am trying the force the application to dispose the unmanaged resources. But it dosent help.
How to do it?? Please refer to the code below which i am trying with…

namespace Daemon
{

public partial class MDIParent : ShellLib.ApplicationDesktopToolbar , IDisposable
{

    private static MDIParent MDIParentInstance = null;


    public MDIParent()
    {
        InitializeComponent();
        timer1.Interval = 50;
        timer1.Enabled = true;

    }
    int childCount = 1;
    int iHitcount = 0;


    protected override void Dispose(bool disposing)
    {
        if (disposing)
        {
            if (components != null)
            {
                components.Dispose();
            }
        }
        base.Dispose(disposing);
    }


    private void MDIParent_FormClosed(object sender, FormClosedEventArgs e)
    {
        Taskbar.Show();
    }

    public void TabIt(string strProcessName)
    {
        //Get the collection of opened tab names and check against the new tabs.
        //If exists, dont allow to open the same tab again.

        bool found = false;

        if (Global.ExistingTabProcessNames.Count > 0)
        {
            foreach (string currentTab in Global.ExistingTabProcessNames)
            {
                if (currentTab.Equals(strProcessName))
                {
                    found = true;
                }
            }
        }

        if (found == false)
        {
            this.Show();

            //Creating MDI child form and initialize its fields
            MDIChild childForm = new MDIChild();
            childForm.Text = strProcessName;
            childForm.MdiParent = this;

            //child Form will now hold a reference value to the tab control
            childForm.TabCtrl = tabControl1;

            //Add a Tabpage and enables it
            TabPage tp = new TabPage();
            tp.Parent = tabControl1;
            tp.Text = childForm.Text;
            tp.Show();
            //child Form will now hold a reference value to a tabpage
            childForm.TabPag = tp;
            //Activate the MDI child form
            childForm.Show();
            childCount++;

            //Activate the newly created Tabpage
            tabControl1.SelectedTab = tp;
            tp.Height = tp.Parent.Height;
            tp.Width = tp.Parent.Width;
        }
    }

    private void MDIParent_Load(object sender, EventArgs e)
    {
        Edge = AppBarEdges.Top;
    } 

    [System.Runtime.InteropServices.DllImport("user32.dll")]

    private static extern int ShowWindow(IntPtr hWnd, int nCmdShow);

    private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
        iHitcount = iHitcount + 1;
        if (iHitcount != 1)
            BringFront(tabControl1.SelectedTab.Text.ToString());
    }

    [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
    private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);

    private const int SW_SHOWNORMAL = 1;
    private const int SW_SHOWMINIMIZED = 2;
    private const int SW_SHOWMAXIMIZED = 3;

    private void BringFront(string ExecutablePath)
    {
        Process[] Processes = Process.GetProcesses();

        foreach (Process clsProcess in Process.GetProcesses())
        {
            if (clsProcess.ProcessName.Contains(ExecutablePath))
            {

                ShowWindowAsync(clsProcess.MainWindowHandle, SW_SHOWMAXIMIZED);
            }
            else
            {
                ShowWindowAsync(clsProcess.MainWindowHandle, SW_SHOWMINIMIZED);
            }
        }
    }

    public static MDIParent MDIParentRef
    {
        get
        {
            if (MDIParentInstance == null)
                MDIParentInstance = new MDIParent();

            return MDIParentInstance;
        }
    }

    public void showScreen()
    {
        if (this.InvokeRequired == true)
        {
            this.Invoke(new MethodInvoker(this.showScreen));
        }
        else
        {

            this.Show();
        }
    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        if (Global.TabProcessNames.Count > 0)
        {
            foreach (string strProcessName in Global.TabProcessNames)
            {
                TabIt(strProcessName);
            }
        }
    } 
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:38:45+00:00Added an answer on May 12, 2026 at 10:38 am

    The appbar is removed by the OnClosing event of ApplicationDesktopToolbar.

    Are you using Application.Exit to exit your application? From MSDN:

    The Application.Exit method does not raise the Form.Closed and Form.Closing events […]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 197k
  • Answers 197k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No big difference between them, you can Target Windows CE… May 12, 2026 at 7:25 pm
  • Editorial Team
    Editorial Team added an answer Include is a hint to eager load, it does not… May 12, 2026 at 7:25 pm
  • Editorial Team
    Editorial Team added an answer Binary data (such as images) doesn't work in a .NET… May 12, 2026 at 7:25 pm

Related Questions

I am trying to create a general method for disposing an object that implements
I am trying to extend the partial classes that the entity framework creates so
Let’s say that I have two C# applications - game.exe (XNA, needs to support
I have the code below in an attempt to allow the user to Step

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.