Solved

change control position

Posted on 2001-08-09
9
282 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 50 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.

730 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