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

x
?
Solved

Center another applications window using it's handle VB.NET

Posted on 2013-12-19
2
Medium Priority
?
391 Views
Last Modified: 2013-12-27
Hi experts...
Is there a way that I can center another applications child window using that windows handle?

Here's what I have written so far but not sure where to go from here:

 
Private Sub CenterWindow(ByVal intHandle As Long)
        Dim iScreenHeight As Long
        Dim iScreenWidth As Long
        '##  PROVIDES SCREEN SIZE IN PIXELS
        iScreenWidth = Screen.PrimaryScreen.WorkingArea.Width
        iScreenHeight = Screen.PrimaryScreen.WorkingArea.Height


        Dim iFormHeight As Long
        Dim iFormWidth As Long

        Dim myRect As RECT
        If GetWindowRect(intHandle, myRect) > 0 Then
            If (myRect.Right - myRect.Left < My.Computer.Screen.WorkingArea.Width) Or (myRect.Bottom - myRect.Top < My.Computer.Screen.WorkingArea.Height) Then
                iFormHeight = myRect.Left
                iFormWidth = myRect.Top

            End If

        End If
        

        '## Next, we need to find the x/y location of the upper right hand corner

        Dim iTopLoc As Long
        Dim iLeftLoc As Long

        iLeftLoc = iFormWidth / 2
        iTopLoc = iFormHeight / 2


    End Sub

Open in new window

0
Comment
Question by:romiebehunin
[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
2 Comments
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 2000 total points
ID: 39731543
0
 

Author Closing Comment

by:romiebehunin
ID: 39742031
Works like a charm thanks guys
0

Featured Post

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.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

636 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