Solved

Stop form from moving

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 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