Remove application's window button from taskbar (WinCE 4.2)

M

minimega

Hi to all NG.

I've this problem: in my application I've develop a custom MessageBox
form (larger than the standard CE MessageBox, with big graphics buttons
Yes/No, with his own title bar..). When I display it as new instance of
the form fmCustomMessageButton, in the taskbar appear a new rectangle,
void, without icon or text.

That's right because on fmCustomMessageButton costructor I've placed
the following code:

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MinimizeBox = false;
this.MaximizeBox = false;
this.ControlBox = false;
this.Menu = null;
this.Text = String.Empty;
this.Icon = null;

hoping that can serve to hide the new window from the taskbar, however
this doesn't work.

If I set the .Parent property of the CustomMessageBox to the Main
window reference, it become a child of the main window, and the
rectangle hide from the taskbar.

However the fmCustomMessageButton is displayed with the .ShowDialog
method, because it must suspend the code flow until the user choose a
button. The .ShowDialog method seems to disable either the main form,
either the CustomMessageBox and I'm not able to click over any button.

Is there a way to hide an application from taskbar without make it a
child window?

Thanks,
Massimo
 
M

minimega

Hi Chris, the following code works fine for me! Can you take a look and
say if is correct?

public void RemoveFromAppBar(Form form)
{
int intCurrentExtStyle = 0;
int intNewExtStyle = 0;

// Get form hWnd
form.Capture = true;
IntPtr hWnd = GetCapture();
form.Capture = false;

// Get current window extended style
intCurrentExtStyle = GetWindowLong(hWnd, GWL_EXSTYLE);

// Add WS_EX_TOOLWINDOW style to the current window style
intNewExtStyle = intCurrentExtStyle | WS_EX_TOOLWINDOW;

// Apply new style
if (intNewExtStyle != intCurrentExtStyle)
SetWindowLong(hWnd, GWL_EXSTYLE, intNewExtStyle);
}

However, if I call somtemes this function, I get more and more windows
in the task bar, and when I exit the application, they remain there,
but if i click over, nothing happens. Why?

Thanks a lot,
Massimo


Chris Tacke, eMVP ha scritto:
 
G

Guest

You should call it once in Form load.

-Chris


minimega said:
Hi Chris, the following code works fine for me! Can you take a look and
say if is correct?

public void RemoveFromAppBar(Form form)
{
int intCurrentExtStyle = 0;
int intNewExtStyle = 0;

// Get form hWnd
form.Capture = true;
IntPtr hWnd = GetCapture();
form.Capture = false;

// Get current window extended style
intCurrentExtStyle = GetWindowLong(hWnd, GWL_EXSTYLE);

// Add WS_EX_TOOLWINDOW style to the current window style
intNewExtStyle = intCurrentExtStyle | WS_EX_TOOLWINDOW;

// Apply new style
if (intNewExtStyle != intCurrentExtStyle)
SetWindowLong(hWnd, GWL_EXSTYLE, intNewExtStyle);
}

However, if I call somtemes this function, I get more and more windows
in the task bar, and when I exit the application, they remain there,
but if i click over, nothing happens. Why?

Thanks a lot,
Massimo


Chris Tacke, eMVP ha scritto:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top