[Webinar] Streamline your web hosting managementRegister Today


Set size of an ActiveX control at runtime.

Posted on 2000-01-03
Medium Priority
Last Modified: 2013-11-20
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.
Question by:Mindo
  • 3
  • 2
LVL 23

Expert Comment

ID: 2320776
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);

Author Comment

ID: 2320905
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()
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.
LVL 23

Expert Comment

ID: 2320939
Call m_pNMEdit->SetWindowPos after m_pNMEdit->Create.

Author Comment

ID: 2320965
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.

LVL 23

Accepted Solution

chensu earned 40 total points
ID: 2321048
You can call m_pNMEdit->SetWindowPos at any time after m_pNMEdit->Create provided m_pNMEdit is valid.

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month9 days, 18 hours left to enroll

591 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