Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problems with SetWindowPos

289 views
Skip to first unread message

Steve Quintana

unread,
Feb 19, 1998, 3:00:00 AM2/19/98
to

My call to SetWindowPos() is crashing (brings up Dr. Watson under NT
4.0). Does anyone know what parameters could cause SetWindowPos() to
just crash the process it is called from???

This is the line that's causing the crash:

SetWindowPos(hDlg, HWND_TOP, 0, 0, (int) Rect.right, (int) Rect.bottom,
SWP_NOMOVE);


As an aside, shouldn't this function just fail and set an error code of
invalid parameter if that's the problem?


Thanks for any help...

Steve Quintana
Software Engineer
ICG Research Incorporated

Andreas Arff

unread,
Feb 20, 1998, 3:00:00 AM2/20/98
to

Steve Quintana wrote:
>
> My call to SetWindowPos() is crashing (brings up Dr. Watson under NT
> 4.0). Does anyone know what parameters could cause SetWindowPos() to
> just crash the process it is called from???
>
> This is the line that's causing the crash:
>
> SetWindowPos(hDlg, HWND_TOP, 0, 0, (int) Rect.right, (int)
> Rect.bottom,
> SWP_NOMOVE);
>
> As an aside, shouldn't this function just fail and set an error code
> of
> invalid parameter if that's the problem?

Yes you are right. But it doesn't happen in your case. Since
you use DrWatson you know that you get a call stack long as
a mile, which can be very helpful in situations like this. You
could try adding an SEH block around your call to SetWindowsPos,
or create your own SEH handler, to see if you can catch any exception
generated by the call, and then grab the last available error code.

Btw, the NT Internals guys made a program that called the API
functions in a random manner with random values just to see how
good the API handled faulty values. I have not tried their
program my self but I trust their word when they say that
it crashes after some time.

> Thanks for any help...

Good luck



> Steve Quintana
> Software Engineer
> ICG Research Incorporated

Andreas

Gary Burgess

unread,
Feb 23, 1998, 3:00:00 AM2/23/98
to

I have just struck some other challenges with SetWindowPos, but have
successfully used is with your parameters. (I am using Delphi, and it works
fine).

The only possibility I can think of is that your handle is not valid (hDlg).

Gary Burgess
Software Developer
Burgess Business Systems Pty Ltd

Steve Quintana wrote in message <34EC5A...@aracnet.net>...


>My call to SetWindowPos() is crashing (brings up Dr. Watson under NT
>4.0). Does anyone know what parameters could cause SetWindowPos() to
>just crash the process it is called from???
>
>This is the line that's causing the crash:
>
>SetWindowPos(hDlg, HWND_TOP, 0, 0, (int) Rect.right, (int) Rect.bottom,
>SWP_NOMOVE);
>
>
>As an aside, shouldn't this function just fail and set an error code of
>invalid parameter if that's the problem?
>
>

>Thanks for any help...

Dennis Swanson

unread,
Feb 23, 1998, 3:00:00 AM2/23/98
to

Who would have guessed that on Thu, 19 Feb 1998 at 11:12:55 -0500
Steve Quintana (SPAMNOT...@aracnet.net) would say:
[...]
~ As an aside, shouldn't this function just fail and set an error code of
~ invalid parameter if that's the problem?

I had heard that for 4.0 MS moved some API functions lower into the OS
(others could provide a more technical explanation), for speed purposes
(sacrificing robustness).

Den

--
Dennis M. Swanson <>< C/Win32 API programmer UNIX hobbyist

Charity is not defined as giving other people's money to the poor.

Steve Quintana

unread,
Feb 24, 1998, 3:00:00 AM2/24/98
to

Gary Burgess wrote:
>
> I have just struck some other challenges with SetWindowPos, but have
> successfully used is with your parameters. (I am using Delphi, and it works
> fine).
>
> The only possibility I can think of is that your handle is not valid (hDlg).
>
> Steve Quintana wrote in message <34EC5A...@aracnet.net>...
> >My call to SetWindowPos() is crashing (brings up Dr. Watson under NT
> >4.0). Does anyone know what parameters could cause SetWindowPos() to
> >just crash the process it is called from???
> >
> >This is the line that's causing the crash:
> >
> >SetWindowPos(hDlg, HWND_TOP, 0, 0, (int) Rect.right, (int) Rect.bottom,
> >SWP_NOMOVE);
> >

Thanks for the response, Gary. I just realized that hDlg refers to a
control in a dialog box, not the dialog box itself. I was incorrectly
using SetWindowPos where I should have been using a simple MoveWindow
call to reposition the control.
MoveWindow, by the way, works fine.

Steve Quintana

unread,
Feb 24, 1998, 3:00:00 AM2/24/98
to

Andreas Arff wrote:

> > This is the line that's causing the crash:
> >
> > SetWindowPos(hDlg, HWND_TOP, 0, 0, (int) Rect.right, (int)
> > Rect.bottom,
> > SWP_NOMOVE);
> >

> > As an aside, shouldn't this function just fail and set an error code
> > of

> > invalid parameter if that's the problem?
>

> Yes you are right. But it doesn't happen in your case. Since
> you use DrWatson you know that you get a call stack long as
> a mile, which can be very helpful in situations like this. You
> could try adding an SEH block around your call to SetWindowsPos,
> or create your own SEH handler, to see if you can catch any exception
> generated by the call, and then grab the last available error code.
>

Thanks for the response, Andreas. I just realized that hDlg refers to a


control in a dialog box, not the dialog box itself. I was incorrectly
using SetWindowPos where I should have been using a simple MoveWindow

call to reposition the control (likely, the HWND_TOP, parameter caused
the problem). MoveWindow, by the way, works fine. It's interesting to
note that something so simple could crash an application under an OS as
"robust" as NT is supposed to be.

0 new messages