Solved

Move window without resize

Posted on 2008-06-16
3
1,433 Views
Last Modified: 2008-10-03
Hi. I am trying to move a window to the upper left corner of my screen. I seem to have no problem moving the window to the corner , but it becomes very very small no matter what I set as nWidth & nHeight. The window i am moving is a "no resizeable" window, and i simply want it in the corner and nothing else.

    Declare Function MoveWindow Lib "user32.dll" Alias _
                    "MoveWindow" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long

0
Comment
Question by:soriega
3 Comments
 
LVL 27

Expert Comment

by:planocz
Comment Utility
try something like this...

Dim frm As New Form1
        frm.Location = New Point(Me.Left + 200, Me.Top + 100)
        frm.Show()
0
 

Author Comment

by:soriega
Comment Utility
Not really, i want to move another window, Not the Form of my application. Is there some way of using this method with the hwnd ?
I thought this was useful
Declare Function MoveWindow Lib "user32.dll" Alias _
                    "MoveWindow" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
This one seem to work, but it becomes very small, and it can after then only be closed
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 150 total points
Comment Utility
Use SetWindowPos() with the SWP_NOSIZE flag:
    Private Const SWP_NOSIZE As Integer = &H1
 

    Private Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As IntPtr, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer

    

    ...

        SetWindowPos(someWindowHandleHere, 0, 0, 0, 0, 0, SWP_NOSIZE)

Open in new window

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

771 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

10 Experts available now in Live!

Get 1:1 Help Now