Set size of an ActiveX control at runtime.

I'm using an ActiveX control. I've created it using the following function:

m_pNMEdit->Create(NULL, NULL, WS_VISIBLE, rect, this, 4545, NULL);

How can i change it's size? I haven't found any method in it. There must be a method like SetSize() or SetWidth ...
By the way, this control is created by subclassing the COleControl.
LVL 2
MindoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chensuCommented:
The wrapper class for the ActiveX control is derived from CWnd. So call CWnd::SetWindowPos to resize it.

m_pNMEdit->SetWindowPos(NULL, 0, 0, nWidth, nHeight, SWP_NOZORDER | SWP_NOMOVE);
0
MindoAuthor Commented:
My program crashes when it tries to execute your code. I did the following:

m_pNMEdit->SetWindowPos(this, 0, 0, 20, 20, SWP_NOZORDER | SWP_NOMOVE);

I'm trying to change the size of the inner control in the OnSize() event of the outer control. Unfortunately, it also crashes in the OnDraw() event.

The only place where it doesn't crash is the Init() method of the outer control:

void CNMComboBoxCtrl::Init()
{
      CreateEditBox();
m_pNMEdit->SetWindowPos(this, 0, 0, 20, 20, SWP_NOZORDER | SWP_NOMOVE);

}

m_pNMEdit is declared as:
CNMEdit* m_pNMEdit;

I create the control in the Init() method.

The error message i receive is:
The instruction referenced memory "...", the memory couldn't be "read".

What could be wrong with it? Thanks.
0
chensuCommented:
Call m_pNMEdit->SetWindowPos after m_pNMEdit->Create.
0
MindoAuthor Commented:
The program doesn't crash if i call it after the Create() invocation. There's no use of invoking the SetWindowPos() after Create(), because i can set the size of the control in the Create() function.

I want to change the size of the inner control at run-time, for example when the outer control's size changes.

Thanks.
0
chensuCommented:
You can call m_pNMEdit->SetWindowPos at any time after m_pNMEdit->Create provided m_pNMEdit is valid.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.