gomasch Development Notes

Dienstag, Oktober 18, 2005

Need Icons? Steal resources with PEResourceExplorer

This post is very basic. I just want to keep a bookmark to PEResourceExplorer somewhere and will now construct some sentences to hide this fact:

What for: I was in the need for some nice icons for Run, Cancel and Open File for a simple program (nothing to be released). And I wanted to use/steel orignal Windows XP icons for this (I think they actually are somewhat copyright protected, are they?).

How: I could have taken screenshots. This works well. I like Paint .Net as a fast/simple/free image processing program to save them after pressing Alt-Print.

How #2: Once I found Build\ImageList16.png and Build\ImageList24.png in the free sources of Lutz Roeders CommandBar I always look there first for standard icons - and found a nice open file button.

How #3: Another way to get icons is to look at the (program) binaries, which can contain them too as resources. Windows\System32\Shell32.dll for example contains many of the typical Windows icons. One only needs a program to rip them off. I searched and quickly found this one: PEResourceExplorer. Looks ok, is free, works. Linking there is the solely purpose of this post ;).

Update 2005-12-08: nice basic icons for free can be found here: http://www.glyfx.com/free.html (found via Larkware) Update 2005-12-19: another free icons set (700 icons in 16x16) is here: http://www.famfamfam.com/lab/icons/silk/ (again found via Larkware) Update 2006-05-12: more free icon resources listed on http://www.drweb.de/weblog/weblog/?p=541 Update 2006-06-29: Visual Studio 2005 ships with a nice pack of standard icons, look in Common7/VS2005ImageLibrary. This is my main source for icons and button images at the moment. (via Brad Adams) Update 2006-09-07: Via WinSnap I found http://www.iconaholic.com/downloads.html, looks interesting too (but only free for private nonpublic use) Update 2006-12-16: steal, not steel

Martin 18:42 | 0 comments |

Freitag, Oktober 14, 2005

CodeSmith, CSS, VbScript Reference

Ah, finally released it and threw it over the wall. Three completely unrelated notes before jumping into weekend:

To try: Code generation with CodeSmith
I've read soooooo often in so many posts, that CodeSmith is a great tool. It started out free but has gone commercial. But when I looked at the website last time it seemed the free version was gone. Boy I must have been blind: there is still free version of CodeSmith: 2.6. I'll try it out as soon as I see an opportunity.

To try: Really using CSS in Html
Mentally I'm still stuck with the tables paradigm. But I just read a very nice presentation why to drop tables and go CSS. Well, somewhen in the remote future I'll follow and really use <div> myself.

To find or write: Nice VbScript Reference
VbScript is quite nice actually for writing scripts running locally like batch files. WSH is built into Windows and can do almost everything. The syntax is ugly - but well, perl's syntax is ugly too and i liked perl. SciTe  supports VbScript syntax highlighting so I have an editor (always looking for an improvement though).

But what I'm massively missing is a nice VbScript [pocket] [quick] reference like the great Rex Swains's HTMLified Perl 5 Reference Guide. Everyone is pointing to the msdn, which isn't that great for learning the language and solving problems, really. Everything is written somewhere but you'll hardly ever find it until you know the solution yourself. There are some books and even reference html pages to buy. But I haven't found an equivalent to Swain's Reference yet. Especially annoying is how the information is spread over several places since you are not using VbScript itself e.g. to copy files but Scripting.FileSystemObject.

Seems like I'll have to compile stuff myself. Just started ripping off html code from these places and putting them into a single HTML page:

Martin 19:39 | 0 comments |

Donnerstag, Oktober 13, 2005

Visual Build Tools

I just want a simple tool to build several Visual Studio .Net 2003 projects, maybe run something to create an installer and run some batch files to collect things for distribution. It's enough if tool just captures console output. It should stop on error. Nice GUI is a must.

Nant is ugly and just text based and does not well integrate with Visual Studio .Net 2003.

MSBuild is the future but only fun with Visual Studio .Net 2005.

FinalBuilder seems to be a very slick product, but it's not free and currently not in our tool list. Maybe later? Well, Joel Spolsky is recommending it, that's a huge pro anyway:).

Visual Build Professional looks not as slick but has a nice feature list. Not in our tool list too.

Yesterday I found this one and I am quite happy with it in the first run: MegaBuild. .Net, cheap, looks nice and simple:

A donation is not improbable if proves itself over time.

Martin 20:35 | 0 comments |

Hosting Windows.Forms User Controls in Mfc 7.1

Here's the setup: 
A GUI is written in .Net and has to be integrated into third party product (say like Outlook) as an ActiveX control. Unfortunately the only supported host for Windows.Forms user controls in .Net Framework 1.1 is currently .Net itself, the Internet Explorer 7 and ... MFC 7.1 (see MSDN mag 2003/03). This happened to be true for our case as well. The hack of putting the user control directly into the 3rd party app did not work. (The hack: register the assembly and add some registry keys, see ".NET and COM - The Complete Interoperability Guide" by Adam Nathan page 471. It worked in the ActiceX Control Test Container but not the our 3rd party app).

The MSDN article has example source code to host a Windows.Forms.Control in MFC 7.1. It works pretty well, but only in Debug mode(I'm building an ActiveX OCX). Compiled as Release I always got strange a NullReferenceException in the copied MSDN code. I tracked it down to this line (in ::OnCreate):

 spunkControl.Attach((IUnknown*)System::Runtime::InteropServices::Marshal::GetIUnknownForObject(ctrlWinForms).ToPointer());

This line works perfectly well when compiled in Debug . In the Release build it's not working for me (and causing MSDN code later to throw a NullReferenceException), maybe due to optimization?

Doing each step one by one is working in Release too:

System::Windows::Forms::Control* ctrlWinForms;
CComPtr<IUnknown> spunkControl;

// load assembly and stuff ...

System::IntPtr iUnknown = System::Runtime::InteropServices::Marshal::GetIUnknownForObject(ctrlWinForms);
if (System::IntPtr::Zero == iUnknown)
{    
// failed to get IUnknown
    
::MessageBox(NULL, "Failed to get an IUnknown for ctrlWinForms ", "Init failed", MB_OK);
    
return VARIANT_FALSE;
}

spunkControl.Attach((IUnknown*)iUnknown.ToPointer());
if (!spunkControl)
{    
// failed to attach
    
::MessageBox(NULL, "Failed to attach the IUnknown for ctrlWinForms ", "Init failed", MB_OK);
    
return VARIANT_FALSE;
}

Final note: the docs for GetIUnknownForObject are explicitly stating, that one has to call a Marshal.Release later. CComPtr<>::Attach is not doing an AddRef though and being a smartpointer calls Release automaticly on exit.

Martin 19:19 | 0 comments |

Blog started

I'm starting this blog to take some technical notes during my work as a programmer.

My personal blog gomasch is in german and I wanted to seperate programming stuff from that.

Martin 18:02 | 0 comments |