BackgroundTrans -

Issue #49 closed
Winter Laite created an issue

Apparently not implemented. ‘Keyword_BackgroundTrans’ exists in Keysharp.Core.Core, but I can’t find a way to set it.

Code that works in AHK, and throws no errors in Keysharp but looks wrong:

MyGui := Gui("-DPIScale +E0x02080000", "Candy Progress")
MyGui.BackColor := "FFCC00"
CandyText := MyGui.Add("Text" ,"x20  y24 w436 h20 Center BackgroundTrans")
CandyText.SetFont("cFFFFFF")
Icon1 := MyGui.Add("Picture",  "x20 y20 w18  h36  BackgroundTrans", "Icon1.ico")        ;left part
Icon2 := MyGui.Add("Picture","x38 y20 w400 h36  BackgroundTrans", "Icon2.ico" )
Icon3 := MyGui.Add("Picture", "x438 y20 w18 h36 BackgroundTrans", "Icon3.ico")
MyGui.Show("w480 h100")

AHK appearance:

Keysharp appearance:

Comments (9)

  1. Matt Feemster repo owner

    After doing a lot of research, it turns out that this can be done, but it requires a special step due to how winforms works

    so i have implemented that

    a control can't be truly transparent relative to the control it's overlaid on, unless it's a child of that control

    so i have added a property to GuiControl called Parent

    the tricky part is that it makes the x,y position coordinate of the child control now be relative to the parent, rather than the entire form

    so in this case, create the label, then create the center of the progress bar, then do label.Parent = icon2

    when you initially set the label position coordinates, make them something like 0,0 or whatever looks good such that it's positioned in the center of the candy progress bar

    that's the best we can do. not ideal, but this scenario is also not common

    i've made a note of it in my long running list of notes

  2. Winter Laite reporter

    This code now works, and looks good. Note the ‘x' and 'y’ coords for the label.

    MyGui := Gui("-DPIScale +E0x02080000", "Candy Progress")
    MyGui.BackColor := "FFCC00"
    CandyText := MyGui.Add("Text" ,"x-20  y5 w436 h20 Center BackgroundTrans", "TESTING")
    CandyText.SetFont("cFFFFFF")
    Icon1 := MyGui.Add("Picture",  "x20 y20 w18  h36  BackgroundTrans", "Icon1.ico")        ;left part
    Icon2 := MyGui.Add("Picture","x38 y20 w400 h36  BackgroundTrans", "Icon2.ico" )
    CandyText.Parent := Icon2
    Icon3 := MyGui.Add("Picture", "x438 y20 w18 h36 BackgroundTrans", "Icon3.ico")
    MyGui.Show("w480 h100")
    

  3. Winter Laite reporter

    However, as yet I’ve been unable to combine this with a progress bar. I will try to come up with working code using a progress bar.

  4. Winter Laite reporter

    This code works, I’m going to close it. The result isn’t perfect, but it’s pretty good.

    
    
    MyGui := Gui("-DPIScale +E0x02080000", "Candy Progress")
    
    MyGui.BackColor := "FFCC00"
    
    CandyText := MyGui.Add("Text" ,"x0 y0 w436 h40 Center BackgroundTrans") ; best so far
    CandyText.SetFont("cFFFFFF")
    
    
    CandyProgress := MyGui.Add("Progress", "x20 y30 w436 h36")
    
    Icon1 := MyGui.Add("Picture",  "x0 y0 w18  h36  BackgroundTrans", "Icon1.ico")        ;left part
    Icon2 := MyGui.Add("Picture","x18 y0 w400 h36  BackgroundTrans", "Icon2.ico" )
    Icon3 := MyGui.Add("Picture", "x418 y0 w18 h36 BackgroundTrans", "Icon3.ico")
    
    Icon1.Parent := CandyProgress
    Icon2.Parent := CandyProgress
    Icon3.Parent := CandyProgress
    CandyText.Parent := Icon2
    
    
    MyGui.Show("w480 h150")
    value := 0
    While True {
         if (value >= 33) and (value <= 66) {
            CandyProgress.Opt("cPurple")
         }
         else if (value >= 66) {
            CandyProgress.Opt("cAqua")
        }       
         else {
            CandyProgress.Opt("cBlack")
        }
        CandyProgress.Value := value
        CandyText.Text := value . "%"
        value := value + 1
        if (value > 100)
        {
                Sleep(1000)
                value := 0
        }
        Sleep(100)
    }
    

  5. Log in to comment