|
It's the 'Control Box' option.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Removing the control box gets rid of minimize and maximize too.
This method just disables the close button and the Close menu item in the form's context menu. Make sure that you give the user a clean way to close the form though!
public Form1()
{
InitializeComponent();
EnableMenuItem(GetSystemMenu(this.Handle, false), SC_CLOSE, MF_GRAYED);
}
private const int SC_CLOSE = 0xf060;
private const int MF_GRAYED = 0x0001;
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern int EnableMenuItem(IntPtr hMenu, int uIDEnableItem, int uEnable);
Edit: I should add - to enable it again if you need to declare this constant:
private const int MF_ENABLED = 0x0000;
and the code to perform the enable is:
EnableMenuItem(GetSystemMenu(this.Handle, false), SC_CLOSE, MF_ENABLED);
Dave
modified on Friday, February 22, 2008 6:14 AM
|
|
|
|
|
Just tested it; it works, but Alt+F4 still closes the form.
|
|
|
|
|
Forgot that one! The code below handles that
private const int WM_SYSKEYDOWN = 0x0104;
private bool handleAltF4 = true;
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
if (msg.Msg == WM_SYSKEYDOWN)
{
switch (keyData)
{
case System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4:
{
return handleAltF4;
}
}
}
return false;
}
Dave
|
|
|
|
|
I finally got around to trying that, I doubt I'd ever need it, but it's good to have, thanks!
|
|
|
|
|
Hey guys!
I just wanted to invite you to download my new development app, it is called CodeForms Lite v4.0, it's compatible with Delphi, C#.NET, VB.NET and VB6, please send me your comments about it, you can donwnload it for free from this address:
http://www.neuronlabs.com/download.html
It is FULLY FUNCTIONAL and IS NOT a limited time demo!
Enjoy it!
Regards
Rafael Agundis
|
|
|
|
|
So, write an article...
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi, I'm playing around with a form and I want it to know if I've changed the contents of a combo box (selecting a new index that is, it doesn't take text extry) placed on it.
So I just made a global bool variable 'ComboBoxChanged' initialized as FALSE, and I set it to TRUE upon handling the ComboBox.SelectedIndexChanged event.
The problem I have is that the event is triggered when the form is loaded, thus setting my 'ComboBoxChanged' variable event though I haven't actually selected a new index.
What do you guys think is the best solution to this?
Thanks for any help.
|
|
|
|
|
Don't use global varuables ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
When the combo box is being populated, the selected index changed is fired on every item (don't ask me why). So you may need another form wide variable or in your inherited combo box to keep track of whether the combo box is being populated.
|
|
|
|
|
An easy work around for this is to set enabled to false before populating it then to true when it's finished. You can then check the enabled state in the SelectedIndexChanged and only alter your global variable if Enabled == true;
Dave
|
|
|
|
|
hi frnds,
I have a requirement for serializing an object to XMLDocument Object. I have got few examples of converting a class with few properties to a simple XML as below:
Class:
class Person<br />
{<br />
private string strName;<br />
private int iAge;<br />
<br />
public String Name{<br />
get{ return strName; }<br />
set{ strName= value; }<br />
}<br />
public int Age{<br />
get{ return iAge; }<br />
set{ iAge= value; }<br />
}<br />
}
XML:
<Person><br />
<Name>Anthony</Name><br />
<Age>38</Age><br />
</Person>
Now the problem is that my XML is not this simple. It would be something like:
<Company>
<Name> </Name>
<Employee>
<Name>A</Name>
<Age>1</age>
</Employee>
<Employee>
<Name>B</Name>
<Age>2</Age>
</Employee>
..
..
..
</Company>
Do we need to use composition here?? Any suggestions??
Thanks
Keep DotNetting!!
GeekFromIndia
|
|
|
|
|
geekfromindia wrote: composition here
yes
class Name
{
string First;
string Middle;
string Last;
};
class Employee
{
Name Name;
int Age;
};
class Company
{
string Name;
List<Employee>
}
Silence is the voice of complicity.
Strange women lying in ponds distributing swords is no basis for a system of government. -- monty python
Might I suggest that the universe was always the size of the cosmos. It is just that at one point the cosmos was the size of a marble. -- Colin Angus Mackay
|
|
|
|
|
ahhz wrote: class Company{ string Name; List<employee>}
I am using 1.1 here so Name and Employee will be classes instead of string or generic list.
maybe something like
class Company<br />
{<br />
Employee objEmployee;<br />
Name objName;<br />
}
but i m still not sure how it can be initilialized with multiple employees?
Property with Employee Array??
Keep DotNetting!!
GeekFromIndia
|
|
|
|
|
class Company
{
string Name;
Employee[] employeList;
}
Silence is the voice of complicity.
Strange women lying in ponds distributing swords is no basis for a system of government. -- monty python
Might I suggest that the universe was always the size of the cosmos. It is just that at one point the cosmos was the size of a marble. -- Colin Angus Mackay
|
|
|
|
|
public class Person<br />
{<br />
string m_Name;<br />
int m_Age;<br />
}<br />
<br />
public class Company<br />
{<br />
string m_Name;<br />
[XmlArray(ElementName="Employee", Namesapce="...")]<br />
Person[] m_Persons;<br />
}
only two letters away from being an asset
|
|
|
|
|
I'm making a memory reading application, but after some programming I noticed I actually get the same result for no matter which process. I'll give a very clear example of my problem. This piece of code opens three processes, and reads their memory at position 0x0000FFFF. The processes can be whatever I want (as long as they're running, obviously), but for this example I took Firefox, TeaTimer (background process of Spybot) and Nexcal (a calculator program).
<br />
public static void Test()<br />
{<br />
IntPtr bytesRead = new IntPtr();<br />
<br />
IntPtr firefox = OpenProcess(PROCESS_ALL_ACCESS, 0, (uint)Process.GetProcessesByName("firefox")[0].Id);<br />
byte[] firefoxBuffer = new byte[3];<br />
Trace.WriteLine("Firefox reading success: " + ReadProcessMemory(firefox, new IntPtr(65536), firefoxBuffer, (uint)3, out bytesRead));<br />
foreach (byte b in firefoxBuffer)<br />
{<br />
Trace.WriteLine(b.ToString());<br />
}<br />
CloseHandle(firefox);<br />
<br />
IntPtr tea = OpenProcess(PROCESS_ALL_ACCESS, 0, (uint)Process.GetProcessesByName("TeaTimer")[0].Id);<br />
byte[] teaBuffer = new byte[3];<br />
Trace.WriteLine("TeaTimer reading success: " + ReadProcessMemory(tea, new IntPtr(65536), teaBuffer, (uint)3, out bytesRead));<br />
foreach (byte b in teaBuffer)<br />
{<br />
Trace.WriteLine(b.ToString());<br />
}<br />
CloseHandle(tea);<br />
<br />
IntPtr nex = OpenProcess(PROCESS_ALL_ACCESS, 0, (uint)Process.GetProcessesByName("Nexcal")[0].Id);<br />
byte[] nexBuffer = new byte[3];<br />
Trace.WriteLine("Nexcal reading success: " + ReadProcessMemory(nex, new IntPtr(65536), nexBuffer, (uint)3, out bytesRead));<br />
foreach (byte b in nexBuffer)<br />
{<br />
Trace.WriteLine(b.ToString());<br />
}<br />
CloseHandle(nex);<br />
}<br />
Now here's the output of this code:
Firefox reading success: 1
61
0
58
TeaTimer reading success: 1
61
0
58
Nexcal reading success: 1
61
0
58
I even used different buffers just so I won't make a mistake with accidentally just printing the previous result again. Anyways, it explicitly says it succeeded reading that certain process at that certain position of their memory, but it still returns exactly the same result for the three processes. Now I was thinking this might be an absolute memory location I'm reading. But that wouldn't explain why I'd have to pass a process handle to the kernel32 functions. And it would make it all very complicated and quite useless.
|
|
|
|
|
look here: http://www.codeproject.com/KB/trace/minememoryreader.aspx[^]
Silence is the voice of complicity.
Strange women lying in ponds distributing swords is no basis for a system of government. -- monty python
Might I suggest that the universe was always the size of the cosmos. It is just that at one point the cosmos was the size of a marble. -- Colin Angus Mackay
|
|
|
|
|
I tried the example you gave, and it gives exactly the same result as my code. Hehehe, it seems my code was just totally perfect. Apparently many processes in Windows have certain pieces of their allocated memory identically. Is it some Windows-header or so? Anyway, I tried some other more unusual processes, like winlogon.exe (some Windows process), and he just gives something else. And I also tried some other memory positions alot further than 0xFFFF, like 0x20083, and that gives results different from process to process.
Just got unlucky to try the wrong processes at the wrong places.
Edit: I suddenly notice I actually succeeded reading the memory of a windows process (winlogon.exe), it didn't work after I tried it again...
|
|
|
|
|
Hi,
I need to create a simple e-mail application with basic functionality using C#. I dont want the source code but i would really appreciate if anyone could guide me as to what i should do...
Thanx,
Nadeem.
P.S: Im a comlete n00b in C#.
|
|
|
|
|
look at the open source ThunderBird project.
Silence is the voice of complicity.
Strange women lying in ponds distributing swords is no basis for a system of government. -- monty python
Might I suggest that the universe was always the size of the cosmos. It is just that at one point the cosmos was the size of a marble. -- Colin Angus Mackay
|
|
|
|
|
I dont think u got me .... im a n00b . if i could go through the code of thuderbird, i wouldnt have been here and i dont think Thunderbird has been developed using purely C# ....
Thanx anyway 4 ur time...
N.
|
|
|
|
|
if you're a n00b, then it doesn't really matter which language you use to learn the ideas. they can be applied in any language.
And, that's how I learned: by studying code other excellent programmers wrote (don't personally know if that really applies to thunderbird code).
programming is programming regardless of language used. what you learn can be applied to C#.
There is the System.Net.Mail namespace that has a lot of stuff in it that you'd need.
Why not get started trying something and then ask more appropriate, *small-scope* questions.
First break down the problem into smaller pieces. Then break those pieces into even smaller pieces and repeat until you get something that you can do in a few steps. accomplish all those smallest pieces, and you will have solved the larger ones.
Silence is the voice of complicity.
Strange women lying in ponds distributing swords is no basis for a system of government. -- monty python
Might I suggest that the universe was always the size of the cosmos. It is just that at one point the cosmos was the size of a marble. -- Colin Angus Mackay
|
|
|
|
|
Why do you need to create a mail program ? There's plenty out there.
N4D33M wrote: Im a comlete n00b in C#.
Then if this is a job you've accepted, you should let them know it is beyond you. If it's a personal project, start with something more within your reach. Most people who give up on programming, do so because they didn't set themselves reasonable goals. They expected to start big, instead of learning at a reasonable pace.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanx u all for your replies ...i guess i will have to study a bit more before i delve into such projects .... btw its a project just for fun and information ....
N4D33M.
|
|
|
|