Fed up with having to deal with the security warning every time you download a file from the internet? Supress the warning dialog with the instructions found in the first link on this page.
Go to Run -> gpedit.msc
User Configuration -> Administrative Templates -> Windows Components -> Attachment Manager -> Inclusion List for moderate risk file types.
Enable it and in the box specify the extensions such .exe, .jpg, .com
Friday, 5 June 2009
Thursday, 4 June 2009
TreeViewScroll
The .net TreeView doesn't expose a scroll event. Make your own by overriding DefWndProc.
The code above is sufficient for my needs, but if you need more details about the scroll (direction, where you scrolled to, etc) you need to interrogate the message further.
This link should tell you what the message contains:
http://msdn.microsoft.com/en-us/library/bb787577(VS.85).aspx
This link can tell you the scrollbar values:
http://www.pinvoke.net/default.aspx/Enums/ScrollBarCommands.html
public class TreeViewScroll : TreeView
{
private const int WM_VSCROLL = 0x115;
private IntPtr SB_ENDSCROLL = new IntPtr(8);
public event MethodInvoker Scroll;
protected void OnScroll()
{
if (Scroll != null)
Scroll();
}
protected override void DefWndProc(ref Message m)
{
if (m.Msg == WM_VSCROLL)
{
if (m.WParam != SB_ENDSCROLL)
OnScroll();
}
base.DefWndProc(ref m);
}
}
The code above is sufficient for my needs, but if you need more details about the scroll (direction, where you scrolled to, etc) you need to interrogate the message further.
This link should tell you what the message contains:
http://msdn.microsoft.com/en-us/library/bb787577(VS.85).aspx
This link can tell you the scrollbar values:
http://www.pinvoke.net/default.aspx/Enums/ScrollBarCommands.html
Labels:
C#
Thursday, 28 May 2009
Stuck in a rut
Don't get stuck in a rut! Don't miss the wood for the trees!
The other day, I was working out some long, convoluted workaround for dealing with the fact that vector iterators can become invalid if the vector resizes.
Then someone reminded me that you can access elements of a vector by index. D'oh!
The other day, I was working out some long, convoluted workaround for dealing with the fact that vector iterators can become invalid if the vector resizes.
Then someone reminded me that you can access elements of a vector by index. D'oh!
Labels:
Programming
Wednesday, 27 May 2009
If in doubt, wiggle
A few years ago, part of my job involved making large print runs in Microsoft Word - in the region of 500 to several thousand pages per job. While doing this I discovered an unusual quirk.
In the status bar a little animated icon appears alongside a counter that tells you how far through your print job you are. Quite frequently with the large print jobs, I noticed that the counter would freeze on quite a low number. The printer would catch up to the counter and then nothing would happen for a little while.
But if you wanted, you could "remind" Word to carry on printing, by wiggling the moue over the status icon! While the mouse was moving, the status icon's counter was counting upwards - as soon as you stopped moving, the counter stopped counting.
An obvious explanation might be that the counter only repainted when mouse moved over it; but I experimented - the printer didn't print pages unless the status counter was incrementing. Whenever the counter froze, the printer stopped, and as soon as I moved the mouse over the icon, printing resumed.
How odd.
In the status bar a little animated icon appears alongside a counter that tells you how far through your print job you are. Quite frequently with the large print jobs, I noticed that the counter would freeze on quite a low number. The printer would catch up to the counter and then nothing would happen for a little while.
But if you wanted, you could "remind" Word to carry on printing, by wiggling the moue over the status icon! While the mouse was moving, the status icon's counter was counting upwards - as soon as you stopped moving, the counter stopped counting.
An obvious explanation might be that the counter only repainted when mouse moved over it; but I experimented - the printer didn't print pages unless the status counter was incrementing. Whenever the counter froze, the printer stopped, and as soon as I moved the mouse over the icon, printing resumed.
How odd.
Labels:
Anecdote
Sunday, 8 March 2009
Zipping in C#
After spending hours digging around, trying to find the .net solution to zipping folders using c#, the easiest solution seems to be to use the command line for 7zip.
where compressPath is something like "C:\foo.zip" and compressFolder is something like "C:\foo".
Update: 9th March 2009
It's probably a good idea to make sure both compressPath and compressFolder are surrounded by quotes in case they contain spaces!
String zipper = @"c:\program files\7-zip\7z.exe";
String args = "a -tzip " + compressPath + " " + compressFolder;
Process proc = Process.Start(zipper, args);
proc.WaitForExit();
where compressPath is something like "C:\foo.zip" and compressFolder is something like "C:\foo".
Update: 9th March 2009
It's probably a good idea to make sure both compressPath and compressFolder are surrounded by quotes in case they contain spaces!
Labels:
C#
Sunday, 21 December 2008
Terminology: Ensure
What's in a name? Well, quite a lot actually. At best, a poorly chosen name gives little or no insight into the nature of thing it is naming, and at worst the name can be misleading and actually send you down the wrong path entirely. Conversely, well chosen names can convey the meaning, and intent for a variable, method or project.
There's plenty of literature available on the topic, so I'm not going to belabour the point any more, other than to give a couple of examples of names that I try to use consistently in my projects. I'll add other examples as and when I remember them!
The first, I've already mentioned in a previous post, and that name is "Scaffold". To me, it means "something I've put up as a temporary structure, that isn't intended to be there when the final product is released".
The second name is used when I want to get a reference to something that may not have been created yet.
If I was going to create a foo object, I'd probably use "CreateFoo". But I can't use "Create" because the object might already exist.
If I was going to retrieve a foo object, I might use "GetFoo". But again, I can't use "Get" because the object might not have been created yet.
So the term I use in this situation is "Ensure". I think "EnsureFoo" conveys the meaning and is distinct from "Create" and "Get", and doesn't mislead.
There's plenty of literature available on the topic, so I'm not going to belabour the point any more, other than to give a couple of examples of names that I try to use consistently in my projects. I'll add other examples as and when I remember them!
The first, I've already mentioned in a previous post, and that name is "Scaffold". To me, it means "something I've put up as a temporary structure, that isn't intended to be there when the final product is released".
The second name is used when I want to get a reference to something that may not have been created yet.
If I was going to create a foo object, I'd probably use "CreateFoo". But I can't use "Create" because the object might already exist.
If I was going to retrieve a foo object, I might use "GetFoo". But again, I can't use "Get" because the object might not have been created yet.
So the term I use in this situation is "Ensure". I think "EnsureFoo" conveys the meaning and is distinct from "Create" and "Get", and doesn't mislead.
Labels:
Programming
Saturday, 20 December 2008
Delete the font
Originally, I could read every website that was thrown at me.
Then, ClearType arrived, and I had the option of "improving" the readability on my LCD screen. I tried ClearType and decided I prefered my text without ClearType, so turned it off. Things were still fine.
But then, sites started using fonts that seemed to rely on ClearType to be clear enough to read. The fonts I struggled with were mainly Calibri, Segoe and Vera.
(I won't bother posting screenshots, because you won't be able to see them as they appear on my monitor.)
I tried to find ways to disable certain fonts on websites, replace font X for Y, make a global stylesheet change, but in the end, I found the way to make readable the sites that use those fonts, was simply to delete the fonts that I struggled to read. :)
Then, ClearType arrived, and I had the option of "improving" the readability on my LCD screen. I tried ClearType and decided I prefered my text without ClearType, so turned it off. Things were still fine.
But then, sites started using fonts that seemed to rely on ClearType to be clear enough to read. The fonts I struggled with were mainly Calibri, Segoe and Vera.
(I won't bother posting screenshots, because you won't be able to see them as they appear on my monitor.)
I tried to find ways to disable certain fonts on websites, replace font X for Y, make a global stylesheet change, but in the end, I found the way to make readable the sites that use those fonts, was simply to delete the fonts that I struggled to read. :)
Labels:
Misc
Subscribe to:
Posts (Atom)