Refresh screen

MERCOMMS
MERCOMMS used Ask the Experts™
on
I have an app that opens a command prompt window then moves that command prompt window.  Everything works fine but after the command prompt window is moved there is a "ghost" of the window where it originally was.  If you grab the command prompt window and move it around it will erase the ghost of itself if that makes sense.  

What I need is something that will refresh the screen to get rid of the "ghost" image of the command prompt window (vb6).
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Is it creating a ghost copy every time you move it or only once?

Author

Commented:
I only move it via code one time and it doesn't create the ghost then but instead leaves a ghost of where it was originally.  Then if I grab the window I can use it kind of like an eraser to erase the ghost.
Martin LissOlder than dirt
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Does the same thing happen if the code is run in the IDE? If NOT then try putting a DoEvents line after the code that moves the window.
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
Doevents after moving the window has no affect.
Top Expert 2012

Commented:
Try to set Form AutoRedraw property to True.
Martin LissOlder than dirt
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Does it only happen with the exe?
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009

Commented:
Is your app by chance waiting for the command prompt window to close?

How are you opening that command prompt?
Commented:
I assume that when you say you are 'Moving the Window' you are using the API

Declare Function MoveWindow Lib "user32.dll" (ByVal hwnd As _
Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As _
Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long 

Open in new window

The last option, bRepaint determines if the screen is repainted or not.

If you don't want the ghost image, set this value to TRUE  ( 1 )

retval = MoveWindow(Form1.hWnd, 200, 150, 175, 300, 1)

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial