Solved

Stop form from moving

Posted on 2013-05-14
6
318 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.Net - Not Sure if Multi-threading is What I Need 4 39
Why use this lambda? 12 60
ModalPopup  question 22 37
"lblTime is not declared" 3 28
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

685 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