Custom Form Background

Started by Richard Kelly, April 04, 2014, 03:02:25 AM

Previous topic - Next topic

Richard Kelly

I want to fill the space on the left side of my form with a shape that is basically a rectangle with a portion of circle laid on top. It's a bit hard to describe and I've attached a crude MS Paint example.

Can you paint a circle when its bounding rectangle lays outside the forms client area? This is all done for the forms %WM_ERASEBKGND and is done before any controls are rendered.

Sorry for not putting this question in the appropriate forum. That was careless of me.

Rick Kelly

Richard Kelly

I was able to get something going with:


Function MAIN_CUSTOM ( _
                     hWndForm      As Dword, _  ' handle of Form
                     wMsg          As Long,  _  ' type of message
                     wParam        As Dword, _  ' first message parameter
                     lParam        As Long   _  ' second message parameter
                     ) As Long

Local nCircleSize   As Long
Local hBrush        As Dword
Local rc            As Rect
Local rcClear       As Rect
Local tlb           As LOGBRUSH

   Select Case wMsg

      Case %WM_ERASEBKGND
     

         GetClientRect hWndForm, rc

         tlb.lbStyle = %BS_SOLID
         tlb.lbColor = &H00B4AB97???
         tlb.lbHatch = 0
         
         hBrush = CreateBrushIndirect(tlb)

' Background color

         FillRect wParam, rc, hBrush
         DeleteObject hBrush
         
' Draw Circle         
         
         nCircleSize = rc.Bottom * .3
         
         Ellipse wParam, nCircleSize, -10, rc.Bottom + nCircleSize * 2, rc.Bottom + nCircleSize
         
' Clear right half

         tlb.lbColor = &H00FFFFFF???
         hBrush = CreateBrushIndirect(tlb)
         rcClear = rc
         rcClear.Left = nCircleSize * 3
         FillRect wParam, rcClear, hBrush
         DeleteObject hBrush
         
' Bottom Orange Bar     
         
         rc.Top = rc.Bottom - AfxScaleX(40)
         tlb.lbColor = &H00466BEB??
         hBrush = CreateBrushIndirect(tlb)
         FillRect wParam, rc, hBrush
         DeleteObject hBrush

         Function = %TRUE
         Exit Function

   End Select
End Function


I do have three sphere's that will be on the screen and will use Jose's graphic control. For precise positioning of the spheres along the arc of the circle, I'll have to do the standard cosine/sine calculations to get the circle points and move the controls everytime I paint the background.

I need to get familiar with Jose's GDI+ classes.

Richard Kelly

#2
For those interested, with just a small bit of code to paint the background, my app's main form now looks like the attachment.

My goal was not only to be a bit unique, it was also to use clear entry points into the app and drive my users to the primary tasks. I will have some minor tweaking to do so add a small bit of secondary navigation for other options.

I do have a question - my forms icon shows in the designer and when I run the app, it disappears and you can see in the picture. Am I doing something wrong? Icon attached was converted from PNG to ICO with IconFx software.

Rick Kelly

Paul Squires

Cool interface :)

Kind of sounds like an icon issue. I believe we've run into this issue before (icons created from PNGs using IconFx). Have you tried a generic "normal" icon to see if it shows up? That way, we could verify or eliminate the PNG->ICO conversion as the source of the problem.
Paul Squires
PlanetSquires Software

Richard Kelly

Quote from: TechSupport on April 07, 2014, 01:15:41 PM
Cool interface :)

Kind of sounds like an icon issue. I believe we've run into this issue before (icons created from PNGs using IconFx). Have you tried a generic "normal" icon to see if it shows up? That way, we could verify or eliminate the PNG->ICO conversion as the source of the problem.

I grabbed another ICO and it seemed work so I questioned the conversion...maybe IconFx has a problem.

Robert Eaton

I recall an icon problem if the PNG icon used compression.

Richard Kelly

Quote from: Robert Eaton on April 07, 2014, 01:59:01 PM
I recall an icon problem if the PNG icon used compression.

I went back to the original PNG file and used the converter at:


http://www.convertico.com/


and now the ICO works perfectly. I will report the issue to IconFX.

Rick

Richard Kelly

Quote from: Richard Kelly on April 08, 2014, 03:03:13 AM
Quote from: Robert Eaton on April 07, 2014, 01:59:01 PM
I recall an icon problem if the PNG icon used compression.

I went back to the original PNG file and used the converter at:


http://www.convertico.com/


and now the ICO works perfectly. I will report the issue to IconFX.

Rick

When I took another look at each ICO, and both were converted from the same source PNG, the IconFX icon contained 8 images and the web site converter contained 3 (48/32/16). I removed the extra 5 images from the IconFX image and now it works as it should. There is something about the non 32bit images that must be causing the problem.

Rick

Jean-pierre Leroy

Quote
I removed the extra 5 images from the IconFX image and now it works as it should.
Hi Richard,

I'm curious to know how you do that ? with which tools ?

Thanks, Jean-Pierre

Richard Kelly

#9
Quote from: Jean-pierre Leroy on April 09, 2014, 05:32:44 AM
Quote
I removed the extra 5 images from the IconFX image and now it works as it should.
Hi Richard,

I'm curious to know how you do that ? with which tools ?

Thanks, Jean-Pierre

IconFX

I went back and repeated the process, the difference being I used a 256x256 PNG. I ended up with an ICO with 256, 128, 64, 48, 32, and 16 size images, all 32 bit and things still work. It's looking like the lower resolution images are causing the problems.

As you can see from the attached picture, all my icons, even in smaller sizes seem to be rendering properly.

Rick