?
Solved

change control position

Posted on 2001-08-09
9
Medium Priority
?
289 Views
Last Modified: 2013-11-20
i added some activeX control on my CFormView (part of SplitterWnd), i wanna to change its position and size according to the size of its parent (CFormView),
meaning strech it all over the form view
in OnInitialUpdate() i did:

     CRect rect;
     GetClientRect(&rect);
     ::SetWindowPos(m_dataQCtrl.m_hWnd, HWND_TOPMOST, rect.left, rect.right, rect.Width(), rect.Height());
but it didn't work, why?
0
Comment
Question by:sedgwick
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 4

Expert Comment

by:IainHere
ID: 6368231
You're calling the SetWindowPos API function directly, but you're not providing a uFlags parameter?  Did this compile?
0
 
LVL 4

Expert Comment

by:captainkirk
ID: 6368232
Did you try the SWP_SHOWWINDOW flag, just for grins???
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6368305
sorry, this is what i tryied:
     CRect rect;
     GetClientRect(&rect);
::SetWindowPos(m_dataQCtrl.m_hWnd, HWND_TOPMOST, rect.left, rect.right, rect.Width(), rect.Height(),
SWP_SWP_SHOWWINDOW);

complied but doesn't work
0
Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

 
LVL 6

Expert Comment

by:MichaelS
ID: 6368314
Use OnSize and call MoveWindow instead of SetWindowPos. MoveWindow is enouph for your needs. BTW, may be problem is in the ActiveX. Try to do it with some static control to be sure that moving part is working properly.
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6368412
sorry, this is what i tryied:
     CRect rect;
     GetClientRect(&rect);
::SetWindowPos(m_dataQCtrl.m_hWnd, HWND_TOPMOST, rect.left, rect.right, rect.Width(), rect.Height(),
SWP_SWP_SHOWWINDOW);

complied but doesn't work
0
 
LVL 4

Expert Comment

by:albay
ID: 6368721
hi.

you have to use SWP_NOZORDER flag to change the window pos.

SWP_SHOWWINDOW | SWP_NOZORDER.

best regards,
albay
0
 
LVL 7

Accepted Solution

by:
peterchen092700 earned 150 total points
ID: 6369321
albay: you don't *have* to, but it's a good idea in this case.

The problem is a bit deeper: repositioning an activeX control does not work using the HWND of the host alone, both the control and the container are involved.

You need to use the CWnd Member functions themselfes, that contain special code when the CWnd hosts an ActiveX control:


m_dataQCtrl.SetWindowPos(NULL, x,y,cx,cy, SWP_NOZORDER);

you should can add the SWP_NOSIZE (or SWP_NOMOVE) flag when you dont change the size (or the position) of the control. In this case cx,cy (or x,y) are ignored.  

Again, m_dataQCtrl.MoveWindow(...) would be enough for this.

The protocol for correctly repositioning an ActiveX is complicated, since it depends on what interfaces the control supports etc.

If you got it working, please check the following: the control may "jump back" to original size & positon when you change the activation state (i.e. activate or deactivate it). I had this behaviour one with an ATL ActiveX hosting IE in an MFC container.

Peter
0
 
LVL 7

Expert Comment

by:peterchen092700
ID: 6379643
why a "B"? Anything else you would have liked?
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6382938
>>the control may "jump back" to original size

the control did jumped back
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month12 days, 16 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question