JohnOne Posted November 19, 2011 Posted November 19, 2011 (edited) I'm having trouble keeping my form on top.The relevant code below, except it simply does not stay on top, and after a search all I can find as a solutionis importing user32.dll (not tried it) but I'd sooner not have to.Any pro tips?EDIT: solvedprivate void InitializeComponent() { this.SuspendLayout(); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.Window; this.ClientSize = new System.Drawing.Size(231, 164); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "Form1"; this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = ""; this.Load += new System.EventHandler(this.Form1_Load); this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown); this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove); this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseUp); this.ResumeLayout(false); this.TopMost = true; } Edited November 19, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Richard Robertson Posted November 19, 2011 Posted November 19, 2011 Setting Form.TopMost is enough. What you may be experiencing is other windows also marked as top most or you have other windows being displayed as children.
JohnOne Posted November 19, 2011 Author Posted November 19, 2011 I nothing I can think of running with topmost property/attribute. Just browser. Unless of course my form (the only one in the project) is a child of visual studio, but I've tried release as well as debug. Does an app in .net require admin rights to stay on top? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
JohnOne Posted November 19, 2011 Author Posted November 19, 2011 hmmm. seems TopMost means TopMost in more than one sense. If I move the statement to the top... this.TopMost = true; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); ...It's all gravy. Cheers. Solved. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
jvanegmond Posted November 20, 2011 Posted November 20, 2011 this.ResumeLayout(false); this.TopMost = true; This order is wrong. You set all properties first, then you do ResumeLayout call. You aren't editing the file that says "This code is auto generated and will be overwritten", right? github.com/jvanegmond
JohnOne Posted November 20, 2011 Author Posted November 20, 2011 I don't see that, I was editing the region... "#region Windows Form Designer generated code" For the record, I added the Topmost from withing the properties tab in VS first, but it never worked and that's why I began to fart around in there. And also to add "FormBorderStyle", as I could not find anywhere in properties to do that. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Richard Robertson Posted November 20, 2011 Posted November 20, 2011 You must be using an older version of Visual Studio. Newer versions actually hide that stuff in a second file to keep people from messing with it unless they know how to find it.
JohnOne Posted November 20, 2011 Author Posted November 20, 2011 VS2010 I'm using. But I could not find a way to get the border style right, all I found was padding which I set to 0. I'm not, as you can tell, all that clever with VS so if you have any tips to offer I'd be mighty grateful. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Richard Robertson Posted November 20, 2011 Posted November 20, 2011 Border style should just be in the form properties. Probably labled FormBorderStyle.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now