Delphi vs Winform - Score 1 for Delphi [Edit]

This might be a little techie, but I think most people here are familiar with Delphi to understand the difference between a TWinControl and TGraphicControl.  

I was trying to create a C# Winform project based on a Delphi prototype and ran into this problem which I posted to some Winform forums ... 

This led me to an *obvious* deficiency in Winforms programming. I'd like to hear your thoughts.

My question to the Winforms forums describing the problem is copied below:

<snip>

Hi, I mostly do Delphi development but would like to start my next small work project in Visual Studio using C# and Winforms.

Right away I see that there is something so easy to do in Delphi and potentially difficult to do in WinForms. I am hoping maybe someone could explain to me how this UI design task could be accomplished easily with WinForms.

Here is my design goal:

I would like to design screens with graphical elements (controls positioned at design time) which overlap each other. These graphical elements do not accept user input, but usually convey some text, image, background, shape, or other drawn item. The key though is this: these items are not rectangles, they are words or shapes and colors that may overlap one anther.

Here is a screenshot from my Delphi prototype which uses GraphicControl classes (standard in Delphi) to accomplish my goal:

http://imagebot.org/snapshops/overlapping.jpg

Above we have an  image control, two text label control, and a infobox control (rounded edged, interior gradient fill). Notice that the infobox is in the back, the text on top of it, and the image (globe with people) is to the left.

Now I can easily create these layouts in the form design using Delphi, but with Winforms there is a problem; all controls are windows and thus rectangular. They will clip the drawing of the controls behind them and not give me the composited per pixel transparency I am going for. See a closer look of of the screen above an notice the controls are blended together:

http://imagebot.org/snapshops/closer.jpg

Notice the variable per pixel level alpha blending. So my question is, how can I create this same layout in the Winforms visual designer where controls have variable levels of alpha blending per pixel and are all layered together on on top of another?

I can think of one solution, which is to have a control that requests controls underneath it to paint themselves in it (typically by sending WM_PAINT with your DC and the origin offset).

Is this already handled by the Winforms framework?
Is there a simple method I can call to compisite controls together?
Have other people tackled this problem and solved it in a form that can be downloaded?

</snip>
1
Anthony
10/21/2009 8:10:28 PM
embarcadero.delphi.non-tech 5933 articles. 1 followers. Follow

11 Replies
2137 Views

Similar Articles

[PageSpeed] 50

"Anthony Walter" wrote: .
>
>
> Here is my design goal:
>
> I would like to design screens with graphical elements (controls 
> positioned at design time) which overlap each other. These graphical 
> elements do not accept user input, but usually convey some text, image, 
> background, shape, or other drawn item. The key though is this: these 
> items are not rectangles, they are words or shapes and colors that may 
> overlap one anther.
>
....
>
> Is this already handled by the Winforms framework?
> Is there a simple method I can call to compisite controls together?
> Have other people tackled this problem and solved it in a form that can be 
> downloaded?

Have you considered the Winforms designer that is included with .NET 2.0? 
You can find example code on how to host the designer in a Winforms form if 
you do a Google on "hosting winforms designer".
0
John
10/21/2009 8:53:55 PM
I'm no C# developer but I believe you can do this by:

1. Setting the overlapping controls BackColor as Color.Transparent
2. Setting the overlapping controls parent as the control its on top of, e.g.:

http://www.climsystems.com/misc/Untitled-2.jpg

// pictureBox1 is the blue swirl
// hello world
label1.BackColor = System.Drawing.Color.Transparent;
label1.Parent = pictureBox1;

// the blue/green circle with the semi-transparent 'reflection' (PNG file)
pictureBox2.BackColor = System.Drawing.Color.Transparent;
pictureBox2.Parent = pictureBox1;

Perhaps not as robust as TGraphicControl but it can be done. 

--
Climate change and adaptation software and services - http://www.climsystems.com/

Edited by: Matthew Dooley on Oct 21, 2009 2:20 PM
0
Matthew
10/21/2009 9:20:34 PM
> {quote:title=John Cash wrote:}{quote}
> "Anthony Walter" wrote: .
> >
> >
> > Here is my design goal:
> >
> > I would like to design screens with graphical elements (controls 
> > positioned at design time) which overlap each other. These graphical 
> > elements do not accept user input, but usually convey some text, image, 
> > background, shape, or other drawn item. The key though is this: these 
> > items are not rectangles, they are words or shapes and colors that may 
> > overlap one anther.
> >
> ...
> >
> > Is this already handled by the Winforms framework?
> > Is there a simple method I can call to compisite controls together?
> > Have other people tackled this problem and solved it in a form that can be 
> > downloaded?
> 
> Have you considered the Winforms designer that is included with .NET 2.0? 
> You can find example code on how to host the designer in a Winforms form if 
> you do a Google on "hosting winforms designer".
 
I have Visual Studio installed. Why would I need "the Winforms designer"?
0
Anthony
10/21/2009 9:40:12 PM
> {quote:title=Matthew Dooley wrote:}{quote}
> I'm no C# developer but I believe you can do this by:
> 
> 1. Setting the overlapping controls BackColor as Color.Transparent
> 2. Setting the overlapping controls parent as the control its on top of, e.g.:
> 
> http://www.climsystems.com/misc/Untitled-2.jpg
> 
> // pictureBox1 is the blue swirl
> // hello world
> label1.BackColor = System.Drawing.Color.Transparent;
> label1.Parent = pictureBox1;
> 
> // the blue/green circle with the semi-transparent 'reflection' (PNG file)
> pictureBox2.BackColor = System.Drawing.Color.Transparent;
> pictureBox2.Parent = pictureBox1;
> 
> Perhaps not as robust as TGraphicControl but it can be done. 

Okay, that did make some difference, and I didn't know you could do that with Winforms. Kudos!

*But*, your solution is not without its own problems..

http://imagebot.org/snapshops/some-clipping.jpg

Child controls still clip each other and the parent control clips the children. In my original example if I were to parent the image and labels to the infobox control, the image would be clipped because it lays 50% inside the left edge of the infobox and 50% outside the left edge of the infobox.
0
Anthony
10/21/2009 9:49:27 PM
> Okay, that did make some difference, and I didn't know you could do that with Winforms. Kudos!
> 
> *But*, your solution is not without its own problems..
> 
> http://imagebot.org/snapshops/some-clipping.jpg
> 
> Child controls still clip each other and the parent control clips the children. In my original example if I were to parent the image and labels to the infobox control, the image would be clipped because it lays 50% inside the left edge of the infobox and 50% outside the left edge of the infobox.

Ah yes I see.  The best solution at this point would be to create a custom control and draw everything yourself, or use your WM_PAINT idea (which I can only guess comes with its own set of hassles). 
--
Climate change and adaptation software and services - http://www.climsystems.com/
0
Matthew
10/21/2009 10:05:34 PM
"Anthony Walter" wrote:
>> {quote:title=John Cash wrote:}{quote}
>> "Anthony Walter" wrote: .
>> >
>> >
>> > Here is my design goal:
>> >
>> > I would like to design screens with graphical elements (controls
>> > positioned at design time) which overlap each other. These graphical
>> > elements do not accept user input, but usually convey some text, image,
>> > background, shape, or other drawn item. The key though is this: these
>> > items are not rectangles, they are words or shapes and colors that may
>> > overlap one anther.
>> >
>> ...
>> >
>> > Is this already handled by the Winforms framework?
>> > Is there a simple method I can call to compisite controls together?
>> > Have other people tackled this problem and solved it in a form that can 
>> > be
>> > downloaded?
>>
>> Have you considered the Winforms designer that is included with .NET 2.0?
>> You can find example code on how to host the designer in a Winforms form 
>> if
>> you do a Google on "hosting winforms designer".
>
> I have Visual Studio installed. Why would I need "the Winforms designer"?

Because it will provide the design surface in your application that allows 
you to place elements on it and move them around - plus a lot more.
0
John
10/21/2009 10:43:11 PM
> {quote:title=John Cash wrote:}{quote}
> Because it will provide the design surface in your application that allows 
> you to place elements on it and move them around - plus a lot more.

And this has something to do with the problem I described how?
0
Anthony
10/21/2009 11:40:19 PM
> {quote:title=Matthew Dooley wrote:}{quote}
> > Okay, that did make some difference, and I didn't know you could do that with Winforms. Kudos!
> > 
> > *But*, your solution is not without its own problems..
> > 
> > http://imagebot.org/snapshops/some-clipping.jpg
> > 
> > Child controls still clip each other and the parent control clips the children. In my original example if I were to parent the image and labels to the infobox control, the image would be clipped because it lays 50% inside the left edge of the infobox and 50% outside the left edge of the infobox.
> 
> Ah yes I see.  The best solution at this point would be to create a custom control and draw everything yourself, or use your WM_PAINT idea (which I can only guess comes with its own set of hassles). 


What might work is a container control which specifically renders the children in z-order inside of itself and then ...

well this is another problem with .NET ... I can't easily view base library the source code and step through it to learn how it works. And even when you do get the source code to the control framework, it's not nearly as nicely designed around known knowns and known unknowns (the Windows API) as the VCL controls. There is no Windows.pas in .NET, which is all Winforms is anyways ... a layer on top of the Windows API.
0
Anthony
10/22/2009 12:28:27 AM
"Anthony Walter" wrote in message news:175429@forums.codegear.com...
>> {quote:title=John Cash wrote:}{quote}
>> Because it will provide the design surface in your application that 
>> allows
>> you to place elements on it and move them around - plus a lot more.
>
> And this has something to do with the problem I described how?

> Here is my design goal:
>
> I would like to design screens with graphical elements (controls
> positioned at design time) which overlap each other. These graphical
> elements do not accept user input, but usually convey some text, image,
> background, shape, or other drawn item. The key though is this: these
> items are not rectangles, they are words or shapes and colors that may
> overlap one anther.
0
John
10/22/2009 12:56:31 AM
I've cancelled multiple personal attacks (and replies to same) in this
thread. Please keep it civil.

-- 
Craig Stuntz · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz/
0
Craig
10/22/2009 3:33:41 PM
"Craig Stuntz" wrote:
> I've cancelled multiple personal attacks (and replies to same) in this
> thread. Please keep it civil.
> 

Thanks...
0
John
10/22/2009 4:22:14 PM
Reply:

Similar Artilces:

SEPA components for Delphi with Source Code (Delphi 5
Hi all, in the european union change next year the Bankingformat to the SEPA Format. All peoples and companies must change the bankingssoftware and the costumer data form acountnummers in the new IBAN and BIC numbers. See: http://www.arma-it.de/shop/artikelueber.php?wgruppeid=211&wgruppe_offen=211 Functions: - generate SEPA XML'S - Calc IBAN - BIC Database (DE,AT and CH) Questions: vertrieb@arma-it.de PS: Bankinssoftware for Develpoers (Germany only) http://www.arma-it.de/shop/artikelueber.php?wgruppeid=212&wgruppe_offen=212 El 26/10/13 21:38, A...

Delphi and Delphi for .Net
It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. I would like to know is it true all .Net application is slower than Win32 native applicaiton or it is Delphi for .Net only. Your information is great appreciated, Inung On 2011-06-21 18:20:17 +0100, Inung Huang said: > It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. > I would like to know is it true all .Net application is slower than > Win32 native applicaiton or it is Delphi for .Net only. If you are only running the code in the application once then, yes, yo...

IOS Setup in Delphi help
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --JivePart=_8d526.zeB8CwDOH5aMJzMl Content-Type: text/plain; charset="Utf-8" --JivePart=_8d526.zeB8CwDOH5aMJzMl Content-Type: application/msword; name="Create Profile for Delphi.doc" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="Create Profile for Delphi.doc" 0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAAFAAAAbwIAAAAAAAAA EAAAcQIAAAEAAAD+////AAAAAGoCAABrAgAAbAIAAG...

New to Delphi
Hi I am new to Delphi & want to know good resources for learning to use it. Is there a list of good Delphi learning resources (books/online tutorials) somewhere? What recommendations can anyone make for someone new to Delphi (& only a hobby programmer at the moment)? A couple of weeks ago I started with DelphiXE4 trial & have Googled for a few Delphi resources but I haven't found anything very good yet for me as a beginner. I'm just struggling along trying to learn as I go! (I'm presently struggling with DragandDrop...see [http://stackoverflow.com/questions/17232...

Convert Delphi 7 to Delphi 2009 [Edit]
Hi! Please, I have a code done in Delphi 7... Now I want to convert Delphi 7 to Delphi 2009 but I'm having problems when compile the code. Error message: +[DCC Fatal Error] Far.dpr(9): F2063 Could not compile used unit 'System.pas'+ Please can somebody help me? Source Download (349KB): http://rapidshare.com/files/256191328/FileManager.rar.html Mirror Source Download: http://www.megaupload.com/?d=12GYLPT0 Password: delphi Thank u so much! (sorry for my bad english, it is not my native language) Edited by: loquax loquax on Jul 15, 2009 12:24 PM Sorry, bu...

Question about Delphi 2009 vs Delphi 7
Hi, I was wondering if any of you can point me to a URLs that show the most important improvements between these versions of Delphi. The objective is convincing the powers-that-pay-the-bills that moving to D2009 (that we'd have to purchase) is a better idea than moving to D7 (for which we have licenses). Fire at will! -- Saluti, Alessandro Federici ------------------------------- "I have been through some terrible things in my life, some of which actually happened." (Mark Twain) Alessandro Federici wrote: > Hi, > I was wondering if any of yo...

Memory usage in Delphi 2007 vs. Delphi 5
Going from Delphi 5 to Delphi 2007 and finding something way unexpected. The reportedly *same code, and same data,* uses about 104 MB in Delphi 5 and about 400 MB in Delphi 2007 according to the Windows Task Manager. Now, I know that it is not the most accurate way of measuring memory usage, but it gives us an idea of the proportion of memory use in Delphi 2007. Before we go deeper, we just created 20,000 objects and added them to an object list in Delphi 5 and 2007. The result in memory use still looks like 50 MB (Delphi 5) to 178 MB (Delphi 2007). We've downloaded ...

Update Delphi 2005 to Delphi 2010, which do i need? [Edit]
Hello, we have one Delphi 2005 Professional here and want to upgrade to Delphi 2010, but we are a bit confused. Our distributor in Germany, ingram-micro offers several upgrade products: UPG DELPHI 2010 PRO - NAMED USER UPG DELPHI 2010 PRO - NAMED USER ELS UPG DELPHI 2010 PRO - NAMED USER FLEX RAD STUDIO 2010 PRO - UPG UPG RAD STUDIO 2010 PRO - NAMED ELC UPG RAD STUDIO 2010 PRO - NAMED FLEX UPG DELPHI 2010 PRO - CONCURRENT ELS UPG DELPHI 2010 PRO - CONCURRENT FLEX What do they mean exactly and which one do i need? At the moment delphi is installed on two PCs and we want to use ...

Delphi 2006 vs Delphi 2009 IDE stability
Hello, all. I have medium sized project which includes about 20Mb of source code (just size of *.pas files). I use Delphi 2006. There are third party component suites JVCL, DevExpress Bars, Pegasus Imaging. All updates applied. The main problem is IDE stability. About four..five times a day IDE become unstable after intensive usage of code insight functions (most often I press Ctrl+Space key). The best outcome is that I have to save everything and restart the IDE. The worst outcome is when IDE stalls or falls into endless loop of error messages and any unsaved work is lost. OS...

Migrating from Delphi 6 to Delphi XE 3! [Edit]
All, I am a Delphi developer working in an windows form application developed using Delphi 6. Now, we are planning to upgrade the development tool. Can anyone provide me information related to major roadblocks that we can face while migrating from Delphi 6 to Delphi XE 3? Should we migrate to Delphi XE 3 or any other preferred version of Delphi based on the fact that our target users will be using Windows 7 or Windows 8? Do we have any tools or utilities to migrate the source code from Delphi 6 to higher version of Delphi? Also, any suggestions related to best practices are welcome....

Project Manager Delphi 2007 vs Delphi 5
I am in the midst of moving from Delphi 5 to Delphi 2007. I have a .BAT file that I use to do some post processing on the executable after it is built. In Delphi 5, I just added the .BAT file to the project manager. Then when I wanted to execute the .BAT file I just right clicked its entry in the project manager and selected Execute. There doesn't seem to be anyway to add the .BAT file to the project manager in Delphi 2007. How can I set up something similar to what I had in Delphi 5? I thought about using a Post Build event but I don't necessarily want to execute the .BAT fi...

Delphi 7 to Delphi XE: TBlobField to XML [Edit]
Hi, I'm migrating a Delphi7 application to Delphi XE. I'm using a TClientDataSet to communicate, by using a XML frame, with my server. In this TClientDataSet I'm using a TBlobField which is an array of 384 byte. The blobField is allocate by a code like this : {code} myStream : TStream; myStream := aClientDataSet.CreateBlobStream(myBlobField, bmwrite); vResult := myStream.Write(ArrayOf384Byte[0], length(ArrayOf384Byte)); //vResult = 384 => GooD ! (...) {code} For communicate with the server, we have to decode the Blobfield in XML before to sending it. We have...

Delphi 5 (string[80]) vs Delphi XE
Hi guys i'm trying to convert a old application made with Delphi 5 to Delphi XE 5 The probleme i have right now is about String[80] and the Read / Write procedure i have a type like that Type TEnrMess = record Mess : String[80]; MessSuiv : Word; Hint : Word; end; And i read/write this type to a File of TEnrMess My probleme is that the string have changed from Delphi 5 to Delphi XE i join the link of a simple of the probleme that can be compiled on delphi 5 and any Delphi XE https://mega.co.nz/#!wV1VyZzY!1ha5oOxTg7L1WJAOXutUygkj...

Code works in Delphi 7 but not in Delphi 2010 [Edit]
hello, i have a procedure that open's a file by passing the file name as the parameter to the executable. something like this {code} C : \ P r o g r a m F i l e s \ Da c k e r \ D r a c k e r . e x e " G : \ D E l p h i 7 \ D e l p h i 7 A p p _ l o g . t " {code} The source code is {code} procedure OpenFileWithExe var hReg: HKEY; Ret: Longint; RegDataType, RegDataSize: DWORD; CmdLine: array [0..560] of Char; Len: Integer; SInfo: TStartupInfo; PInfo: TProcessInformation; begin Ret := windows.RegOpenKeyEx(HKEY_CURRENT_USER, ...

Win32 program: Delphi 7 vs Delphi XE5
How is a D7 Win32 program compared to a Delphi XE5 one in terms of stability and performance? Is Delphi XE5 good enough for a big ERP project with several DLL's and hundreds of units and forms? Thanks in advance Am 26.12.2013 15:02, schrieb lior ilan: > How is a D7 Win32 program compared to a Delphi XE5 one in terms of stability > and performance? > Is Delphi XE5 good enough for a big ERP project with several DLL's and > hundreds of units and forms? > Thanks in advance > Hello, XE5 has increased functionality. Stability seems to be ok for most ...

Web resources about - Delphi vs Winform - Score 1 for Delphi [Edit] - embarcadero.delphi.non-tech

TDD of a WinForm app – Part 5 – Validating the account data
In our last post, we worked on allowing our user to enter new accounts – basically making our AddAccountForm usable. We were able to do that ...

Stack Overflow
Stack Exchange log in - careers - chat - meta - about - faq Questions Tags Users Badges Unanswered Ask Question Top Questions interesting 325 ...

Barcode Recognition and Creation - 2D Barcodes - Accusoft Pegasus
... documents, process, forms, track inventory or separate document batches ImageGear for .NET .NET 32/64-bit Fully-managed code for Winforms, ...

Why Microsoft has made developers horrified about coding for Windows 8
Microsoft's Windows 8 demonstration at the D9 conference looked pretty, but …

What language was ASP.Net originally written in?
In this video , Peter Hallam, one of the original C# designers talks about a new C# v3 feature, but also says that WinForms was the original ...

Services - Bad At Math's Blog
Services Portfolio Blog About Services Bad At Math is a software consulting and development firm. We specialize in the following areas: Web Development ...

Why WPF for LOB applications? - Bizcoder
... users don’t really care too much about skinning their ERP application, but it does need to look good and it should be consistent. Stock Winforms ...

Getting Started With Your Own Software Company
Eric Sink has a new article in MSDN offering a few suggestions on Getting Started With Your Own Software Company. It sounds exactly how I would ...

Learning WiX from ground up
... And here is a list of tools that you may want to check out: SharpSetup creates bootstrapper and GUI for your WiX installer in C# and WinForms. ...

:: CODE Magazine - Online Content ::
Content by Category .NET 1.x .NET 2.0 .NET 3.0 .NET 3.5 .NET 4.0 .NET Assemblies .NET Framework .NET Getting Started Accessibility ADO.NET Advertorials ...

Resources last updated: 1/8/2016 3:41:40 AM