tag:blogger.com,1999:blog-52325925112688033252024-02-21T03:04:48.534+00:00Programming for PeopleTimhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.comBlogger55125tag:blogger.com,1999:blog-5232592511268803325.post-54664841709570210202018-01-07T12:03:00.000+00:002018-01-07T12:03:40.853+00:00Connor's Portal 2 levelsConnor has been playing portal 2 since he was 3 years old, and has been making his own levels almost as long.<br />
<br />
He's published 10 levels so far - they can be found here:<br />
<a href="https://steamcommunity.com/profiles/76561198325470848/myworkshopfiles/?appid=620">https://steamcommunity.com/profiles/76561198325470848/myworkshopfiles/?appid=620</a><br />
<br />
<span style="font-size: x-small;">(Most of them require the install of <a href="https://github.com/BEEmod/BEEMOD/releases" target="_blank">BEEMOD</a> - it adds more puzzle elements to the pallet such as the pellets</span>)<br />
<br />
If you play portal 2 on PC and could try them out, that'd be amazing! If you leave comments/feedback he'd be over the moon!<br />
<br />
If you don't have time to try all of them, my personal favourites are:<br />
<br />
<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=1220097620" target="_blank">yes it is possible</a> (if you're looking for a challenge),<br />
<br />
I think <a href="https://steamcommunity.com/sharedfiles/filedetails/?id=1259628918" target="_blank">laser levels</a> is an elegant level full of re-use and recycling of puzzle elements,<br />
<br />
and <a href="https://steamcommunity.com/sharedfiles/filedetails/?id=749064216" target="_blank">two headed test chamber</a> purely for the aesthetics / symmetry.<br />
<br />
Thanks for reading<br />
<br />
Tim (and Connor).Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-42359605961715943762014-05-03T17:46:00.002+01:002014-05-03T17:46:54.396+01:00Save a line - assign and test<div dir="ltr">
In C++ if you Get() a member pointer and then check if it's null before you use it (which is probably quite a common occurrence) and you're using two lines to do it in, you can save a line by testing the result of the assignment inline.<br />
</div>
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> Player player1 = PlayerManager.GetPlayer(1);
if (player1 != NULL)
{
player1.doStuff();
}
</code></pre>
<br />
becomes:<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> if (Player player1 = PlayerManager.GetPlayer(1))
{
player1.doStuff();
}
</code></pre>
<div dir="ltr">
<br /></div>
<div dir="ltr">
<br /></div>
Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-39506326954050378772011-09-17T21:32:00.003+01:002011-09-17T21:44:16.127+01:00More half baked ideasI posted one half baked <a href="http://programmingforpeople.blogspot.com/2008/12/ideas.html">idea</a> a while back (find people by interest).<br /><br />Here's another.<br /><br />A personal, multi-accessible, cross-platform, "cloud", simultaneous-accessible scheduler.<br /><br />I want to be able to access my schedule through my phone or my home computer or my work computer.<br /><br />I want the option of scheduling a reminder independently of the event - so I could say I want a reminder on this date at this time, and the title of the event is XYZ. Currently, with outlook, I have to specify 2 date / time periods - first when the event is, then when I want the reminder - I'd rather do it in one.<br /><br />I want the reminder to pop up on all my synced devices simultaneously, so whichever I happen to have with me / am looking at, I get the reminder - at the moment I can't schedule everything in outlook at work because sometimes I'm not in the office. I can't schedule everything on my phone because sometimes my phone is on silent (e.g. when I'm in the office). When I get my reminder, I want to be able to snooze the reminder on one device, and it will pop up again after the snooze duration on all my synced devices, and any of the devices could snooze it again.Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com1tag:blogger.com,1999:blog-5232592511268803325.post-38203624452534680902011-03-03T23:00:00.004+00:002011-03-12T22:30:18.600+00:00The taskbar is my mental stackIf I've got one objective that I'm trying to achieve, I might need to meet several sub-objectives along the way.<br /><br />So if I've got visual studio open and I'm working on my main feature, then I notice I need to get something out of a folder, I'll open an explorer window and navigate to that folder. While I'm there, I realise I need to do something later, so I'll make a note of it in notepad. A colleague then asks me to fix something in another program, so I'll open another instance of visual studio, and maybe firefox to look up the issue in the bug database, and another explorer window to find the data.<br /><br />Pre-windows 7, my taskbar would now have 6 items on it, in the order: visual studio 1, 1 explorer window, notepad, visual studio 2, firefox, and another explorer window.<br /><br />The items on the taskbar were arranged in a similar way to how they were ordered in my mind. As I complete sub tasks, I can close the programs one by one, from latest, to earliest, until I've finished my main task. That was good.<br /><br />Now, windows 7 groups similar items together. Which means the mental associations between the second visual studio and the explorer window (for example) are no longer matched by what's on screen, which means I have to spend mental effort connecting the various items whenever I try to work out what I was doing. And since lots of my work involves putting my mind through a mangler (figuratively), any extra mental effort that I have to put in that I didn't used to have to do, isn't appreciated :-(<br /><br />Luckily, there's (at least) one app which "fixes" this for me. <a href="http://rammichael.com/7-taskbar-tweaker">Windows 7 Taskbar Tweaker</a> lets me change the behaviour so that buttons are no longer grouped. Back to full productivity again! :-)Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com1tag:blogger.com,1999:blog-5232592511268803325.post-66239573244036547402010-06-06T14:57:00.003+01:002010-06-06T15:01:57.530+01:00One-liners: Prevent beep after pressing 'enter' in a controlIf you're a fan of your keyboard shortcuts, you might notice that windows sometimes emits a beep (or bell) after pressing enter to select something. Prevent the bell by setting the KeyDown eventargs SuppressKeyPress member to 'true' if the enter key was pressed.<br /><br /><pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>protected override void OnKeyDown(KeyEventArgs e)<br />{<br /> if (e.KeyCode == Keys.Enter)<br /> {<br /> e.SuppressKeyPress = true; // stop the bell!!!<br /> }<br /></code></pre>Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-26201725972766498772010-06-06T14:49:00.007+01:002010-06-06T14:56:12.169+01:00One-liners: Designer autogenerates Property = nullSick of the c# designer setting your control's property to null in the InitializeComponent() function? Then simply set the property's default value to null so InitializeComponent() doesn't have to!<br /><br /><pre style="font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; border: 1px dashed rgb(153, 153, 153); line-height: 14px; padding: 5px; overflow: auto; width: 100%;"><code>[DefaultValue(null)]<br />My Property...<br /></code></pre>Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-46338413547162068562009-12-05T16:00:00.005+00:002011-09-18T16:39:38.133+01:00Apps Hungarian vs Systems HungarianHungarian Notation is a convention where a prefix is given to a name to indicate its type. There are two flavours of Hungarian, and most of the criticisms are directed at Systems Hungarian, while people don't realise that Apps Hungarian even exists.<br /><br />Systems Hungarian prefixes variable names with their type. One big argument against doing this is that if the type changes, then you have to change every occurence of that name to match the new type.<br /><br />Apps Hungarian prefixes variable names with semantic information about the variable.<br /><br />Without the prefix, "Filename" might be a string, a text box, or something else. "Car" could be an instance of the car class, or a pointer to a car, or an index into a list of cars. "First" and "Second" could be almost meaningless, but in a spreadsheet application (for example) they could refer to rows, columns, cells, or something else.<br /><br />With a semantic prefix, things become clearer. In a forms application txtFilename is now likely to be the name of a textbox which contains a file name, while strFilename is more likely to be the string itself. Note that strFilename doesn't constrain me to any particular type of string - just that it is a string of some description.<br /><br />"iCar" is a sensible index into an array of cars, "pCar" is a pointer to a car, and "car" is most likely to be a concrete instance of the car class.<br /><br />My favourite example comparing Apps Hungarian to Systems Hungarian is based on spreadsheet software.<br /><br />Using Systems Hungarian (prefixing the type to the name), if "first" and "second" are integer indices, the assignment "iFirst = iSecond" looks alright at first glance. However, if the two variables were refering to rows and columns respectively, then the assignment was used to assign incompatible values.<br /><br />If we'd used Apps Hungarian instead, the assignment now becomes "rowFirst = colSecond" and without knowing anything about the type of the data, if we saw that assignment, alarm bells would be ringing.<br /><br />A colleague told me that a 'p' prefix before a pointer name was unneccessary - His arguments were:<br /><ol><li>we have strongly typed compilers which can tell us when we've tried using the variable incorrectly</li><li>intellisense can tell us a type just by hovering the mouse</li><li>if a name was followed by a dot '.' then it was a concrete instance</li><li>if it was followed by an arrow '->' then it was a pointer.</li></ol>My counter-arguments are:<br /><ol><li>Wherever possible, I want to type code correctly in the first place - not have to wait for the compiler to tell me it's incorrect.</li><li>Intellisense requires me to shift control-context to the mouse - which can be very disruptive during an intense coding-at-the-keyboard session</li><li>Intellisense doesn't always get it right</li><li>The code that has already been written isn't guaranteed to have used dots and arrows yet - explained below:</li></ol>If you had a variable m_CurrentVehicle - and a member function, EnoughFuel(); which is correct? m_CurrentVehicle.EnoughFuel() or m_CurrentVehicle->EnoughFuel() ?<br />If the variable was named m_pCurrentVehicle, then you would be able to see the answer instantly.<br /><br />I used to hate seeing things in Systems Hungarian like lpszMessage (long pointer to a string which is zero terminated), but I like Apps Hungarian.Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-12790049164937813352009-11-30T12:00:00.000+00:002009-11-30T12:59:58.058+00:0010 Reasons why I like Scrum for GamesThis is a response to Steve Tovey's <a href="http://www.kick-ups.net/ste/?p=107">10 Reasons why Scrum sucks for Games</a>. Steve and I used to work at the same company (but on different projects), and it sounds like he and Scrum didn't get along very well. I think Steve's a very clever chap, but I had a somewhat different experience of Scrum.<br /><br />Scrum is a project management framework. A project is broken down into a strictly prioritized set of components (the backlog) and every few weeks (called a "sprint") the highest priority items are taken off the backlog, divided among the Scrum teams, developed, and signed-off. Additional features include <a href="http://www.planningpoker.com/detail.html">Planning Poker</a>, Sprint Planning Meetings, Sprint Retrospectives, and a Scrum Master whose job it is to make sure things run smoothly.<br /><br />My team (the tools team) was one of the last teams in the company to adopt Scrum, and when the Powers That Be were trying to push Scrum to us, we resisted at first (why would I want to Scrum? sounds like a load of rubbish!) It was the early days of a new project, and we had all the time in the world, so there was no pressure on the tools team, no deadlines, and it felt like we could do whatever we wanted. The trouble is, without targets, there was no feeling of achievement - things just rolled along at a less than optimal pace. When we started Scrum, we suddenly had deadlines and targets, and over time we could see where our work fit into the bigger picture. Which leads me to my first reason:<br /><br /><span style="font-weight: bold;">1. Scrum improves visibility</span>. You can see exactly what is important and what isn't - what you should be spending time on, and what is acceptable to slip.<br /><br />During the sprint planning meetings, you divide tasks into manageable chunks. In Scrum, "Manageable" is no more than a day, and preferably less. If a task is estimated at taking a week, it needs breaking down some more and thinking about more. As Steve rightly points out, estimating is hard. The first few planning meetings are going to have estimates that may be quite a bit off the mark. But estimating is a skill that can be improved with practice. This is reason number 2:<br /><br /><span style="font-weight: bold;">2. Scrum improves developer's estimation skills.</span> And when management sees that the developers are able to give accurate estimates, they get more realistic expectations of what can be achieved by the end of the project.<br /><br />When development time is underestimated, tasks end up dropping off your current sprint and returning to the backlog, but the important thing here is that they are still at the same relative priority to all the other tasks. They will be dealt with next sprint. Eventually, when you run out of sprints, you will inevitably have to drop features because you ran out of time. But thanks to the strict ordering of the backlog, the features you ultimately ship without are of the lowest priority, meaning<br /><br /><span style="font-weight: bold;">3. Scrum makes sure you work on the most important things.</span><br /><br />That isn't to say there's no time for polish. Between sprints is a period of time for integration (combining all of the Scrum teams' work). While this is going on, and developers get a bit of a breather, they can use this time to add the bits of polish that didn't fit into the main product backlog. Also, if the product owner wants to put more time on polish, he can simply bump up the priority of polish - with the understanding that anything of a lower priority will move down the list, possibly causing another of the lowest priority tasks to be unachievable.<br /><br /><span style="font-weight: bold;">4. Each sprint generates "deliverables".</span><br /><br />In a project meant to run over a couple of years, you might expect to see somewhere in the region of 10 - 20 sprints. At the end of the early sprints, you might not have anything that could be boxed and sold, but towards the end of the project, it is possbile that you could finish the project early because you made sure that there was a deliverable at the end of each sprint. Alternatively, you could ship on the expected end date, and then run extra sprints for a patch or version 2.<br /><br />I will agree with Steve on his point 5 "Why do I get a say?" I was lucky in that my Scrum team consisted entirely of programmers. I can imagine it being very frustrating having an artist telling you how simple (or difficult) a programming task is, or generally just pulling numbers out of thin-air during planning, and similarly having a programmer tell an artist how much time it takes to be creative. So I'll give my reason 5 as<br /><br /><span style="font-weight: bold;">5.</span> (assuming your Scrum team is composed of developers from the same discipline) <span style="font-weight: bold;">Everyone relevant gets to have a say.</span><br /><br />Steve says taking an entire sprint to react to change isn't very <a href="http://en.wikipedia.org/wiki/Agile_software_development">Agile</a>. After a quick glance at both the Agile and Scrum entries on Wikipedia (thus making me an expert in the fields) I'd says that the Agile timeboxes (of one to four weeks) correspond rather neatly with sprints, and I'd say that adopting changes between the timeboxes fits in rather comfortably with the Agile ethos. If reacting to changes every 4 weeks isn't rapid enough (say I want to react in a day), then by all means make an emergency change to the sprint - it's not going to bring the whole system crashing down! So<br /><br /><span style="font-weight: bold;">6. Scrum is Agile</span>, in my expert (ha!) opinion.<br /><br />I partially agree with Steve on his point 7 "less done". You do get less coding done if you spend more time in meetings - it is a simple calculation. But to be fair, (anecdotal evidence alert) I don't feel that you loose that much, especially if you value what you gain - a better ability to estimate tasks, and a greater focus on what the customer (project manager) wants. So<br /><br /><span style="font-weight: bold;">7. While less overall code gets done, more important code gets done.</span> There's no risk of not having enough time to finish the critical features just because you decided that it would be nice to work on a small pet project / task / feature.<br /><br />In the daily Scrum meeting, the team move Task post-it notes from the "pending", to the "in-progress" to the "complete" sections of the Scrum board. I have a feeling Steve found this a waste of time! I think they served a useful purpose.<br /><br />I remember reading about computerization of air traffic control. Prior to computerization, aircraft were represented by plastic tags on a board, and when an aircraft changed position in their queue, the controller responsible for that aircraft had to move the tag. I don't remember details of what disasters happened after the computers took over, but I remember reading that the controllers felt less responsible for their charges. The reason I read was, that the tags that they moved around were things they could physically grab hold of or pass to other controllers and that physical movement or handover, psychologically, made the controllers feel more responsible for the planes they were in charge of. Without the physical tags, there was a psychological disconnect between the controller and the plane.<br /><br />I think the post-its, in their small way, make the team members feel more responsible for their tasks. Usually. I do remember on a number of occasions a team member who would say things like "I've done X and I'm just waiting for Y so I can finish it" or "I can't do Z this sprint" while moving his post-it note into the complete section. Occasionally I would (in a joking-but-not-joking kind of way) try to pick him up on this, but his post-its still managed to find their way in to the complete section anyway! I think this was partly due to a slightly competitive feel that some people might get when you can see how many tasks you've completed compared with your team mates; but I also think a bit of friendly competition is healthy for the team. I'm not saying you can't be competitive without Scrum, but I'd say that Scrum makes your progress that much more visible.<br /><br />Steve says "Too many coders spoil the broth". I'd use the saying when it came to Scrum team sizes in general - lots of coders in a daily meeting wastes a lot of peoples' time - but I'd say sharing higher level tasks among three or four people is a sensible idea, because I'm a fan of team ownership.<br /><br />I hear a lot of people voraciously cheering the <a href="http://martinfowler.com/bliki/CodeOwnership.html">Code Ownership</a> bandwagon, but they are supporting Strong Code Ownership - the idea that every piece of code is owned by exactly one individual. While it sounds like a good idea that one person knows everything thoroughly and is the highest authority on that code, if that coder leaves the team, or company, (or gets hit by a bus), the company is in trouble. The opposite extreme is that nobody is responsible for any code, anyone can change anything, and if anyone wants to know how something works, they pretty much have to work it out for themselves because so many people have had their fingers in the code pie.<br /><br />In the middle, you have team ownership. I don't remember reading a definition of it anywhere, so I may have invented it, but probably not. Anyway, with team ownership, while individuals work on components, the team should be more or less knowledgeable of the whole subsystem that they have been made responsible for. Which means if one member is ill, or on holiday, or leaves the company, any of the other team members can quickly and easily take up the slack.<br /><br />This fits in nicely with Scrum - during the sprint planning meeting (the process by which high-level post-it-notes get turned into lots of low level-post-it-notes) the low-level tasks can be shared among the team (as long as the tasks and boundaries are well defined). I like scrum because<br /><br /><span style="font-weight: bold;">8. Scrum facilitates shared code ownership.</span><br /><br />Each daily sprint meeting is attended by the Scrum master. Each day, the team has the opportunity to bring to light any impediments and the Scrum master can go off and prod the relevant people until the impediment is removed. The impediments can also be brought to the Scrum master at any time, not just during the daily meetings.<br /><br /><span style="font-weight: bold;">9. Having a consistent Scrum Master really helps remove impediments!</span><br /><br />After each sprint you have a sprint retrospective. The team brainstorms about the past sprint, trying to decide what went well, what went badly, how to improve things in the future. Also, each team member draws a graph of how they felt during the sprint - from very happy, to very sad. There are no numbers on the graph, the important part is sharing the reasons behind the peaks and troughs of the graph, hopefully helping to improve future sprints.<br /><br /><span style="font-weight: bold;">10. Scrum encourages frequent communication.</span><br /><br />No need to wait until the end of the project for a post-mortem!<br /><br />Just before I finish, I will say that you don't need Scrum in its entirety to get all of the benefits - individual elements are probably strong in their own right. But I do feel that there are a lot of good reasons to adopt Scrum as a whole.<br /><br />Sorry the post was so long! Feel free to blast apart any of the arguments I just made :)Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com1tag:blogger.com,1999:blog-5232592511268803325.post-63657748970523318172009-10-25T23:49:00.003+00:002009-10-26T00:09:20.642+00:00Style sheets for IDEsAs programmers, code layout is very important to us.<br /><br />If code is presented in a way we are familiar with, we can skim-read entire passages of code in very little time and find our way to the significant details very quickly. With well presented code, you can often see the general flow of the code without even having to read the fine details.<br /><br />Conversely, if the code we read is layed out poorly, it can be a real struggle to read through, and can take a very long time to get even a basic understanding of the code.<br /><br />Unfortunately, "well presented" is a very personal, subjective description of code.<br /><br />Indent with 3 spaces or 4? Tabs or spaces? Braces on the same line as other code? Alignment of variable names? Prefix? Hungarian?<br /><br />There are hundreds more examples. If you surveyed every programmer you knew, I'm sure you wouldn't find any two who agreed on every point of code layout.<br /><br />The trouble is, there is no right answer - there are valid reasons for all the choices.<br /><br />What we need, is a way of separating out the code from its layout - syle from substance.<br /><br />When we have IDEs which can present any piece of code in your style, we'll have made a great leap in the speed of code comprehension.Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-54754964163591924292009-07-22T12:06:00.005+01:002009-07-22T12:33:31.717+01:00What do I want from a mobile phone?<ul><li>I want good audio quality!</li><li>I want long battery life - specifically I want to be able to turn the screen on and off in order to save the battery - even during a phone call!</li><li>I want to be able to turn the phone off and the alarm clock to still work (I don't want to leave a "live" mobile phone on my bedside table at night every night).</li><li>I want the phone to charge via USB - then I don't have to carry my charger around with me everywhere.</li><li>I want the interface to be as customizable as possible - if I don't have a data plan, 100 internet shortcuts are useless to me!</li><li>I want the phone to vibrate for a phone call or text message - but not when navigating menus!</li><li>I want tactile feedback from the buttons on the phone - I often "touch-type" with my mobile, but if some buttons don't have the same "click" as other buttons it will throw me off.</li></ul>Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-16170829231340742712009-06-05T22:00:00.004+01:002009-06-06T09:10:49.426+01:00Open File Security Warning RemovalFed 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 <a href="http://www.google.co.uk/search?q=I+see+a+ton+of+ways+that+are+supposed+to+disable+this+but+none+seem+to+work.++Is+there+a+way+to+truly+disable+it&sourceid=navclient-ff&ie=UTF-8&rlz=1B3GGGL_enUS321US321">this page.</a><br /><br />Go to Run -> gpedit.msc<br />User Configuration -> Administrative Templates -> Windows Components -> Attachment Manager -> Inclusion List for moderate risk file types.<br />Enable it and in the box specify the extensions such .exe, .jpg, .comTimhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-39244478446632812112009-06-04T10:09:00.005+01:002009-06-04T10:15:37.047+01:00TreeViewScrollThe .net TreeView doesn't expose a scroll event. Make your own by overriding DefWndProc.<br /><br /><pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"><code> public class TreeViewScroll : TreeView<br /> {<br /> private const int WM_VSCROLL = 0x115;<br /> private IntPtr SB_ENDSCROLL = new IntPtr(8);<br /><br /> public event MethodInvoker Scroll;<br /><br /> protected void OnScroll()<br /> {<br /> if (Scroll != null)<br /> Scroll();<br /> }<br /><br /> protected override void DefWndProc(ref Message m)<br /> {<br /> if (m.Msg == WM_VSCROLL)<br /> {<br /> if (m.WParam != SB_ENDSCROLL)<br /> OnScroll();<br /> }<br /><br /> base.DefWndProc(ref m);<br /> }<br /> }<br /></code></pre><br /><br />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.<br /><br />This link should tell you what the message contains:<br /><a href="http://msdn.microsoft.com/en-us/library/bb787577(VS.85).aspx">http://msdn.microsoft.com/en-us/library/bb787577(VS.85).aspx</a><br /><br />This link can tell you the scrollbar values:<br /><a href="http://www.pinvoke.net/default.aspx/Enums/ScrollBarCommands.html">http://www.pinvoke.net/default.aspx/Enums/ScrollBarCommands.html</a>Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-3975559128774639382009-05-28T12:00:00.000+01:002009-05-28T12:00:00.720+01:00Stuck in a rutDon't get stuck in a rut! Don't miss the wood for the trees!<br /><br />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.<br /><br />Then someone reminded me that you can access elements of a vector by index. D'oh!Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com1tag:blogger.com,1999:blog-5232592511268803325.post-59451094515406836462009-05-27T22:40:00.002+01:002009-05-27T23:07:51.463+01:00If in doubt, wiggleA 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.<br /><br />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.<br /><br />But if you wanted, you could "remind" Word to carry on printing, by <span style="font-weight: bold;">wiggling the moue</span> 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.<br /><br />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.<br /><br />How odd.Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-10673739131196474452009-03-08T23:14:00.006+00:002009-03-09T10:43:41.883+00:00Zipping 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.<br /><br /><pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"><code>String zipper = @"c:\program files\7-zip\7z.exe";<br />String args = "a -tzip " + compressPath + " " + compressFolder;<br /><br />Process proc = Process.Start(zipper, args);<br />proc.WaitForExit(); <br /><br /></code></pre><br /><br />where compressPath is something like "C:\foo.zip" and compressFolder is something like "C:\foo".<br /><br /><span style="font-weight: bold;">Update: 9th March 2009</span><br />It's probably a good idea to make sure both compressPath and compressFolder are surrounded by quotes in case they contain spaces!Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-46675861454349898942008-12-21T12:30:00.000+00:002008-12-21T12:16:20.900+00:00Terminology: EnsureWhat'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.<br /><br />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!<br /><br />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".<br /><br />The second name is used when I want to get a reference to something that may not have been created yet.<br /><br />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.<br /><br />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.<br /><br />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.Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-38320640998181438902008-12-20T19:26:00.000+00:002008-12-20T19:26:00.227+00:00Delete the fontOriginally, I could read every website that was thrown at me.<br /><br />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.<br /><br />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.<br /><br />(I won't bother posting screenshots, because you won't be able to see them as they appear on my monitor.)<br /><br />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. :)Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-17562948706760594122008-12-18T12:00:00.000+00:002008-12-18T12:00:00.245+00:00IdeasI wonder if there's a website where you can post your ideas for coding projects. I had a (very) brief search, but didn't find anything so far.<br /><br />Various software ideas pop into my head from time to time.<br /><br />Here's one of them:<br /><br />Connecting people via a database correlating hobbies with people.<br /><br />By chance I found out that a colleague read some of the same books as me - we had a bit of a chat about the books and it made a nice change to talking about work. I wondered how many other colleagues read the same books as me. So originally the database idea was just for work. Then I thought it could easily be expanded to allow people in local neighourhoods to find people with similar interests. Then I thought it could easily be expanded to be a global database.<br /><br />The trouble would be getting people interested enough to fill in their details. Writing the database and the interface would be easy by comparison!Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-1125900012572563922008-12-17T12:00:00.003+00:002009-04-01T11:33:36.180+01:00More CustomizationsTwo more customizations - this time relating to the system notification area.<br /><br />When working on a new PC, sooner or later I end up installing <a href="http://www.4t-niagara.com/tray.html">4t Tray Minimizer</a>. I like to keep a clear taskbar, so if I have several programs open at once, and I'm not actively working on something, but don't want to close it, I can right-click the minimize button and it turns into an icon in the system notification area.<br /><br />Secondly, when I have too many icons in the notification area, I like to decide which icons don't need to be there at all. For the trial period, I had <a href="http://www.pssoftlab.com/">PS Tray Factory</a> installed, which mostly did what I expected of it, though it did seem to forget my settings from time to time (although that could have been one of the trial limitations).<br /><br />I'd quite like to have a go at writing my own program that manipulates the icons in the notification area. When I have time. One day. :)Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-66202264746504449682008-12-16T12:00:00.001+00:002008-12-16T15:40:12.662+00:00Conversation ContextWhy are mobile phones so distracting to the point where over 30 countries have made it illegal to drive while operating a mobile phone. If having a conversation with someone over the phone is so distracting, why isn't it illegal to chat to a passenger in your car?<br /><br />In England, at least, it's legal to use a mobile phone while driving, as long as you are operating the phone "hands-free". Personally, however, I wouldn't feel safe operating a mobile phone while driving, regardless of whether or not I could use the phone and keep both hands on the wheel.<br /><br />The reason is to do with context, and it doesn't just apply to using a mobile phone in a car - I have the same issue with landlines and three-way-conversations involving somebody in the room with me.<br /><br />The trouble is, in both examples, I'm the piggy-in-the-middle, but neither of the other "players" communicates with each other directly.<br /><br />In the landline example, the other players are obviously the person on the other end of the line and the person in the same room as me. In the mobile example, one player is the person on the mobile, while the other player is the environment in which I'm driving my car.<br /><br />If somebody was sat in the car with me, and the lights turned green, they could see that I was concentrating and hang fire with the conversation until they could see that there was less demand for my attention. But the person on the other end of the mobile can't see the road, and know when to pause, so will carry on talking and distracting me, without realising.<br /><br />I'm sure there's an analogy to programming here, but for the life of me I can't see it... :-STimhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-56156619660353409582008-12-15T10:07:00.002+00:002008-12-15T22:01:44.799+00:00ScaffoldEver find yourself commenting out lines of code, or adding dummy values, or setting up variables just to test something, then once the test has finished, going back through your code removing the comments, commenting out the dummy values and changing the variables back? And then repeating that sequence when you find that you hadn't actually finished testing?<br /><br />I do.<br /><br />Steve McConnell calls this code "scaffolding code".<br /><br />I also have a tendency to forget to remove this code once I've fixed my bug or finished my test. So I've gotten into the habit of marking the change with a comment similar to<br /><br /><pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>// Scaffold: added dummy value<br />int dummy = 3;<br /></code></pre><br /><br />Sometimes my scaffold comments get lost among a sea of other code, and I forget to remove it. So to group it together, I've started using a single scaffold file / class. That way there's only one place to look for the scaffold code.<br /><br />That's still susceptible to me forgetting about the scaffold before publishing my program, so I think the next step might be to create a user defined scaffold file that can be edited and stored locally, so even if I turn on all my scaffold constructs, nobody else sees them.Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-68366191947630085972008-10-29T01:00:00.005+00:002008-10-29T09:38:08.969+00:00CloudLauncher updateWell, after a brief hiatus, I'm back onto CloudLauncher.<br /><br />Just in case you don't know what it is, it's a launcher app. Drag your files / folders / executables / shortcuts onto CloudLauncher - it creates a shortcut to your file. Double-click the shortcut - your file opens. Simple.<br /><br />So how is it any different to windows explorer?<br /><br />Well, the main reason I wrote cloud launcher was because windows forgets my icon positions. In fact, this is probably the only reason to use CloudLauncher. For now.<br /><br />Version 0.1 is available <a href="http://www.programmingforpeople.com/programming/programs/src/CloudLauncher_2008_10_29_09_14_18.zip">here.</a><br /><br />TODO:<br /><br />Add option to delete shortcuts!<br />Add option to line up icons.<br />Add option to edit the target of the shortcut.<br />Add "F2" to rename shortcuts.<br />Add option to choose (or disable) the hotkey.<br /><br />Bug: Copy the name of the shortcut instead of the name of the target!<br />Bug: Don't crash if the global hotkey is in use!<br /><br /><span style="font-weight:bold;">Update: 29th October 2008</span><br />Added libraries to the zip file so that it compiles!Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-55230923336081784412008-10-28T21:43:00.001+00:002008-10-28T21:43:32.368+00:00Minimize to the Notification AreaCloud Launcher is minimizing to the notification area, then restoring when the notification icon is double clicked.<br /><br />Only, for hours it wasn't. Instead of restoring, it was appearing as a tiny "minimized" window / title bar.<br /><br />Turns out the "restore" / "show" order is important.<br /><br />This:<br /><br /><pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>WindowState = FormWindowState.Normal;<br />Show();<br /></code></pre><br /><br />doesn't work.<br /><br />This:<br /><pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code><br />Show();<br />WindowState = FormWindowState.Normal;<br /></code></pre><br /><br />works.Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-29909864959448231922008-10-08T23:00:00.001+01:002008-10-09T10:51:15.019+01:00TyposI once walked in on a friend who was chuckling to himself as he finished writing an email. Asking him what he found funny, he told me he'd just realised that it would be very easy, when signing an email with "regards" to miss the 'g' and hit 't' instead.<br /><br />For some reason, my fingers refuse to type certain combinations.<br /><br />"tion" always comes out "tino", as in "combinatino", "productino" and "sectino"<br />"updates" keeps coming out as "udpates"<br />"cheers" as "cjeers"<br />"installed" as "isntalled"<br />and even<br />"Tim" as "Time".<br /><br />Do you have any amusing typos?Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0tag:blogger.com,1999:blog-5232592511268803325.post-14074042378800008442008-10-06T22:19:00.002+01:002008-10-08T13:19:07.207+01:00AppendDateMy first code project article:<br /><br /><a href="http://www.codeproject.com/KB/cs/AppendDateTime.aspx">AppendDate</a> appends the current date/time to a file. I find it useful for achiving my work.<br /><br />How exciting :)Timhttp://www.blogger.com/profile/03240345507294112807noreply@blogger.com0