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
530 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 49
Importing Special Characters in Dynamics GP Through Integration Manager 3 82
tripleUp challenge 7 86
JQuery serialize and unserialize 8 137
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…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

831 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