473,789 Members | 2,679 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating custom container controls

I have created a container that will position 4 panels that has 15
different layouts to choose from.

I have based it similar to a System.Windows. Forms.SplitCont ainer but
that has 4 panels instead of 2.

It douse not have the ability on fixing the splitter like the
SplitContainer class has, each splitter is based on a parentage of the
container. For what I wanted it for it did not need that capability so
I wasn’t too bothered.

I have also created the Designer class for the control Container and
the Containers panel class making it user friendly at design time.

I am very please with what I have achieved so far but I have become a
little stuck when I came to moving the splitters at run time with the
mouse.

What I aim to acheave is something like this

<code>

protected override void OnMouseDown(Mou seEventArgs e)
{
base.OnMouseDow n(e);

if (e.X this.VerticalSp litter1Position -
(this.splitterT hicknes / 2) &&
e.X < this.VerticalSp litter1Position +
(this.splitterT hicknes / 2))
{
while (true)
{
// TO-DO
// Re-capture the state of the mouse.
e = new MouseEventArgs( ); // TO-DO - Dont no how to re
capture the state of the mouse.

// If the left button is no longer pressed exit loop.
if (e.Button != MouseButtons.Le ft)
{
break;
}

this.VerticalSp litter1Position = e.X;

Application.DoE vents();
}
}
}

</code>

When the mouse is pressed while over one of the splitters it call the
OnMouseDown event.

Then it needs to wait until the user releases the mouse button before
re locating the splitter to the new position.

The problem I have is that I don’t know how to obtain the mouse
coordinates when the mouse leaves the area of the splitter when the
mouse moves over one of the containers panels within the container the
mouse events are no longer called.

Am I thinking completely wrong by thinking about a loop within the
OnMouseDown event and if so could anybody point me in the write
direction.

This is a link to my container control source code including a simple
form displaying the views that the container offers.

http://www.jdnd.co.uk/temp/QuodContainer.rar

Thank you all for any help and I hope this cold be useful to someone.
Aug 4 '08 #1
2 2192
On Aug 4, 12:26*pm, Jay Dee <first...@gmail .comwrote:
I have created a container that will position 4 panels that has 15
different layouts to choose from.

I have based it similar to a System.Windows. Forms.SplitCont ainer but
that has 4 panels instead of 2.

It douse not have the ability on fixing the splitter like the
SplitContainer class has, each splitter is based on a parentage of the
container. For what I wanted it for it did not need that capability so
I wasn’t too bothered.

I have also created the Designer class for the control Container and
the Containers panel class making it user friendly at design time.

I am very please with what I have achieved so far but I have become a
little stuck when I came to moving the splitters at run time with the
mouse.

What I aim to acheave is something like this

<code>

protected override void OnMouseDown(Mou seEventArgs e)
{
* * base.OnMouseDow n(e);

* * if (e.X this.VerticalSp litter1Position -
(this.splitterT hicknes / 2) &&
* * * * e.X < this.VerticalSp litter1Position +
(this.splitterT hicknes / 2))
* * {
* * * * while (true)
* * * * {
* * * * * * // TO-DO
* * * * * * // Re-capture the state of the mouse.
* * * * * * e = new MouseEventArgs( ); // TO-DO - Dont no how to re
capture the state of the mouse.

* * * * * * // If the left button is no longer pressed exit loop.
* * * * * * if (e.Button != MouseButtons.Le ft)
* * * * * * {
* * * * * * * * break;
* * * * * * }

* * * * * * this.VerticalSp litter1Position = e.X;

* * * * * * Application.DoE vents();
* * * * }
* * }

}

</code>

When the mouse is pressed while over one of the splitters it call the
OnMouseDown event.

Then it needs to wait until the user releases the mouse button before
re locating the splitter to the new position.

The problem I have is that I don’t know how to obtain the mouse
coordinates when the mouse leaves the area of the splitter when the
mouse moves over one of the containers panels within the container the
mouse events are no longer called.

Am I thinking completely wrong by thinking about a loop within the
OnMouseDown event and if so could anybody point me in the write
direction.
Yes, you are. If you do that, you block the event loop from processing
new events. What you should do instead is set some bool flag in
MouseDown and return immediately, then provide appropriate handlers
for MouseMove (where you check for the flag and drag the splitter if
the flag is set), and MouseUp (where you reset the flag).

You do not need to do anything to receive MouseMove/MouseUp events
after you've handled MouseDown - WinForms automatically "captures" the
mouse in MouseDown. However, should you need to control this manually,
have a look at Control.Capture property.
Aug 4 '08 #2
Fantastic, after reading your response it took me about 2 mints to
make it work.

Thank you

<code>

private bool verticalSplitte r1Move;
private bool verticalSplitte r2Move;
private bool horizontalSplit ter1Move;
private bool horizontalSplit ter2Move;

protected override void OnMouseDown(Mou seEventArgs e)
{
base.OnMouseDow n(e);

if (e.Button == MouseButtons.Le ft)
{
// Move VerticalSplitte r1
if (e.X this.VerticalSp litter1Position -
(this.splitterT hicknes / 2) &&
e.X < this.VerticalSp litter1Position +
(this.splitterT hicknes / 2))
{
this.verticalSp litter1Move = true;
}
// Move VerticalSplitte r2
if (e.X this.VerticalSp litter2Position -
(this.splitterT hicknes / 2) &&
e.X < this.VerticalSp litter2Position +
(this.splitterT hicknes / 2))
{
this.verticalSp litter2Move = true;
}
// Move HorizontalSplit ter1
if (e.Y this.Horizontal Splitter1Positi on -
(this.splitterT hicknes / 2) &&
e.Y < this.Horizontal Splitter1Positi on +
(this.splitterT hicknes / 2))
{
this.horizontal Splitter1Move = true;
}
// Move HorizontalSplit ter2
if (e.Y this.Horizontal Splitter2Positi on -
(this.splitterT hicknes / 2) &&
e.Y < this.Horizontal Splitter2Positi on +
(this.splitterT hicknes / 2))
{
this.horizontal Splitter2Move = true;
}
}
}

protected override void OnMouseMove(Mou seEventArgs e)
{
base.OnMouseMov e(e);

if (this.verticalS plitter1Move) this.VerticalSp litter1Position =
e.X;
if (this.verticalS plitter2Move) this.VerticalSp litter2Position =
e.X;
if (this.horizonta lSplitter1Move) this.Horizontal Splitter1Positi on
= e.Y;
if (this.horizonta lSplitter2Move) this.Horizontal Splitter2Positi on
= e.Y;
}

protected override void OnMouseUp(Mouse EventArgs e)
{
base.OnMouseUp( e);

this.verticalSp litter1Move = false;
this.verticalSp litter2Move = false;
this.horizontal Splitter1Move = false;
this.horizontal Splitter2Move = false;
}

</code>
Aug 4 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1795
by: Jim | last post by:
I'm a little new to the C# way of doing thisgs... Although I've done this sort of thing before in VS 6 / MFC... creatnig controls, ActiveX controls, etc. Creating controls in MFC is pretty straightforward and dare I say intuitive? (well, as intuitive as you can get w/ MFC.) Anyhow, I am wanting to create some controls of my own w/ C#. I'm not quite sure where to start though. I created a Windows Control library project, and I get a...
7
3346
by: Girish | last post by:
OK.. phew. Playing with data grids for the past few days has been fun and a huge learning experience.. My problem. I have a requirement to display a gird with a gird. Within the embedded grid, theres a requirement to show a drop down menu list (this is a control I downloaded online) in one of the columns. For the purposes of this question, Ive implemented the drop down menu as a drop down list instead. Ive got all this working at this...
9
4693
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate> /asp:Repeater> The DataSource for this Repeater is a CollectionBase of objects and is
0
1248
by: slemen | last post by:
Hi, The DataGrid aps:EditCommandColumn when used with column templates created programmatically does not trigger the _Edit subroutine in code. The ASP:Datagrid definition is below (1), the _Edit subroutine signature (2) is below that and the column template class is (3). Thank you for your help, Scott
0
1560
by: LaptopHeaven | last post by:
I am having some trouble. How would one load a custom UserControl fro within a class which impements the ITemplate interface. Currently I have the following: public class SmallProductViewTemplate : ITemplate { public void InstantiateIn(Control container) { HyperLink productImage = new HyperLink();
0
1607
by: pabloazorin | last post by:
I developed a Date Picker web control using C# and .net framework 1.1 I added my control to Visual Studio 2003 IDE toolbar. When I drag and drop my control to design web page, the control renders correctly. If I change to HTML the generated html is <cc1:IT24DateTime id="IT24DateTime1" runat="server" Type="Date"></cc1:IT24DateTime> .... and that works correctly.
15
6523
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt accept other controls. The control i drag drop on it becomes the child of my custom control's parent form and not the child of my custom control. Then i added this line "" before my custom control class (i dont know what this line does). Now
1
2182
by: Abdo Haji-Ali | last post by:
Previously I used to create user controls if I wanted to use a specific set of controls in multiple pages, however I want to deploy my control in other applications so I thought of creating custom controls. Only problem is that I'm used to designing my controls in a WYSIWYG (tm) way (i.e. using the designer and writing HTML tags). The only way I found to create custom controls was to create controls dynamically, set their properties and...
5
4128
by: gerry | last post by:
I am trying to create a custom container control that will only ever contain a specific type of control. At design time, when a control of a different type is added to the container I would like to wrap the control in the proper control type - which is also a container. At design time I want to be able to turn this : <my:container> <asp:textbox />
16
4020
by: pupilstuff | last post by:
hi guys i just want to perform custom paging in which at the footer of the grid view ,there must be a pager 'pervious/next with numeric' this is what i did in aspx page <asp:GridView ID="TableGridView" OnPageIndexChanging="TableGridView_PageIndexChanging" runat="server" AutoGenerateColumns="False"
0
9666
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10199
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9983
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9020
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.