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

Positioning a Dialog?

50 views
Skip to first unread message

carter

unread,
May 11, 2001, 12:25:59 AM5/11/01
to
Please excuse my ignorance. I am very new to this whole MFC thing.

I have a Dialog based MFC application that calls up another dialog. My main
dialog is CWinstsDlg which brings up dlgSTSCalc which is of CCalcSTSDlg.
Would I use dlgSTSCalc.SetWindowPos() prior to dlgSTSCalc.DoModal(); to
position the "sub-dialog"? If so, I do not understand the parameters:

BOOL SetWindowPos(
HWND hWnd, // handle to window
HWND hWndInsertAfter, // placement-order handle
int X, // horizontal position
int Y, // vertical position
int cx, // width
int cy, // height
UINT uFlags // window-positioning options
);

Now, the X and Y seem pretty self explanatory, but what is HWND hWnd? How
do I know what value to place here? What is HWND hWndInsertAfter and how do
I know what to place there as well? Exactly what is a window handle?

--
carter

Sam Hobbs

unread,
May 11, 2001, 12:43:48 AM5/11/01
to
You are looking at the non-MFC SetWindowPos, aka ::SetWindowPos. Notice I
used two semi-colons preceding the function name. The MFC version of
SetWindowPos could be referred to as CWnd::SetWindowPos. One big difference
is that the non-MFC SetWindowPos has a parameter for a "handle to window" as
you are asking about. If you are programming a MFC program you should use
the MFC SetWindowPos, especially if you do not know what a window handle is.

You cannot use either version of SetWindowPos before a modal dialog's
DoModal because the dialog does not exist. You will need to set the position
of the dialog from within the dialog. Probably it will work to use
MoveWindow instead of SetWindowPos, and that will be much easier. You will
need to do that in the dialog's OnInitDialog. It is probably best to put the
MoveWindow at the end of the OnInitDialog.

To learn about hings like window handles, you need to get a good bock about
Windows programming.


"carter" <car...@aodinc.com> wrote in message
news:#RlI7Hd2AHA.1228@tkmsftngp02...

carter

unread,
May 11, 2001, 1:15:37 AM5/11/01
to
Thanks for this information. Can you recommend any books on windows
programming? Also, the MoveWindow function worked but positioned the new
dialog relative to the screen. How do I move it relative to the base
dialog?

--
carter

"Sam Hobbs" <sam...@socal.rr.com> wrote in message
news:uNWI#Sd2AHA.2204@tkmsftngp02...

Sam Hobbs

unread,
May 11, 2001, 3:17:19 PM5/11/01
to
I do not know about books but someone else suggested:

http://www.accu.org/

To convert screen coordinates to client coordinates use ScreenToClient.


"carter" <car...@aodinc.com> wrote in message

news:#uucqjd2AHA.964@tkmsftngp03...

0 new messages