Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Stop form from moving

Posted on 2013-05-14
6
Medium Priority
?
328 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

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…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

670 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