Selective showing of taskbar buttons for forms

I've been using the following to put a separate button on the taskbar
for each form in my application:

  SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle,
GWL_EXSTYLE) or
                WS_EX_APPWINDOW);

The problem with this method is that every modal dialog that pops up
in the app also puts a button on the taskbar, which I don't want to
happen. How can I prevent the button on these forms?