See if this site helps you: ENGLISH PAGE - Past Continuous
The simple answer is "yes" but "while" may be more appropriate, depending on your need.
Student or Learner
Can we use the past continous with "when"?
Here is the sentence:
"The idea came to me WHEN I walked/was walking back from a neighbour's farm."
I would rather use "was walking" but the use of this tense with "when" , looks strange to me. Would it be better to say "when I walked back" but then the meaning isn't exactly the same.
Is it necessary to change When into while.
I would use "while" there. The two things happened at the same time. The idea did not interrupt you walk and cause you do something else instead.