Solved

change control position

Posted on 2001-08-09
9
263 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Doc'in system (example?) BA 7 89
wordcount challenge 11 108
firstChar challenge 13 110
Way to decrease size of apk file 9 45
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

920 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

16 Experts available now in Live!

Get 1:1 Help Now