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
529 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Generic progress indicator 6 115
sumDigits challenge 9 146
lucky13 challenge 11 140
MaxSpan challenge 9 94
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…
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.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

813 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

11 Experts available now in Live!

Get 1:1 Help Now