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
525 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
  • 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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 500 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
List out all word 7 223
move a line in eclipse 3 60
post4 challenge 28 82
noX challenge 17 76
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

18 Experts available now in Live!

Get 1:1 Help Now