Link to home
Start Free TrialLog in
Avatar of meravkn
meravkn

asked on

Form deletes painted picture, and getfocus problem

Hi,

I have an application with MDI form, and a few child forms. I have a form "frmPicturePreview", in which I can call another form: "frmAddText" to add text to the picture preview form. The picture is being painted into frmPicturePreview with the paintPicture method. The problem is that when I call the frmAddText, it behaves like an erasure, in a way that if it's over the frmPicturePreview it erases the picture. Weird, huh? Does anyone know about this problem (bug?) and how to fix it?

My other problem is the "GetFocus" method. It looks like just clicking the form title doesn't fire this method. Or even clicking on the form itself. How can I know if the form is the active one? I tried to use MDIForm1.ActiveForm, but it kept telling me that I have an error.

Thanks a lot!
Avatar of PaulHews
PaulHews
Flag of Canada image

Windows applications only repaint when it is necessary (when they are minimized and restored or when they are covered by another window.)  When you are drawing on a form using paintpicture, your application doesn't know it has to maintain that drawing if the form needs to be repainted.  There are two ways to fix this.

in form load:

frmPicturePreview.AutoRedraw = True

or in the Paint event for your form, put in a call to the code that does the paintpicture.

ASKER CERTIFIED SOLUTION
Avatar of Valliappan AN
Valliappan AN
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of meravkn
meravkn

ASKER

Thank you very much, I requested to split the points between two of you.
I have reduced the points in half.  Now you can accept one of the experts comment as an answer and post another question in this topic area for the other for the other 25 points.

Thank you
Computer101
Community Support Moderator