Non active window

  • Thread starter Thread starter Daniel Bello Urizarri
  • Start date Start date
D

Daniel Bello Urizarri

Is there any way to show a non active window? I mean, to sow a focus-less
window, like a tooltip, for instance.

I know that using ShowWindow (hwnd, SW_NOACTIVE ) in Win32 api works fine,
but i like my application to run on other systems.
 
Man, do we have .Net working on systems other than Windows at the time
being? Never heard about it.

Yuri
 
I'm actually looking for the same thing. I have MDI
application with few toolbar windows, but they all show
as inactive when the focus is in regular child window.
How would I use ShowWindow(hwnd, SW_NOACTIVE) to make it
work? I don't care about making it work with other
systems.
 
Hi Andrew:

I don't understand exactly what you are doing, but hope this help:

You must first declare:

[System.Runtime.InteropServices.DllImport ("User32.dll")]
public static extern void ShowWindow ( IntPtr hWnd, int val );

so you can use the function, no refererences are needed, so you only have to
pass in the first parameter the handle (Form.Handle) of the form you want to
show
and one of the following constants (just the integer value)

/*
* ShowWindow() Commands
*/
#define SW_HIDE 0
#define SW_SHOWNORMAL 1
#define SW_NORMAL 1
#define SW_SHOWMINIMIZED 2
#define SW_SHOWMAXIMIZED 3
#define SW_MAXIMIZE 3
#define SW_SHOWNOACTIVATE 4
#define SW_SHOW 5
#define SW_MINIMIZE 6
#define SW_SHOWMINNOACTIVE 7
#define SW_SHOWNA 8
#define SW_RESTORE 9
#define SW_SHOWDEFAULT 10
#define SW_FORCEMINIMIZE 11
#define SW_MAX 11
 
Thanks for the reply.
I'm trying to have MDI application to have other forms as
toolbar windows. Currently when I show other toolbar
windows: toolbarForm.Show(), it's title bar becomes
inactive when I switch focus to other form of the same
application.
I tried using ShowWindow(handle, SW_SHOWNOACTIVATE), but
it doesn't do it.
I want the windows title bar to always be active, even if
I click on (give focus) to other form of the MID
application.
 
Take a look at WM_NCACTIVATE -- that's how the form gets notified that
it's inactive (and should paint itself as inactive). You can either
override WndProc in your toolbar form, or do a SendMessage from another
form into tricking the toolbar form to paint as active.
 
I've never done any windows programming prior to .net, so
I'm not really familiar with internal workings of windows.
Here is what I got so far, and this seems to work.
This is part of my tool window:

const int WM_NCACTIVATE = 0x0086;

protected override void WndProc(ref Message m)
{
if (m.Msg == WM_NCACTIVATE)
{
if (m.WParam == (IntPtr)1)
{
MainForm.DoWndProc(m);
base.WndProc(ref m);
}
else
{
m.WParam = (IntPtr)1;
base.WndProc(ref m);
}
}
else
base.WndProc (ref m);
}

I'm not really sure about MainForm.DoWndProc. I just
wrote this so that the main window doesn't lose it's
active title bar when user switches to the toolbar
window, so I just send a fake WM_NCACTIVATE message to
main window.
It works, but there are few problems. When I have another
window on top of main window, or open modal dialog, the
tool window always stays active.
I wish there was just some property to be set on a form
to indicate that it's toolbar window and always should be
active.
 
Back
Top