[comp.windows.ms] WSMOOTH, *.* default available

mmshah@athena.mit.edu (Milan M Shah) (11/03/90)

As per the few requests for wsmooth which has *.* as the default filespec,
I have modified the source and created a new wsmooth.

More importantly, I have fixed a bug in wsmooth which is guaranteed to 
crash any system running the debug version of windows. I think the bug is
serious enough where it can also cause other running programs to crash in
any version of windows.

Before I start ranting, if anyone is interested in this 'fixed' version of
wsmooth that also has *.* as the default filespec, and will give me their
word that I will not get into trouble for distributing this thing, send
me email and I'll forward you a copy of the executable. Of course, if
someone will reassure me, I will also post the executable and source to any
anon ftp site.

For the curious, the bug has to do with the Settings dialog box - if you
select the Settings menu, which brings up the Settings dialog box, and if you
hit OK or CANCEL, any self respecting version of windows ought to die.

To see why, look at the code for the Settings Dialog function, in file.c.
Look at the code for handling WM_COMMAND message, under ID_OK and ID_CANCEL.
There is a bit of code shared between the two message handlers. The first
line of this shared code is DeleteObject (hDlgBrush). Well, this is going to
kill Windows, because at the time DeleteObject is called, hDlgBrush is
selected into the DC for the IDC_EB_COLOR control (of static class). You
cannot delete an object that is currently selected into a DC.

A more serious bug is in ResetBackground in Wsmooth.c. Here, they do
something like :

   hOldBrush = SelectObject (hDC, hOrgBrush);
   DeleteObject (hOldBrush);

Well, the first time around, hOldBrush gets assigned the handle of 
StockObject White_Brush, and then this stock object is deleted!! The same
bug is repeated in InitSettings in File.c. Lastly, in InitSettings, who
knows why they do a SetClassWord (... GCW_HBRBACKGROUND ...); there is no
reason to change the static class across all windows apps, especially when
they promptly delete the handle to the brush that they set as the background
brush! You'd think they'd run it under debug windows first!


Milan (My code *never* has any bugs ;-) Shah