When I create taskbox on the form the line beside the box wont show up.
it show up untill I have MouseEnter event occur.
Also when I have 2 taskbox on the form it does draw the line around the label
however the line wont draw when i have 1 taskbox move away from another taskbox. The line is gone at last sec when taskbox move away.
could someone please tell me where does I made mistake and how to fix it
thank you
Below is the code. -
using System;
-
using System.Collections.Generic;
-
using System.Text;
-
using System.Windows.Forms;
-
using System.Drawing;
-
-
namespace Task
-
{
-
public class TaskBox: Label
-
{
-
private bool m_IsPressed;
-
private int curDifX,curDifY;
-
private const int STEPBOX_WIDTH = 105;
-
private const int STEPBOX_HEIGHT = 25;
-
-
public event MouseRightKeyPressHandler MouseRightKeyPress;
-
public delegate void MouseRightKeyPressHandler(object sender, MouseEventArgs e);
-
-
public event DeleteTaskHandler DeleteTask;
-
public delegate void DeleteTaskHandler(object sender);
-
-
-
public TaskBox(string name) {
-
-
this.Text = name;
-
this.TextAlign = ContentAlignment.MiddleCenter;
-
this.BorderStyle = BorderStyle.None;
-
this.Size = new Size(STEPBOX_WIDTH, STEPBOX_HEIGHT);
-
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this_MouseDown);
-
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this_MouseMove);
-
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this_KeyUp);
-
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this_MouseUp);
-
this.MouseLeave += new EventHandler(this_MouseLeave);
-
this.MouseEnter += new EventHandler(this_MouseEnter);
-
this.BackColor = Color.FromKnownColor(KnownColor.Control);
-
this.LostFocus+=new EventHandler(this_LostFocus);
-
this.Paint+=new PaintEventHandler(TaskBox_Paint);
-
-
}
-
-
private void this_MouseDown(object sender, MouseEventArgs e)
-
{
-
m_IsPressed = true;
-
(sender as TaskBox).Select();
-
curDifX = Cursor.Position.X - (sender as Label).Left;
-
curDifY = Cursor.Position.Y - (sender as Label).Top;
-
(sender as TaskBox).BackColor = Color.Teal;
-
if (e.Button == MouseButtons.Right)
-
{
-
if (MouseRightKeyPress != null)
-
{
-
-
MouseRightKeyPress(this, e);
-
}
-
}
-
-
}
-
-
private void this_MouseMove(object sender, MouseEventArgs e)
-
{
-
if (m_IsPressed == true)
-
{
-
if (Cursor.Position.X - curDifX < 0)
-
{
-
(sender as TaskBox).Left = 0;
-
}
-
else
-
{
-
(sender as TaskBox).Left = Cursor.Position.X - curDifX;
-
}
-
-
if (Cursor.Position.Y - curDifY < 0)
-
{
-
(sender as TaskBox).Top = 0;
-
-
}
-
else
-
{
-
(sender as TaskBox).Top = Cursor.Position.Y - curDifY;
-
}
-
-
(sender as TaskBox).BringToFront();
-
-
}
-
}
-
-
private void this_MouseUp(object sender, MouseEventArgs e)
-
{
-
(sender as TaskBox).BackColor = Color.Teal;
-
m_IsPressed = false;
-
-
}
-
-
private void this_MouseEnter(object sender, EventArgs e)
-
{
-
Graphics g = (sender as TaskBox).CreateGraphics();
-
g.DrawRectangle(Pens.Red, 0, 0, STEPBOX_WIDTH-1, STEPBOX_HEIGHT-1);
-
}
-
private void this_MouseLeave(object sender, EventArgs e)
-
{
-
Graphics g = (sender as TaskBox).CreateGraphics();
-
g.DrawRectangle(Pens.Black, 0, 0, STEPBOX_WIDTH-1, STEPBOX_HEIGHT-1);
-
}
-
-
private void this_KeyUp(object sender, KeyEventArgs e)
-
{
-
if (e.KeyData == Keys.Delete)
-
{
-
DeleteTask(this);
-
}
-
}
-
-
-
public void TaskBox_Paint(Object sender,PaintEventArgs e)
-
{
-
Graphics g = (sender as TaskBox).CreateGraphics();
-
-
-
if (m_IsPressed)
-
{
-
g.DrawRectangle(Pens.Red, 0, 0, STEPBOX_WIDTH - 1, STEPBOX_HEIGHT - 1);
-
}
-
else
-
{
-
g.DrawRectangle(Pens.Black, 0, 0, STEPBOX_WIDTH - 1, STEPBOX_HEIGHT - 1);
-
}
-
-
}
-
-
private void this_LostFocus(object sender, EventArgs e)
-
{
-
-
(sender as TaskBox).BackColor = Color.FromKnownColor(KnownColor.Control);
-
}
-
-
}
-
}
0 1342 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Steven Stern |
last post by:
I have a script that will be run as a cron task every night but occasionally
will run when request by the browser. When run by the browser, I want it to
output results to the screen.
What's an...
|
by: Catherine |
last post by:
I am having a problem viewing asp pages on iis version
5.1 xp pro.
HTML pages are viewable on http://localhost but .asp
pages are not. I have created a test program called
timetest.asp with the...
|
by: Bob Ranck |
last post by:
More on earlier thread "Base Form that wont go away"
Response to Chris Dunaway dunawayc@lunchmeatsbcglobal.net
Here is the code snippet that calls the working form in
the MDI.
I actually...
|
by: Ali |
last post by:
I have the following web page with a script in it.
<html>
<head>
<title>Make Your Own Objects test</title>
<script>
|
by: eewwttww |
last post by:
how to show the "txt code" that the WebBrowser wont to save when he wont to
save html+pictures with the "dialogbox" - before saving.
this is the code to open the save "dialogbox"
...
|
by: Diz |
last post by:
Hi,
Can anybody tell me why my php script wont run properly unless i put it in a page all on its own? Is it antisocial? Does it want to be alone? I have put it in a page with background and links to...
|
by: Arthur Dent |
last post by:
Hello All,..
I have some settings stored in the project settings which show up under
My.Settings. ...
All works fine.
Now, I wanted to change the value of one of these settings, so I went...
|
by: watashi |
last post by:
Hello,
This is on socket. i m using tcpclient and tcplistener
task is when the "Active " button is pressed according to user choice tool should work as server or client.
when "Inactive"...
|
by: Sean425 |
last post by:
import java.util.*;
class variables {
public static void main(String args) {
Scanner input = new Scanner(System.in);
String op;
int numberOne, numberTwo, result = 0;
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |