• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

change control position

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
Meir Rivkin
Asked:
Meir Rivkin
1 Solution
 
IainHereCommented:
You're calling the SetWindowPos API function directly, but you're not providing a uFlags parameter?  Did this compile?
0
 
captainkirkCommented:
Did you try the SWP_SHOWWINDOW flag, just for grins???
0
 
Meir RivkinFull stack Software EngineerAuthor Commented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
MichaelSCommented:
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
 
Meir RivkinFull stack Software EngineerAuthor Commented:
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
 
albayCommented:
hi.

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

SWP_SHOWWINDOW | SWP_NOZORDER.

best regards,
albay
0
 
peterchen092700Commented:
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
 
peterchen092700Commented:
why a "B"? Anything else you would have liked?
0
 
Meir RivkinFull stack Software EngineerAuthor Commented:
>>the control may "jump back" to original size

the control did jumped back
0

Featured Post

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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now