Solved

change control position

Posted on 2001-08-09
9
252 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
9 Comments
 
LVL 4

Expert Comment

by:IainHere
Comment Utility
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
Comment Utility
Did you try the SWP_SHOWWINDOW flag, just for grins???
0
 
LVL 42

Author Comment

by:sedgwick
Comment Utility
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 6

Expert Comment

by:MichaelS
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 42

Author Comment

by:sedgwick
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
why a "B"? Anything else you would have liked?
0
 
LVL 42

Author Comment

by:sedgwick
Comment Utility
>>the control may "jump back" to original size

the control did jumped back
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 125
only14 challenge 19 63
post4 challenge 28 81
scoreUp challenge 14 47
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now