TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Adamo
NA
3
0
Problem with draggable panels containing labels
Sep 1 2009 12:31 PM
Hi, I'm working on my first C# project with Windows Forms, and so have used the internet to find solutions to a lot of my questions. One such problem was originally how to get a Panel to be movable within a given area.
One of the solutions which I found, was to detect Windows Messages (using the hex codes of WM_LBUTTONDOWN, WM_MOUSEHOVER, etc.) on a MovablePanel, which would be a child class of Panel, and to act on these messages accordingly. This would be handled in an overridden WndProc function...
protected override void WndProc(ref Message m)
While this was working fine, I also have a windows Label which I added to the MovablePanel, and it seems that if the mouse is hovering over or clicking directly on that Label, the MovablePanel does not detect the Windows Messages I check for, which I suppose makes sense. It was problematic when I first noticed it, but I figured I'd deal with it later.
But now I've been trying to make sure the label in the panel is always centered, and did so by:
m_label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
m_label.Dock = System.Windows.Forms.DockStyle.Fill;
m_label.AutoSize = false;
Of course, this means that the label now fills up the entirety of the MovablePanel, so none of the Windows Messages are being detected whatsoever, and I can no longer drag it.
I'm simply looking for some way to go around this that might hopefully be simple. I suppose I could make the label movable as opposed to the panel itself, but that just seems silly...all help is very greatly appreciated! Thanks so much :)
Reply
Answers (
1
)
Disable Ctrl+Alt+Del, Ctrl+Tab, Alt+F4 in Windows Vista
Textbox Validation