|
Hi,
is there a way to disable the X (close) button in the title bar of a Form?
I don't want to completely remove the controls from the title bar because I want to have the icon and the minimize button still visible.
I tried a few ways based on the override of the WndProc method, but they didn't work, probably because they were in VB6 and porting them to C# broke something.
Thanks for any help.
|
|
|
|
|
I guess thats not possible. Even I wanted the same thing some time ago but failed to do it. i even tried with some java scripts there also i failed to get a result. So i guess it is not possible.
Vipin
|
|
|
|
|
Hello Friend,
As i get your problem.
Try this solution.
Firstly Declair a bool IsClose = false;
Then in,
protected override void Dispose( bool disposing )
{
if(IsClose)
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
}
Make IsClose = true
when you want to close the form and then
call Dispose(true);
Rahul Kulkarni
|
|
|
|
|
I already use this method, but the close button is still enabled, so when the user clicks on it, nothing happens and it has not a good feeling.
Thanks anyway.
|
|
|
|
|
const int SC_CLOSE = 0xF060;
const int MF_BYCOMMAND = 0x0;
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern IntPtr RemoveMenu(IntPtr menuHwnd, int position, int flags );
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern IntPtr GetSystemMenu(IntPtr hwnd, int bRevert);
public static void EnableApplicationClose( System.Windows.Forms.Form form, bool val )
{
IntPtr menu = GetSystemMenu( form.Handle, val ? 1 : 0 );
if ( !val && menu != IntPtr.Zero )
RemoveMenu( menu, SC_CLOSE, MF_BYCOMMAND );
else
{
form.Enabled = false;
form.Enabled = true;
}
}
|
|
|
|
|
Thank you so much!
It's exactly what I was looking for!
|
|
|
|
|
In my project I m created DataGrid TableStyle and DataGrid Text coloumn when clicking on textcolumn contain of that coloumn display in the next form.
my problem is before sorting code working fine but when i m doing sorting and clicking on any datagridtextcoloumn it displaying before sorting data.
i m binding datagrid with type dataset.
sorting base on datagrid header row.
help me it's very urgent.
|
|
|
|
|
can u make it little more clearer please. I didnt get u.
Vipin
|
|
|
|
|
I m binding datagrid with schema, datagrid having five column datetime ,seqno,networkid,type,message etc.
i created datagridtablestyle.
datagridtablestyle allowsorting property is true.
when i m clicking on datagrid header it doing should sorting according to that.
when i m double clicking on any datagridtextcolumn,i m finding on which row and which coloumn i clicked then i m displaying the cell value in the next form.this is also working but before sorting.
after sorting when i m doing samething it displaying before sorting data.
for example
there are three coloumn in datagrid
before sortin
Id type Message
1 m Hello
2 e bye
3 s Yes
when i m double clicking on any row or coloumn it display message coloumn value in the next form.
suppose i m doing sorting on message colomn
After sorting
Id type Message
2 e bye
1 m Hello
3 s Yes
when i m double clicking on any row or coloumn it display message coloumn value in the next form.
suppose i clicked on Hello that's second row third coloumn ,so it should display Hello in next form but it's displaying old one that is "Bye"
even though i m using data grid referesh propertie and re binding the datagrid also.
but result is same.
|
|
|
|
|
Hello Frieds,
Can we do application which will get time and date from any datetime site
and synchronize the time of client machine in C#.Net windows application ONLY.
Code, Helpfull sites needed.
Thanks in Advance.
Rahul Kulkarni
|
|
|
|
|
http://msdn2.microsoft.com/en-us/library/k8azesy5.aspx
Then you can use the string you get to set the machine time. Probably using DOS Command.
|
|
|
|
|
Why did you delete the exact same question posted an hour or 2 ago?
|
|
|
|
|
Hi, I have a very serious problem and i've been making researches for almost a week now. i need to force wmp activex to switch aspect-ratio like 16:9 or 4:3.
Please it is really important and i'm a little bit out of schedule.
I'm using c# technology so if anyone can help me i would really appreciate it.
thank you
Souhail Jabbour
Souhail J Jabbour
Software Developer
Activemania.com
|
|
|
|
|
Hi,
Is there an easy way to find out if a string contains a valid date?
Example:
string dateStr = "060101"; //format is yymmdd
TIA,
Ed
VagaBond
|
|
|
|
|
I forgot to add that the try/catch method of determining the validity is not really desired 'cuz according to our standards - "Exceptions are used to indicate that an error has occurred while running the program".
VagaBond
|
|
|
|
|
Use the DateTime.TryParseExact method.
---
b { font-weight: normal; }
|
|
|
|
|
static bool IsDateTimeOk(string input)
{
try
{
int year = int.Parse(input.Substring(0, 2)) + 2000;
int month = int.Parse(input.Substring(2, 2));
int day = int.Parse(input.Substring(4, 2));
int maxDaysInFeb = 28;
if(year % 4 == 0 && year % 100 != 0 && year % 400 == 0)
maxDaysInFeb = 29;
if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
if(day >= 1 && day <= 31)
return true;
else if(month != 2)
if(day >= 1 && day <= 30)
return true;
else
if(day >= 1 && day <= maxDaysInFeb)
return true;
return false;
}
catch
{
return false;
}
}
|
|
|
|
|
Thanks, I'll give this a try, after I delete the try/catch...
VagaBond
|
|
|
|
|
Hi folks,
I have 2 forms, forn1 and form2, how can I access or reference form1 from form2?
Thanks, Ben.
|
|
|
|
|
by creating instance of form1 in form2
form1 frm = new form1();
rahul
|
|
|
|
|
Perfect, thanks
|
|
|
|
|
How to open particular tabpage when click mouse-right button?
|
|
|
|
|
i have 2 functions:
void Log(LogTypes type, string message, string context);
void Log(LogTypes type, string message, params object[] parameters);
when i use the following call:
Logger.Log(LogTypes.Message, "{0} test", "ddd"); // the "{0}" will be
// replaced by "ddd" in format message
i get to a problem - how can i force the usage of either one of the functions in the call (for example - one time i want "ddd" to be a context and in another - be a parameter)
Any ideas?
Thanks.
|
|
|
|
|
The easiest way I can think of is make Context a class called "LogContext". It could be as simple as a wrapper around a string, but at least it differentiates it from a string parameter used in the params argument.
One other point, in the naming of your enum. Enums should be singular tense, unless it can be used in a bitmasked way (ie/ are marked with the FlagsAttribute).
so for example,
LogType.Message <-- singlular as you can only use one at a time
UserGroups.User | UserGroups.Administrator <-- example of bitmasked enums
|
|
|
|
|
Thanks. this would probably be the best solution.
|
|
|
|