|
Absolutely agree, Jeffrey Richter's book is awesome! Really teaches you an awful lot, I'm quite looking forward to getting my hands of Jeff Prosise's .NET book when its eventually in the shops -- the MFC book had to be the best one I've read particularly when I was first starting with VC++.
Anyone got any kind of insider knowledge about how good it is?
|
|
|
|
|
Can anyone help with this question - i'm trying to trap the MouseWheel event of a scrollbar control placed on a form, and although this doesn't appear as an event at design-time i can create an event at run-time to handle it, ie:
vScrollBar1.MouseWheel += new System.Windows.Forms.MouseEventHandle(WheelEventHandler);
Problem is that this doesn't trap the wheel scroll event at all even although i'm convinced this is how to do it.
I know it ain't a visible event at design time and similarly it's a MouseEventHandler instead of just an EventHandler (used for MouseDown/Hover/Leave etc) and bearing this in mind how do i trap it?
Cheers
Martin D
|
|
|
|
|
Have you tried to override the event?
<code>
protected override void OnMouseWheel(System.Windows.Forms.MouseEventArgs e)
{
MessageBox.Show("I moved the mousewheel");
}
</code>
Nick Parker
|
|
|
|
|
Yeah i've tried overriding it but nothing. I've also tried creating a UserControl (Windows Control Library) and inheriting my class from "System.Windows.Forms.VScrollBar" but this doesn't do anything for the MouseWheel event, although it does seem to work for SystemEventHandlers as i suggested earlier.
Another point to note is that this is only a problem on our Win2000 boxes - we've got an XP box and the original "vScrollBar1.MouseWheel += New etc etc..." works fine on that, even although MSDN suggests Win2000 should be OK as well - a bug....?
Martin D
|
|
|
|
|
OK now for the most bizarre solution of the day....if ur Wheel Settings on Control Panel / Mouse Properties has 'Enable Enhanced Scrolling' checkbox then Uncheck it and hey presto - it works again.
Seems that even although you have to check this to modify the no. of 'scroll by' lines, it has to be Unchecked to allow the scrolling wheel facility in the first place!
Not only does this seem a bit back-to-front but not all mouse devices have them so watch out - also it's not something that can be found by interrogating the SystemInformation options in the code either...
|
|
|
|
|
I have a program which calculate the time i spent on the phone and I want to create a report to print. I got it by drawing each control on my form and the text, the image also, but i want to know if is there a solution I can use for all my futur report project. I tried Crystal Report but It's too hard for me, i don't understand how it's work and I don't want to spend my time on learning CR.
Anyone have an answer please ??
Thanks
|
|
|
|
|
... it will change all text when next text will be added!!!!
Like this, in my RichTextBox I handle TextChanged and do this code in it:
private void richTextBox1_TextChanged(object sender, System.EventArgs e)
{
// 'str' is the palayer name
String str = "Rickard Andersson:";
int howMany = str.Length;
int startAt;
// loop through the RichTextBox whole text to find 'str'
// with no Bold style... if we find 'str' with no Bold syle
// then we make it Bold
do
{
startAt = this.richTextBox1.Find(str);
if(startAt != -1)
{
this.richTextBox1.Select(startAt,howMany);
Font oldFont;
Font newFont;
// Get the font of 'str'
oldFont = this.richTextBox1.SelectionFont;
// If we found a 'str' with no Bold style, make 'str' Bold
if (!oldFont.Bold)
{
newFont = new Font(oldFont, FontStyle.Bold);
// Give the non-Bold 'str' bold style now
this.richTextBox1.SelectionFont = newFont;
this.button1.Focus();
break;
}
}
}
while(startAt == -1);
}
I have test this code with two buttons on my form, those add text like: "Rickard Andersson: Hell oman" and "Mike: Hello you too!"
And if "Rickard Andersson: Hell oman" will be added the "Rickard Andersson:" will be bold. But when I press the other button which add "Mike: hello to you too" ALL text will be bold instead of no change at all... what's wrong, dude!?
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Can anyone help me with C++ code that will allow me to offer the user the choice to restart the computer from a windows dialog box?
Kyle
|
|
|
|
|
ExitWindowsEx(EWX_REBOOT,SHTDN_REASON_MAJOR_APPLICATION);
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
where is ExitWindowsEx in the .NET Framework? I can't find it anywhere.
|
|
|
|
|
It isn't, you need to use P/Invoke; kyle posted to the wrong forum
[DllImport("user32.dll")]<br />
public external static bool ExitWindowsEx(uint uFlags, int dwReason);
Search through the Vc7\PlatformSDK\Include directory to get the constants needed for the paramters.
James
Simplicity Rules!
|
|
|
|
|
I did think I was in the C++ forum when I posted. Please accept my apology. Your answer was excellent and it made me question, is there a way to restart the computer using C# managed code?
Kyle
|
|
|
|
|
kyledunn wrote:
Please accept my apology.
No problems
kyledunn wrote:
is there a way to restart the computer using C# managed code?
AFAIK there isn't; I haven't run across one anyway.
James
Simplicity Rules!
|
|
|
|
|
It is very doable from WMI API wrapped in the .NET System.Managment namespace. You can reboot/shutdown the local or any other machine on the domain. Depending on the privileges you or your admin have set, your mileage will vary.
Regards
|
|
|
|
|
using System.Management;
.
.
.
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem WHERE Primary = TRUE");
ManagementBaseObject inParams;
ManagementBaseObject outParams;
bool temp;
foreach (ManagementObject os in searcher.Get())
{
temp = os.Scope.Options.EnablePrivileges;
os.Scope.Options.EnablePrivileges = true;
inParams = os.GetMethodParameters("Reboot");
outParams = os.InvokeMethod("Reboot", inParams, null);
os.Scope.Options.EnablePrivileges = temp;
}
You can also specify Shutdown for the method...
|
|
|
|
|
i want to delete bmp from the hard(no specified location), is this possible!!!
|
|
|
|
|
Zzzz wrote:
no specified location
????????
But if you have a "specified location" then you can use FileSystemInfo to open a file and then use the member method Delete() to delete it.
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Zzzz wrote:
(no specified location)
You mean that the files location may change, is that correct? Or are you actually doing a search for the file each time to find the location?
Nick Parker
|
|
|
|
|
yeah that's what i meant, or we may say that at runtime i cannot specify the location, i can only know the filename..
|
|
|
|
|
The static File.Delete method
|
|
|
|
|
It's not a good idea to delete all bmps in a hard disk
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
surely i won't delete all the bitmaps from the hard.!!!!!!
|
|
|
|
|
Zzzz wrote:
surely i won't delete all the bitmaps from the hard.!!!!!!
Sorry I misunderstood the question.
I still havent understood what exectly you want to know!
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
it's okay
here what i want,
at runtime, some bitmaps will b generated but if something wrong happned, i'll have to delete these files, without knowing where they are, only their names, Got it, anyway thanx
|
|
|
|
|
Zzzz wrote:
some bitmaps will b generated
If you are doing the generation, surely you'd know the folder where it's being generated.
Zzzz wrote:
without knowing where they are, only their names
You can concatenate the folder where you generate them with their file names and pass this string to the File.Delete function
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|