Distinguishing form being built for rendering versus submission Is there a way to distinguish, inside a form function, that the form is being built to be rendered on the page, as opposed to being re-built as a result of submission?

I would like to use drupal_set_message() inside the form function, but only while it's being built for rendering.
Take a look at the $form_state elements. You'll want to look at 'submitted', 'rebuild', 'cache', 'programmed', etc... depending on your use-case.  You can get a good idea of those elements and what they mean in drupal_build_form.  I typically use $form_state['submitted'].