Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need to resize ActiveX control at start up.  OnSize of dialog is called before ActiveX Control is a window and cannot be used.

Posted on 2006-07-14
7
Medium Priority
?
540 Views
Last Modified: 2013-11-20
Hello and happy Friday everyone; I have yet another question.  

I have an activeX control on my dialog that I resize by using a method ResizeControl, in the OnSize message of my dialog.  
This works properly once the program is running.  If I resize the dialog my control positions and resizes perfectly.

My problem is that at startup the ResizeControl is not called and my control always starts in the top left corner.
For safety sake I need to make sure that the Dialog and the Control are both Windows before calling ResizeControl.
Is there any init method that I could use where the Window and the Control would both be windows so I could call ResizeControl?

Thanks,
0
Comment
Question by:alexatsearidge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17108782
>>For safety sake I need to make sure that the Dialog and the Control are both Windows before calling ResizeControl

you may use IsWindow() API  function at startup to determine if window is really created and exist..

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/iswindow.asp


-MAHESH
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17108974
e.g. At startup you may use IsWindow like :

if(IsWindow(m_MyDialog.m_hWnd)==TRUE) //m_MyDIalog is member variable for CDialog
{
//Resize Dialog
}

if(IsWindow(m_Ctrl.m_hWnd)==TRUE) //m_Ctrl is member variable of your control
{
//Resize Control
}


-MAHESH

0
 

Author Comment

by:alexatsearidge
ID: 17109316
Thanks Mahesh,

I am currently using IsWindow to double check.  The problem is that my code is in the OnSize of my main dialog and the first call to OnSize is before the dialog is a window.  This means that I cannot make a call to my ActiveX control yet because it is not a window.  

I need another method that I can use that will be called at start up but only after the window has been created.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 22

Expert Comment

by:mahesh1402
ID: 17109730
So you may perform resizing only if window is created otherwise return from function...so that your resize code will execute if and only if your dialog / control is fully created

CMyDialog::OnSize()
{

if(IsWindow(m_Control.m_hWnd)==TRUE) // OR if(IsWindow(m_Control.GetSafeHwnd ( )==TRUE)
  //Proceed with Resize
else
 return;

}

-MAHESH
0
 
LVL 22

Accepted Solution

by:
mahesh1402 earned 1000 total points
ID: 17110000
I am not sure IsWindowEnabled() and IsWindowVisible() functions will help you as they used to check if window is enabled for mouse n keyboar input and visible with WM_VISIBLE style respectively...but I dont think you need double checking if you goin to check it as suggested above with IsWindow() function.

-MAHESH
0
 

Author Comment

by:alexatsearidge
ID: 17111398
Mahesh I think perhaps I wasn't expressing myself properly.

I needed someway of redrawing my ActiveX control on a property page at start up.  The problem is that the control was being created after OnSize and OnInitDialog so that if I try to resize it there I could not because the window was not created yet.

I've solved the problem by calling the resize in the first tick of my timer.  
Thanks for your help though.
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17113359
alexatsearidge,
You could use FindWindow() API function for this purpose too..you may pass class name or window title name to detect window is present or not..

http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/findwindow.asp?frame=true

-MAHESH
0

Featured Post

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.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

610 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