DrawHighliteGradientFrame – Draw a form with raised/sunken gradient borders

DrawHighliteGradientFrame – Draw a form with raised/sunken gradient borders

Private Type POINTAPI    x As Long    Y As LongEnd TypePrivate Declare Function SetPixel& Lib "gdi32" (ByVal hDC As Long, _    ByVal x As Long, ByVal Y As Long, ByVal crColor As Long)Private Declare Function LineTo& Lib "gdi32" (ByVal hDC As Long, _    ByVal x As Long, ByVal Y As Long)Private Declare Function MoveToEx Lib "gdi32" (ByVal hDC As Long, _    ByVal x As Long, ByVal Y As Long, lpPoint As POINTAPI) As Long' Create a form with a 3D gradient frame'' Pass this a borderless form' You get better results with AutoRedraw set to TRUE' and with HiLiteCol and ShadowCol "close" to the' form's BackColor'' It draws a series of lines around the form' starting on the outside and moving one pixel inward with each line' the number of lines is determined by the "Steps" value that is passed.' The Left and Top use the "HiliteCol" value' the Right and Bottom use the "ShadowCol" value.' Swap them to get a sunken effect' Call this routine from within Form_Load, as in:'    Sub Form_Load()'        Const MyBackgroundColor = 16119262'        Const MyShadowColor = 14474381'        Const MyHiLiteColor = 15329769'        Me.BackColor = MyBackgroundColor'        DrawHighliteGradientFrame Me, MyHiLiteColor, MyShadowColor, 7'    End SubSub DrawHighliteGradientFrame(FormIn As Form, ByVal HiLiteCol As Long, _    ByVal ShadowCol As Long, ByVal Steps As Integer)    ' exit if the form is minimized    If FormIn.WindowState = vbMinimized Then Exit Sub           Dim InnerCol As Long    Dim R_Inner As Long, G_Inner As Long, B_Inner As Long    Dim R_HiLite As Long, G_HiLite As Long, B_HiLite As Long     Dim R_Shadow As Long, G_Shadow As Long, B_Shadow As Long    Dim R_HiLiteIncr As Single, G_HiLiteIncr As Single, B_HiLiteIncr As Single,    Dim R_HiLiteCur As Single, G_HiLiteCur As Single, B_HiLiteCur As Single    Dim R_ShadowIncr As Single, G_ShadowIncr As Single, B_ShadowIncr As Single,    Dim R_ShadowCur As Single, G_ShadowCur As Single, B_ShadowCur As Single    Dim sTemp As String, i As Integer, WD  As Long, HT As Long, DC As Long    Dim pos As Integer, LP As POINTAPI, LongVal As Long    Dim oldScaleMode As Integer, oldForeColor As Long         ' switch to pixel scalemode    oldForeColor = FormIn.ForeColor    oldScaleMode = FormIn.ScaleMode    FormIn.ScaleMode = vbPixels        'Set the form width, height & DC    With FormIn       WD = .ScaleWidth - 1       HT = .ScaleHeight - 1       DC = .hDC    End With        'convert the hilite color from long to RGB    R_HiLite = (HiLiteCol And &HFF&)    G_HiLite = (HiLiteCol And &HFF00&) / &H100&    B_HiLite = (HiLiteCol And &HFF0000) / &H10000        'convert the shadow color from long to RGB    R_Shadow = (ShadowCol And &HFF&)    G_Shadow = (ShadowCol And &HFF00&) / &H100&    B_Shadow = (ShadowCol And &HFF0000) / &H10000        'convert the inner color from long to RGB    InnerCol = FormIn.BackColor    R_Inner = (InnerCol And &HFF&)    G_Inner = (InnerCol And &HFF00&) / &H100&    B_Inner = (InnerCol And &HFF0000) / &H10000            'set the increments    R_HiLiteIncr = (R_HiLite - R_Inner) / Steps    G_HiLiteIncr = (G_HiLite - G_Inner) / Steps    B_HiLiteIncr = (B_HiLite - B_Inner) / Steps    R_ShadowIncr = (R_Shadow - R_Inner) / Steps    G_ShadowIncr = (G_Shadow - G_Inner) / Steps    B_ShadowIncr = (B_Shadow - B_Inner) / Steps        'initialize the current colors    R_HiLiteCur = R_HiLite    G_HiLiteCur = G_HiLite    B_HiLiteCur = B_HiLite    R_ShadowCur = R_Shadow    G_ShadowCur = G_Shadow    B_ShadowCur = B_Shadow        With FormIn        For i = 0 To Steps - 1            'draw clockwise from bottom / left                        'Use hilite color            'Round the RGB vals  to integers and convert to a long color value            LongVal = (Int(B_HiLiteCur) * 65536) + (Int(G_HiLiteCur) * 256) + _                Int(R_HiLiteCur)                        'set the drawing color            .ForeColor = LongVal                        'Draw the left and top            MoveToEx DC, i, HT - i, LP        'left            LineTo DC, i, i            MoveToEx DC, i, i, LP             'top            LineTo DC, WD - i, i                        'Use shadow color            'Round the RGB vals  to integers and convert to a long color value            LongVal = (Int(B_ShadowCur) * 65536) + (Int(G_ShadowCur) * 256) + _                Int(R_ShadowCur)                        'set the drawing color            .ForeColor = LongVal                        'Draw the right and bottom            MoveToEx DC, WD - i, i, LP       'right            LineTo DC, WD - i, HT - i            MoveToEx DC, WD - i, HT - i, LP  'bottom            LineTo DC, i, HT - i                        'increment the colors            R_HiLiteCur = R_HiLiteCur - R_HiLiteIncr            G_HiLiteCur = G_HiLiteCur - G_HiLiteIncr            B_HiLiteCur = B_HiLiteCur - B_HiLiteIncr            R_ShadowCur = R_ShadowCur - R_ShadowIncr            G_ShadowCur = G_ShadowCur - G_ShadowIncr            B_ShadowCur = B_ShadowCur - B_ShadowIncr        Next           .Refresh    End With    ' restore original values    FormIn.ForeColor = oldForeColor    FormIn.ScaleMode = oldScaleModeEnd Sub

devx-admin

devx-admin

Share the Post:
Poland Energy Future

Westinghouse Builds Polish Power Plant

Westinghouse Electric Company and Bechtel have come together to establish a formal partnership in order to design and construct Poland’s inaugural nuclear power plant at

EV Labor Market

EV Industry Hurting For Skilled Labor

The United Auto Workers strike has highlighted the anticipated change towards a future dominated by electric vehicles (EVs), a shift which numerous people think will

Soaring EV Quotas

Soaring EV Quotas Spark Battle Against Time

Automakers are still expected to meet stringent electric vehicle (EV) sales quotas, despite the delayed ban on new petrol and diesel cars. Starting January 2023,

Affordable Electric Revolution

Tesla Rivals Make Bold Moves

Tesla, a name synonymous with EVs, has consistently been at the forefront of the automotive industry’s electric revolution. The products that Elon Musk has developed

Poland Energy Future

Westinghouse Builds Polish Power Plant

Westinghouse Electric Company and Bechtel have come together to establish a formal partnership in order to design and construct Poland’s inaugural nuclear power plant at the Lubiatowo-Kopalino site in Pomerania.

EV Labor Market

EV Industry Hurting For Skilled Labor

The United Auto Workers strike has highlighted the anticipated change towards a future dominated by electric vehicles (EVs), a shift which numerous people think will result in job losses. However,

Soaring EV Quotas

Soaring EV Quotas Spark Battle Against Time

Automakers are still expected to meet stringent electric vehicle (EV) sales quotas, despite the delayed ban on new petrol and diesel cars. Starting January 2023, more than one-fifth of automobiles

Affordable Electric Revolution

Tesla Rivals Make Bold Moves

Tesla, a name synonymous with EVs, has consistently been at the forefront of the automotive industry’s electric revolution. The products that Elon Musk has developed are at the forefront because

Sunsets' Technique

Inside the Climate Battle: Make Sunsets’ Technique

On February 12, 2023, Luke Iseman and Andrew Song from the solar geoengineering firm Make Sunsets showcased their technique for injecting sulfur dioxide (SO₂) into the stratosphere as a means

AI Adherence Prediction

AI Algorithm Predicts Treatment Adherence

Swoop, a prominent consumer health data company, has unveiled a cutting-edge algorithm capable of predicting adherence to treatment in people with Multiple Sclerosis (MS) and other health conditions. Utilizing artificial

Personalized UX

Here’s Why You Need to Use JavaScript and Cookies

In today’s increasingly digital world, websites often rely on JavaScript and cookies to provide users with a more seamless and personalized browsing experience. These key components allow websites to display

Geoengineering Methods

Scientists Dimming the Sun: It’s a Good Thing

Scientists at the University of Bern have been exploring geoengineering methods that could potentially slow down the melting of the West Antarctic ice sheet by reducing sunlight exposure. Among these

why startups succeed

The Top Reasons Why Startups Succeed

Everyone hears the stories. Apple was started in a garage. Musk slept in a rented office space while he was creating PayPal with his brother. Facebook was coded by a

Bold Evolution

Intel’s Bold Comeback

Intel, a leading figure in the semiconductor industry, has underperformed in the stock market over the past five years, with shares dropping by 4% as opposed to the 176% return

Semiconductor market

Semiconductor Slump: Rebound on the Horizon

In recent years, the semiconductor sector has faced a slump due to decreasing PC and smartphone sales, especially in 2022 and 2023. Nonetheless, as 2024 approaches, the industry seems to

Elevated Content Deals

Elevate Your Content Creation with Amazing Deals

The latest Tech Deals cater to creators of different levels and budgets, featuring a variety of computer accessories and tools designed specifically for content creation. Enhance your technological setup with

Learn Web Security

An Easy Way to Learn Web Security

The Web Security Academy has recently introduced new educational courses designed to offer a comprehensible and straightforward journey through the intricate realm of web security. These carefully designed learning courses

Military Drones Revolution

Military Drones: New Mobile Command Centers

The Air Force Special Operations Command (AFSOC) is currently working on a pioneering project that aims to transform MQ-9 Reaper drones into mobile command centers to better manage smaller unmanned

Tech Partnership

US and Vietnam: The Next Tech Leaders?

The US and Vietnam have entered into a series of multi-billion-dollar business deals, marking a significant leap forward in their cooperation in vital sectors like artificial intelligence (AI), semiconductors, and

Huge Savings

Score Massive Savings on Portable Gaming

This week in tech bargains, a well-known firm has considerably reduced the price of its portable gaming device, cutting costs by as much as 20 percent, which matches the lowest

Cloudfare Protection

Unbreakable: Cloudflare One Data Protection Suite

Recently, Cloudflare introduced its One Data Protection Suite, an extensive collection of sophisticated security tools designed to protect data in various environments, including web, private, and SaaS applications. The suite

Drone Revolution

Cool Drone Tech Unveiled at London Event

At the DSEI defense event in London, Israeli defense firms exhibited cutting-edge drone technology featuring vertical-takeoff-and-landing (VTOL) abilities while launching two innovative systems that have already been acquired by clients.

2D Semiconductor Revolution

Disrupting Electronics with 2D Semiconductors

The rapid development in electronic devices has created an increasing demand for advanced semiconductors. While silicon has traditionally been the go-to material for such applications, it suffers from certain limitations.

Cisco Growth

Cisco Cuts Jobs To Optimize Growth

Tech giant Cisco Systems Inc. recently unveiled plans to reduce its workforce in two Californian cities, with the goal of optimizing the company’s cost structure. The company has decided to

FAA Authorization

FAA Approves Drone Deliveries

In a significant development for the US drone industry, drone delivery company Zipline has gained Federal Aviation Administration (FAA) authorization, permitting them to operate drones beyond the visual line of

Mortgage Rate Challenges

Prop-Tech Firms Face Mortgage Rate Challenges

The surge in mortgage rates and a subsequent decrease in home buying have presented challenges for prop-tech firms like Divvy Homes, a rent-to-own start-up company. With a previous valuation of

Lighthouse Updates

Microsoft 365 Lighthouse: Powerful Updates

Microsoft has introduced a new update to Microsoft 365 Lighthouse, which includes support for alerts and notifications. This update is designed to give Managed Service Providers (MSPs) increased control and

Website Lock

Mysterious Website Blockage Sparks Concern

Recently, visitors of a well-known resource website encountered a message blocking their access, resulting in disappointment and frustration among its users. While the reason for this limitation remains uncertain, specialists