Solved

Stop form from moving

Posted on 2013-05-14
6
317 Views
Last Modified: 2013-06-25
Hi,

I am opening up an external process and 'capturing' it in my form with the code below. How would I stop the captured CMD window from being moved? Is this possible? I still need the CMD window caption to be visible so I can't remove it.

Thanks,

Dave.

proc = Process.Start("cmd.exe")
        System.Threading.Thread.Sleep(250)
        SetParent(proc.MainWindowHandle, Me.Handle)
0
Comment
Question by:wildarmsdave
6 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39167489
You can maximize the window which would mean it can not be moved.
0
 
LVL 16

Expert Comment

by:hjgode
ID: 39168118
You can alter the Window styles of the external process window. For example disable the window (if no input is needed) using WS_DISABLED.
0
 
LVL 22

Accepted Solution

by:
rspahitz earned 500 total points
ID: 39168761
>I still need the CMD window caption to be visible so I can't remove it.
Are you referring to the Title Bar?
How about disabling the form borders and add a simple label along the top (full width, maybe even with a dithered blue gradient like Windows) to make it look like the Title bar?
Or maybe put the full borders, capture an image of the heading, then revert to no-borders and place the image in a picturebox along the top?
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:wildarmsdave
ID: 39170540
Thanks all,

CodeCruiser - I have tried your suggestion. The window maximizes but is still moveable

SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, WS_MAXIMIZE, 0)

hjgode - I need the user to have input so this wouldn't work, but thanks.

rspahitz - I totally overlooked this simple option!!!! Yes it is the title bar I'm referring to.
0
 

Author Comment

by:wildarmsdave
ID: 39170619
Edit - apologies CodeCruiser, that should have read  SC_MAXIMIZE, 0 (which still leaves the form moveable)
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 39171824
Here's another thought...in .NET you can make a window "modal" and the window behind it can't be moved until you respond to that window.  If you could somehow get a modal "overlay" window on top of that window, it can't be moved.  The problem would be ensuring that the overlap window allowed all events to pass through to the window behind it so you could (1) temporarily close the overlay window (2) re-direct the events (3) reload the overlay window as needed.
Probably more trouble than it's worth, but maybe there's a variation of this that could work?
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 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