Re: Can't Move Overlapped Window to Front

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Thanks for your insights. I know that my message pump is working -- when I
call Invalidate() and UpdateWindow(), my OnPaint() handler executes and I
can see the updates in the portion of my window not obscured by other
windows. Could my problem be somehow related to the fact that my app is a
Console app?

"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:9b1bc1d6goviaubpdc8psdd665fegjbfbo@xxxxxxxxxx
> It is potentially difficult to inhibit dragging. The most common cause is
that the window
> is off somewhere executing, or is blocked on I/O or a synchronization
primitive, and
> therefore its message pump is blocked, which would also explain why you
don't see any
> redraw: the app is in a loop somewhere, not handling messages, so
dragging, repainting,
> etc. are dead. But beyond that simple error, you actually have to WORK to
inhibit
> dragging.
>
> I'd suggest that you do a 'break' in the debugger and see where your
process is under
> these conditions. It sounds like you are off doing some computational
loop, or you've
> blocked on something.
>
> Note that OnActivate will only get called if the message pump is active.
If it isn't
> called, that's another indication your message pump is blocked.
> joe
>
> On Fri, 1 Jul 2005 08:19:42 -0400, "George B" <ghbennett@xxxxxxxxxxx>
wrote:
>
> >I think you're right that it is connected with window activation. The
> >window gets painted properly in the non-obscured portion. My window
> >doesn't let me drag it -- I don't know what I have to do to get that
> >capability or whether this is another default behavior I'm not getting.
By
> >installing an OnActivate handler, I found out that the window only gets
one
> >activation message at creation time. When I call SetActiveWindow, the
> >return tells me my window is already active. When I click on the title
bar,
> >the color changes to indicate activation, but nothing happens to the
display
> >(and OnActivate() doesn't even get called).
> >"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
> >news:c3p8c19skv1ehpaa4nqhtkfvpfl8ur6k23@xxxxxxxxxx
> >> THis suggests problems in window activation; it has nothing to do with
> >OnPaint. There are
> >> many ways this can happen, such as failing to call the superclass
> >OnActivate handler,
> >> improperly responding to a WM_MOUSEACTIVATE message, and so on.
> >>
> >> My first guess is that you are apparently seeing an error in window
> >activation. Does the
> >> non-client area paint properly? If ;you drag the window offscreen and
back
> >on, do you get
> >> proper refresh?
> >>
> >> If you see the nonclient area paint, but you don't get repainting of
your
> >client area, so
> >> the previous contents of what overlaid it are still present, then this
> >indicates a bug in
> >> your OnPaint handler, because it is quite possibly failint to paint at
> >all.
> >>
> >> One way to test this is to do an OnEraseBkgnd handler and paint the
> >background some weird
> >> color. If you see the background getting pained the weird color, then
you
> >have an error in
> >> your OnPaint logic. If you don't see it painting the background, then
it
> >is a
> >> bring-to-foreground problem.
> >> joe
> >>
> >> On Thu, 30 Jun 2005 16:49:08 -0400, "George B" <ghbennett@xxxxxxxxxxx>
> >wrote:
> >>
> >> >Thanks for your response. Apparently I'm not being clear. With
normal
> >> >apps, activating one window will bring it to the top and overlap all
> >other
> >> >windows. But when I attempt to activate my window, it stays below the
> >> >others. I tried the topmost option and this keeps the window on top,
but
> >> >doesn't let any other app (or even my own main console window) to
regain
> >the
> >> >top position.
> >> >
> >> >"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
> >> >news:9gi8c11pmpg2d8timgho7oduq9csiv95e0@xxxxxxxxxx
> >> >> And what exactly is the problem? OnPaint is SUPPOSED to refresh only
> >the
> >> >non-obscured
> >> >> portion of the window! That's what it is all about. This is
carefully
> >> >arranged by the
> >> >> WIndows operating system so this is how it will work.
> >> >>
> >> >> Why would you want "obscured" parts of your app to draw on top of
some
> >> >other window you
> >> >> don't own?
> >> >>
> >> >> And the correct window reference for making a window topmost is
> >> >&wndTopmost (or
> >> >> &wndTopMost), not &wndTop.
> >> >> joe
> >> >> On Thu, 30 Jun 2005 14:53:56 -0400, "George B"
<ghbennett@xxxxxxxxxxx>
> >> >wrote:
> >> >>
> >> >> >Using VC6 on W98SE, my app derives a window class from CWnd,
creates
> >the
> >> >> >window and successfully displays it with OnPaint(). However, when
the
> >> >> >window is obscured by another app, I can't find a way to refresh
the
> >> >> >display. OnPaint() gets called, but refreshes only the
non-obscured
> >> >portion
> >> >> >of the window. I tried calling SetWindowPos(&wndTop....), but that
> >> >doesn't
> >> >> >do anything, even if called from OnActivate().
> >> >> >
> >> >> >How should this work?
> >> >> >
> >> >> >George
> >> >> >
> >> >>
> >> >> Joseph M. Newcomer [MVP]
> >> >> email: newcomer@xxxxxxxxxxxx
> >> >> Web: http://www.flounder.com
> >> >> MVP Tips: http://www.flounder.com/mvp_tips.htm
> >> >
> >>
> >> Joseph M. Newcomer [MVP]
> >> email: newcomer@xxxxxxxxxxxx
> >> Web: http://www.flounder.com
> >> MVP Tips: http://www.flounder.com/mvp_tips.htm
> >
>
> Joseph M. Newcomer [MVP]
> email: newcomer@xxxxxxxxxxxx
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm


.



Relevant Pages

  • Re: Drawing disappears when window dragged
    ... Anything drawn at any other time will be erased as you describe. ... the only correct fix is to move all your drawing logic to your OnPaint handler. ... drawn disappeared when the window is moved. ...
    (microsoft.public.vc.mfc)
  • Re: Thread Deadlock
    ... How can an app update ... > does not get out of the event handler until the dialog is closed. ... Every window has a function that gets called when a message needs to be ... This function is called from a Message Pump. ...
    (microsoft.public.vc.mfc)
  • Re: Is this Application.Run() correct?
    ... > message pump won't terminate automatically when the form closes. ... Notify context menu handler. ... right window as there is NO window (no HWND, no GDI DC no GDI Region) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Fullscreen PPC
    ... timer handler and nothing in the WM_ACTIVATE handler, ... You select the window that you want to know about from the Windows List ... Paul T. ... // Resize the window over the taskbar area. ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Child Window Creation
    ... your handler! ... painted until all posted messages have been pumped. ... but it was getting handled before the window painted. ...
    (microsoft.public.vc.mfc)