Solved

Stop form from moving

Posted on 2013-05-14
6
310 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
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.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

12 Experts available now in Live!

Get 1:1 Help Now