Click here to Skip to main content
16,006,382 members
Home / Discussions / C#
   

C#

 
AnswerRe: Web-style UI with re-flow - seen any examples? Pin
sreejith ss nair9-Sep-04 23:41
sreejith ss nair9-Sep-04 23:41 
GeneralRe: Web-style UI with re-flow - seen any examples? Pin
Mal Ross9-Sep-04 23:47
Mal Ross9-Sep-04 23:47 
AnswerRe: Web-style UI with re-flow - seen any examples? Pin
mav.northwind10-Sep-04 1:45
mav.northwind10-Sep-04 1:45 
AnswerRe: Web-style UI with re-flow - seen any examples? Pin
mav.northwind10-Sep-04 2:45
mav.northwind10-Sep-04 2:45 
GeneralRe: Web-style UI with re-flow - seen any examples? Pin
Mal Ross10-Sep-04 4:46
Mal Ross10-Sep-04 4:46 
Generalcall Javascript Function Pin
Ikarus769-Sep-04 22:16
Ikarus769-Sep-04 22:16 
Generaldisable cross button Pin
xiaowenjie9-Sep-04 20:22
xiaowenjie9-Sep-04 20:22 
GeneralRe: disable cross button Pin
Jay Shankar9-Sep-04 20:56
Jay Shankar9-Sep-04 20:56 
Hi Cris,
It involves P/Invoking
1.GetSystemMenu
2.GetMenuItemCount
3.RemoveMenu
4.DrawMenuBar

API methods declaration and DisableCloseButton function can be written as below:

//API function declaration
[DllImport("user32.Dll")]
public static extern IntPtr RemoveMenu(int hMenu, int nPosition,long wFlags); 

[DllImport("User32.Dll")]
public static extern IntPtr GetSystemMenu(int hWnd, bool bRevert);

[DllImport("User32.Dll")]
public static extern IntPtr GetMenuItemCount(int hMenu);

[DllImport("User32.Dll")]
public static extern IntPtr DrawMenuBar(int hwnd);
//



//constants declaration
private const int MF_BYPOSITION = 0x400;
private const int MF_REMOVE = 0x1000;
private const int MF_DISABLED = 0x2;
//




public void DisableCloseButton(int hWnd)
{
	IntPtr hMenu;
	IntPtr menuItemCount;

	//Obtain the handle to the form's system menu
	hMenu = GetSystemMenu(hWnd, false);

	// Get the count of the items in the system menu
	menuItemCount = GetMenuItemCount(hMenu.ToInt32());

	// Remove the close menuitem
	RemoveMenu(hMenu.ToInt32(), menuItemCount.ToInt32() - 1,MF_DISABLED | MF_BYPOSITION);

	// Remove the Separator 
	RemoveMenu(hMenu.ToInt32(), menuItemCount.ToInt32() - 2,MF_DISABLED | MF_BYPOSITION);

	// redraw the menu bar
	DrawMenuBar(hWnd);
}


Do revert back whether it could do the desired thing or not.

Please Note that User can also close the application using Alt+F4. you should handle that aspect as well, which can be done very easily by overriding wndProc method.

Regards,

Jay
GeneralRe: disable cross button Pin
Stefan Troschuetz10-Sep-04 2:39
Stefan Troschuetz10-Sep-04 2:39 
Questionhow to import COM DLL in ASP.NET using C# Pin
zahid_ash9-Sep-04 19:09
zahid_ash9-Sep-04 19:09 
AnswerRe: how to import COM DLL in ASP.NET using C# Pin
sreejith ss nair9-Sep-04 20:00
sreejith ss nair9-Sep-04 20:00 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
zahid_ash9-Sep-04 20:37
zahid_ash9-Sep-04 20:37 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
sreejith ss nair9-Sep-04 21:10
sreejith ss nair9-Sep-04 21:10 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
zahid_ash9-Sep-04 21:37
zahid_ash9-Sep-04 21:37 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
sreejith ss nair9-Sep-04 22:36
sreejith ss nair9-Sep-04 22:36 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
zahid_ash9-Sep-04 23:15
zahid_ash9-Sep-04 23:15 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
sreejith ss nair9-Sep-04 23:29
sreejith ss nair9-Sep-04 23:29 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
zahid_ash10-Sep-04 0:03
zahid_ash10-Sep-04 0:03 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
sreejith ss nair10-Sep-04 0:12
sreejith ss nair10-Sep-04 0:12 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
zahid_ash10-Sep-04 0:23
zahid_ash10-Sep-04 0:23 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
sreejith ss nair10-Sep-04 0:34
sreejith ss nair10-Sep-04 0:34 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
zahid_ash10-Sep-04 0:44
zahid_ash10-Sep-04 0:44 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
sreejith ss nair10-Sep-04 0:51
sreejith ss nair10-Sep-04 0:51 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
zahid_ash10-Sep-04 0:57
zahid_ash10-Sep-04 0:57 
Generallike operator in C# Datatable Pin
Ruchi Gupta9-Sep-04 14:39
Ruchi Gupta9-Sep-04 14:39 

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.