473,748 Members | 5,242 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create a helper control to modify existing forms controls.

I am designing an enhanced GUI suite, and i need to know how to:
* Make a user control a "helper" control, ie, one that sits at the
bottom (like timer or process)
* Make this control modify the behavior of the painted controls
already on the form. (ie, make my control handle the painting of the
controls on the page)
* Make the TextBox contol have it's background painted by me. This
seems to be a hassle.

Any help would be deeply appreciated as at the moment i am coding solo
for an open source program.

Thank You!

Jul 5 '06 #1
4 2500
CodeLeon wrote:
I am designing an enhanced GUI suite, and i need to know how to:
* Make a user control a "helper" control, ie, one that sits at the
bottom (like timer or process)
* Make this control modify the behavior of the painted controls
already on the form. (ie, make my control handle the painting of the
controls on the page)
* Make the TextBox contol have it's background painted by me. This
seems to be a hassle.

Any help would be deeply appreciated as at the moment i am coding solo
for an open source program.

Thank You!
Hi CodeLeon,

WRT your first point, you need to create a component, not a user-control, if
you want the type of behaviour you see with Timers and etc.

--
Hope this helps,
Tom Spink
Jul 5 '06 #2
Thank you, but i already did that. What i need to do is get the parent
form of my componenet. Any ideas?

Tom Spink wrote:
CodeLeon wrote:
I am designing an enhanced GUI suite, and i need to know how to:
* Make a user control a "helper" control, ie, one that sits at the
bottom (like timer or process)
* Make this control modify the behavior of the painted controls
already on the form. (ie, make my control handle the painting of the
controls on the page)
* Make the TextBox contol have it's background painted by me. This
seems to be a hassle.

Any help would be deeply appreciated as at the moment i am coding solo
for an open source program.

Thank You!

Hi CodeLeon,

WRT your first point, you need to create a component, not a user-control, if
you want the type of behaviour you see with Timers and etc.

--
Hope this helps,
Tom Spink
Jul 5 '06 #3
CodeLeon wrote:
Thank you, but i already did that. What i need to do is get the parent
form of my componenet. Any ideas?

Tom Spink wrote:
>CodeLeon wrote:
I am designing an enhanced GUI suite, and i need to know how to:
* Make a user control a "helper" control, ie, one that sits at the
bottom (like timer or process)
* Make this control modify the behavior of the painted controls
already on the form. (ie, make my control handle the painting of the
controls on the page)
* Make the TextBox contol have it's background painted by me. This
seems to be a hassle.

Any help would be deeply appreciated as at the moment i am coding solo
for an open source program.

Thank You!

Hi CodeLeon,

WRT your first point, you need to create a component, not a user-control,
if you want the type of behaviour you see with Timers and etc.

--
Hope this helps,
Tom Spink
Hi CodeLeon,

I'm afraid it's not that simple. I've taken the liberty of whipping up a
bit of code, that may get you started. It's a component that you add to
your form, and extends your form by adding a property called
HandlePainting. Then, it'll paint all buttons Red and everything else
Green. It doesn't contain any code that will detach the paint event, if
the property was set to false. I also haven't included the
InitializeCompo nent() method, because you should be able to put the
relevant code into your own component class.

///
[ProvideProperty ( "HandlePainting ", typeof( Control ) )]
public partial class PaintModifier : Component, IExtenderProvid er
{
// A map of our handles.
private Dictionary<Cont rol, bool_handleMap;

public PaintModifier ( )
{
// Initialise the handle map.
_handleMap = new Dictionary<Cont rol, bool>();

InitializeCompo nent();
}

public PaintModifier ( IContainer container )
{
// Initialise the handle map.
_handleMap = new Dictionary<Cont rol, bool>();

container.Add( this );
InitializeCompo nent();
}

public bool CanExtend ( object extendee )
{
// Extend only controls.
return extendee is Control;
}

public void SetHandlePainti ng ( Control c, bool value )
{
if ( !_handleMap.Con tainsKey( c ) )
{
_handleMap.Add( c, value );

if ( value )
AttachToControl ( c );
}
else
_handleMap[c] = value;
}

public bool GetHandlePainti ng ( Control c )
{
if ( _handleMap.Cont ainsKey( c ) )
return _handleMap[c];
else
return false;
}

private void AttachToControl ( Control c )
{
c.Paint += new PaintEventHandl er( OnHandlePaintEv ent );
}

private void OnHandlePaintEv ent ( object sender, PaintEventArgs e )
{
if ( sender is Button )
e.Graphics.Clea r( System.Drawing. Color.Red );
else
e.Graphics.Clea r( System.Drawing. Color.Green );
}
}
///

Maybe it will be of some use.

--
Hope this helps,
Tom Spink
Jul 5 '06 #4
Thank you for your timely reply, and i will try to incorporate it into
my product. Check out the blog for this suite at cleanux.blogger .com; i
will periodically post screenshots and graphics here.

Thanx!

Tom Spink wrote:
CodeLeon wrote:
Thank you, but i already did that. What i need to do is get the parent
form of my componenet. Any ideas?

Tom Spink wrote:
CodeLeon wrote:

I am designing an enhanced GUI suite, and i need to know how to:
* Make a user control a "helper" control, ie, one that sits at the
bottom (like timer or process)
* Make this control modify the behavior of the painted controls
already on the form. (ie, make my control handle the painting of the
controls on the page)
* Make the TextBox contol have it's background painted by me. This
seems to be a hassle.

Any help would be deeply appreciated as at the moment i am coding solo
for an open source program.

Thank You!

Hi CodeLeon,

WRT your first point, you need to create a component, not a user-control,
if you want the type of behaviour you see with Timers and etc.

--
Hope this helps,
Tom Spink

Hi CodeLeon,

I'm afraid it's not that simple. I've taken the liberty of whipping up a
bit of code, that may get you started. It's a component that you add to
your form, and extends your form by adding a property called
HandlePainting. Then, it'll paint all buttons Red and everything else
Green. It doesn't contain any code that will detach the paint event, if
the property was set to false. I also haven't included the
InitializeCompo nent() method, because you should be able to put the
relevant code into your own component class.

///
[ProvideProperty ( "HandlePainting ", typeof( Control ) )]
public partial class PaintModifier : Component, IExtenderProvid er
{
// A map of our handles.
private Dictionary<Cont rol, bool_handleMap;

public PaintModifier ( )
{
// Initialise the handle map.
_handleMap = new Dictionary<Cont rol, bool>();

InitializeCompo nent();
}

public PaintModifier ( IContainer container )
{
// Initialise the handle map.
_handleMap = new Dictionary<Cont rol, bool>();

container.Add( this );
InitializeCompo nent();
}

public bool CanExtend ( object extendee )
{
// Extend only controls.
return extendee is Control;
}

public void SetHandlePainti ng ( Control c, bool value )
{
if ( !_handleMap.Con tainsKey( c ) )
{
_handleMap.Add( c, value );

if ( value )
AttachToControl ( c );
}
else
_handleMap[c] = value;
}

public bool GetHandlePainti ng ( Control c )
{
if ( _handleMap.Cont ainsKey( c ) )
return _handleMap[c];
else
return false;
}

private void AttachToControl ( Control c )
{
c.Paint += new PaintEventHandl er( OnHandlePaintEv ent );
}

private void OnHandlePaintEv ent ( object sender, PaintEventArgs e )
{
if ( sender is Button )
e.Graphics.Clea r( System.Drawing. Color.Red );
else
e.Graphics.Clea r( System.Drawing. Color.Green );
}
}
///

Maybe it will be of some use.

--
Hope this helps,
Tom Spink
Jul 5 '06 #5

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

Similar topics

7
3555
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET) template. Briefly -------------------------------------------------------------------------------------------- I need to create dynamically some controls on the forms, and display these
6
3318
by: SamIAm | last post by:
Hi am creating a email application that needs to mail out a very large amount of emails. I have created a multithreaded c# application that using message queuing. I have created a threadpool of 5 threads and each thread checks the queue, receives the message and sends an email. How do I determine the right amount of threads to create? Thanks, S
2
3977
by: Mevar81 | last post by:
Hi to everybody.I have a problem with the PropertyGrid control.I want to display not all the properties of a generic Control(Button,TextBox,ComboBox,ecc.).In general I don't want to display only one category(Appearance, Behavior,ecc.) but I want to chose directly which properties to show.I've read that I can use the SelectedObjects to put an array of object with some properties in common with the SelectedObject,and only properties in...
0
1906
by: Duncan Mole | last post by:
Hi, I have created a control which draws a title bar and provides a drop down menu for a Smart Device Application. It seemed to work fine until I came to add an event handler to act on Paint messages in the form which has drawn the control. Evidently, the control is consuming all of these messages. How can I pass them back/on? I have a reference to the owner form but calling Refresh() via this reference isn't helping. Help! Do I need to...
1
2324
by: Kris van der Mast | last post by:
Hi, been a while since I posted a question myself instead of trying to help others out. I'm refactoring an existing web app that uses dynamic loading of user controls and a lot of response.redirects to the same page. Because I hate the overhead by doing this I'm searching for a cleaner option. But I'm having troubles (off course or I wouldn't be posting this).
11
2199
by: Özden Irmak | last post by:
Hello, In my VB.Net application I create a new instance of my form like : NewForm = new MyNewForm() But with this line, this new form is automatically shown. I want it to be hidden at the start... Adding a line after this line like :
3
499
by: Charles Law | last post by:
Sorry for reposting this question, but I did not get a single answer last time, and I'm sure you guys must have some thoughts on the matter. I have a user control which can be dragged and dropped onto a form in my application when it is running. I allow it to be clicked and dragged to a new location on the form. However, the user control has a check box on it, and if the user clicks over the checkbox to drag the user control, the check...
0
2469
by: Matthew | last post by:
All, I have searched google and the newsgroups but can't find anything the same as what I am experiencing (though I may have missed something). I have controls (textboxes) within UserControls which are not behaving as I would expect. Specifically, if there is a command button external to the usercontrol which is activated by a shortcut key (eg Alt-B), the command button Click event handler code 'executes' even though the textbox set...
15
5276
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to show - text boxes, input boxes, buttons, hyperlinks ie the usual. The data is not obtained directly from a database.
0
8987
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
9534
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9366
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...
0
9241
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
8239
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...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3303
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
3
2211
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.