I actually considered that as a realistic possibility -- that memories of dreams form as you wake up -- but I think that is didproved by people talking and moving in their sleep in ways consistent with what they report about their dreams when they wake up. PET and NMR scanning might be able to resolve the issue, if it has not done so already.
Lucid dream research done in the 1970s had subjects signalling from within a dream using eye movement.