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

Group box disappears when MoveWindow or SetWindowPos is called

120 views
Skip to first unread message

Chip Calvert

unread,
Sep 24, 1998, 3:00:00 AM9/24/98
to
I am trying to resize a group box on a property sheet. When I call
MoveWindow or SetWindowPos (which returns TRUE), it disappears. Here
is the code:

//Attempt with MoveWindow. Note the call to ShowWindow afterwards

CWnd *cwndGroup = GetDlgItem(IDC_RECIPIENTS_FRAME);
// CHMWnd::GetWindowRect is a custom function which simply uses
// a safe handle to get the RECT info
CRect RecipGroupRect = CHMWnd::GetWindowRect(cwndGroup);
ScreenToClient(RecipGroupRect);
// ClientSize is a CSize that contains the height and width of
// the client area. GapControlsToBorder is an int with a value
// of 7
RecipGroupRect.right = ClientSize.cx - GapControlsToBorder;
cwndGroup->MoveWindow(RecipGroupRect.left, RecipGroupRect.right,
RecipGroupRect.Width(), RecipGroupRect.Height(), TRUE);
bResult = cwndGroup->ShowWindow(SW_SHOW);


// Attemp with SetWindowPos

CWnd *cwndGroup = GetDlgItem(IDC_RECIPIENTS_FRAME);
// CHMWnd::GetWindowRect is a custom function which simply uses
// a safe handle to get the RECT info
CRect RecipGroupRect = CHMWnd::GetWindowRect(cwndGroup);
ScreenToClient(RecipGroupRect);
// ClientSize is a CSize that contains the height and width of
// the client area. GapControlsToBorder is an int with a value
// of 7
RecipGroupRect.right = ClientSize.cx - GapControlsToBorder;
// This call attempts to push the group box to the top of the
// Z order in order to get it to show up
bResult = cwndGroup->SetWindowPos(&wndTop, RecipGroupRect.left,
RecipGroupRect.right, RecipGroupRect.Width(), RecipGroupRect.Height(),
SWP_DRAWFRAME | SWP_SHOWWINDOW);


Neither of these work. Please suggest anything!

Thanks,


Chip

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Make it idiot-proof and someone will make a better idiot."
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Remove NO and SPAM from my email address.

David Lowndes

unread,
Sep 25, 1998, 3:00:00 AM9/25/98
to
>I am trying to resize a group box on a property sheet. When I call
>MoveWindow or SetWindowPos (which returns TRUE), it disappears.

Chip,

As we don't have the details of your code or any numbers that indicate
where you've moved the window, I'd guess that you've moved it off the
screen. If you use the Spy++ utility you'll be able to locate the
control and find where it now is.

Have you run through your code with the debugger to check the values?

BTW, there's no need to cross-post so wildly.

Dave
----
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.

Chip Calvert

unread,
Sep 25, 1998, 3:00:00 AM9/25/98
to
Steve,

>I suggest changing RecipGroupRect.right to RecipGroupRect.top in the
>calls to SetWindowPos() and/or MoveWindow(). <g>

Did a really do that? <bang, bang, bang> That was the sound of my head
beating against the wall in my office.

THANK YOU!!!!!

Chip Calvert

unread,
Sep 25, 1998, 3:00:00 AM9/25/98
to
Dave,

>As we don't have the details of your code or any numbers that indicate
>where you've moved the window, I'd guess that you've moved it off the
>screen.

Actually, the error was glaring at me from the code I posted. A gent
named Steve spotted it and was kind enough to point out what had been
staring me in the face for a couple of days: I was passing "left" and
"right" instead of "left" and "top". Your supposition was correct; it
was being drawn off screen.

>BTW, there's no need to cross-post so wildly.

It wasn't "wild" but quite deliberate. I've noticed that while some
people seem to visit every relevant newsgroup, others limit their
activities to one or two. I needed this answer quickly. Had I
restricted my post to one or two newsgroups, Steve might not have seen
it and I might not have gotten the answer so quickly. However, I
don't generally post to more than one or two. Also, the term
"crosspost," in my experience, is used to refer to posts that are
off-topic. I was careful to post only to those groups where the topic
was relevant.

Thanks for your advice.

0 new messages