PC Review


Reply
Thread Tools Rate Thread

Form without Titlebar

 
 
Graeme Richardson
Guest
Posts: n/a
 
      23rd Dec 2004
Hi, I'm trying to implement a form that has no titlebar but still displays a
Minimise and Close button. I've set the Form style to None, ControlBox to
False, and included a menu.
I'm looking for a window style similar to WordPad or Explorer.
What's the trick to getting the Close button to display?

Thanks, Graeme.


 
Reply With Quote
 
 
 
 
Sergey Bogdanov
Guest
Posts: n/a
 
      24th Dec 2004
WordPad and Explorer uses separate toolbar for displaying Close button.
Due to this fact that CF.NET (1.0) doesn't support more than one toolbar
it's not so easy implement.

Actually if you would like to repeat something similiar you have to
write native control wrappers at least for "ReBarWindow32" (container
for toolbars), "ToolbarWindow32".

Here is a simple example how to create "ReBarWindow32":

....

private IntPtr GetHandle(System.Windows.Forms.Control c)
{
c.Capture = true;
IntPtr hwnd = GetCapture();
c.Capture = false;
return hwnd;
}

public ReBar(System.Windows.Forms.Control parent)
{
INITCOMMONCONTROLSEX c = new INITCOMMONCONTROLSEX();

c.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES;
InitCommonControlsEx(c);

//get instance handle
IntPtr m_instance = Core.GetModuleHandle(null);

IntPtr parent_hwnd = GetHandle(parent);
IntPtr styles = (IntPtr)((int)(Win32Window.WindowStyle.WS_CHILD |
Win32Window.WindowStyle.WS_VISIBLE |
Win32Window.WindowStyle.WS_BORDER) |
RBS_VARHEIGHT | RBS_BANDBORDERS | CCS_NODIVIDER | CCS_NOPARENTALIGN);
handle = OpenNETCF.Win32.Win32Window.CreateWindowEx(IntPtr.Zero,
"ReBarWindow32", "",
styles, 0, 0, parent.Width, parent.Height, parent_hwnd, IntPtr.Zero,
m_instance, IntPtr.Zero);

//create control
//_msgwnd = new ControlMessageWindow(this, handle);
}

....

[StructLayout(LayoutKind.Sequential)]
internal class INITCOMMONCONTROLSEX
{
public INITCOMMONCONTROLSEX()
{
dwSize = Marshal.SizeOf(this);
}

public int dwSize;
public int dwICC;
}

const int RBS_VARHEIGHT = 0x0200;
const int RBS_BANDBORDERS = 0x0400;
const int CCS_NODIVIDER = 0x00000040;
const int CCS_NOPARENTALIGN = 0x00000008;

const int ICC_COOL_CLASSES = 0x400;
const int ICC_BAR_CLASSES = 0x004;

[DllImport("coredll.dll")]
internal extern static IntPtr GetCapture();

[DllImport("Commctrl.dll")]
private static extern bool InitCommonControlsEx(INITCOMMONCONTROLSEX c);

HTH
Sergey

Graeme Richardson wrote:
> Hi, I'm trying to implement a form that has no titlebar but still displays a
> Minimise and Close button. I've set the Form style to None, ControlBox to
> False, and included a menu.
> I'm looking for a window style similar to WordPad or Explorer.
> What's the trick to getting the Close button to display?
>
> Thanks, Graeme.
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Maximized MDI Child form with no titlebar shifts form David W Microsoft Dot NET Framework Forms 0 16th Feb 2007 07:55 PM
Form's TitleBar Mystique Microsoft C# .NET 0 24th Aug 2006 01:36 PM
Form with no titlebar Keith Microsoft VB .NET 1 16th Feb 2006 01:28 AM
Form without titlebar PR Microsoft Dot NET Compact Framework 1 22nd Sep 2004 02:00 PM
How do you do a form with no titlebar Will Pittenger Microsoft C# .NET 6 3rd Apr 2004 09:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:51 PM.