Mirage Source
http://web.miragesource.net/forums/

Fading / Darkning
http://web.miragesource.net/forums/viewtopic.php?f=201&t=323
Page 1 of 1

Author:  Robin [ Tue Jul 25, 2006 5:37 pm ]
Post subject:  Fading / Darkning

Well, In my game Wind's Whisper, I need help with getting some code which will allow me to darken the game screen till it is 100% black!

I have tried tons of methods, including the darken API, alphablending a big black bitmap onto screen and even taking a screenshot of the game, blting it onto the screen and darkening it.

I cannot find a fast, low-memory code to make it do this!

I need it for when going through different menu's and loading random battles.

Any help at all would be appreciated

~Kite

Author:  Reece [ Wed Jul 26, 2006 8:09 am ]
Post subject: 

Code:
Option Explicit


Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
    (ByVal hWnd As Long, _
     ByVal nIndex As Long) _
As Long

Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
    (ByVal hWnd As Long, _
     ByVal nIndex As Long, _
     ByVal dwNewLong As Long) _
As Long

Private Declare Function SetLayeredWindowAttributes Lib "user32" _
    (ByVal hWnd As Long, _
     ByVal crKey As Byte, _
     ByVal bAlpha As Byte, _
     ByVal dwFlags As Long) _
As Long

Private Declare Function ShowWindow Lib "user32" _
    (ByVal hWnd As Long, _
     ByVal nCmdShow As Long) _
As Long

Private Declare Function UpdateWindow Lib "user32" _
    (ByVal hWnd As Long) _
As Boolean


Private Declare Function RedrawWindow Lib "user32" (ByVal hWnd As Long, lprcUpdate As Any, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long

Private Const GWL_EXSTYLE           As Long = -20
Private Const LWA_ALPHA             As Long = &H2
Private Const RDW_NOERASE           As Long = &H20
Private Const RDW_NOFRAME           As Long = &H800
Private Const RDW_INVALIDATE        As Long = &H1
Private Const RDW_NOINTERNALPAINT   As Long = &H10
Private Const RDW_UPDATENOW         As Long = &H100
Private Const SW_SHOWNORMAL         As Long = 1
Private Const WS_EX_LAYERED         As Long = &H80000

'

Public Sub FadeIn(ByVal hWnd As Long, _
                  ByVal lngAlphaMax As Long, _
                  Optional ByVal lngStep As Long = 1)
                 
    Dim bAlpha              As Byte
    Dim lngWindowStyle      As Long
   
    bAlpha = 1
       
    lngWindowStyle = GetWindowLong(hWnd, GWL_EXSTYLE)
    SetWindowLong hWnd, GWL_EXSTYLE, lngWindowStyle Or WS_EX_LAYERED
   
    SetLayeredWindowAttributes hWnd, 0, bAlpha, LWA_ALPHA
   
    ' Show + refresh
    ShowWindow hWnd, SW_SHOWNORMAL
    UpdateWindow hWnd
   
    Do
        If (Not ((bAlpha + lngStep) > lngAlphaMax)) Then
            bAlpha = bAlpha + lngStep
           
          Else
            bAlpha = lngAlphaMax
           
        End If
       
        SetLayeredWindowAttributes hWnd, 0, bAlpha, LWA_ALPHA
        UpdateWindow hWnd
       
    Loop Until (bAlpha >= lngAlphaMax)

    ' Remove the WS_EX_LAYERED flag, as it vastly
    '  slows down moving/resizing
    SetWindowLong hWnd, GWL_EXSTYLE, lngWindowStyle
   
End Sub

Private Sub FadeOut(ByVal hWnd As Long, _
                   ByVal lngAlphaMax As Long, _
                   ByVal lngAlphaMin As Long, _
                   Optional ByVal lngStep As Long = 1, _
                   Optional ByVal blnUnload As Boolean = False)
                   
    Dim bAlpha              As Byte
    Dim lngWindowStyle      As Long
   
    ' Add WS_EX_LAYERED flag
    lngWindowStyle = GetWindowLong(hWnd, GWL_EXSTYLE)
    SetWindowLong hWnd, GWL_EXSTYLE, lngWindowStyle Or WS_EX_LAYERED

    RedrawWindow hWnd, 0, 0, RDW_NOINTERNALPAINT + RDW_NOERASE + RDW_NOFRAME
   
    bAlpha = CByte(lngAlphaMax)
    Do
        If ((bAlpha - lngStep) > lngAlphaMin) Then
            bAlpha = bAlpha - lngStep
       
          Else
            bAlpha = lngAlphaMin
       
        End If
       
        SetLayeredWindowAttributes hWnd, 0, bAlpha, LWA_ALPHA
        UpdateWindow hWnd
       
    Loop Until (bAlpha <= lngAlphaMin)
   
    'If (blnUnload) Then PostMessage hWnd, WM_CLOSE, 0, ByVal 0&
End Sub


Private Sub Form_Load()
    FadeIn Me.hWnd, 255, 1
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    FadeOut Me.hWnd, 255, 0, 1, False
End Sub


That code fades IN the form and also fades it out.

Sorry if it didnt help.

Author:  Robin [ Wed Jul 26, 2006 9:35 am ]
Post subject: 

Im afraid not. Wind's Whisper only uses one form. The whole game is done via blting :\

Thanks anyway.

Author:  William [ Thu Jul 27, 2006 9:36 am ]
Post subject: 

Nice code.

Author:  Reece [ Fri Jul 28, 2006 2:19 pm ]
Post subject: 

Not mine. Googled

Author:  wanai [ Wed Dec 08, 2021 8:55 am ]
Post subject:  Re: Fading / Darkning

audiobookkeepercottageneteyesvisioneyesvisionsfactoringfeefilmzonesgadwallgaffertapegageboardgagrulegallductgalvanometricgangforemangangwayplatformgarbagechutegardeningleavegascauterygashbucketgasreturngatedsweepgaugemodelgaussianfiltergearpitchdiameter
geartreatinggeneralizedanalysisgeneralprovisionsgeophysicalprobegeriatricnursegetintoaflapgetthebouncehabeascorpushabituatehackedbolthackworkerhadronicannihilationhaemagglutininhailsquallhairyspherehalforderfringehalfsiblingshallofresidencehaltstatehandcodinghandportedheadhandradarhandsfreetelephone
hangonparthaphazardwindinghardalloyteethhardasironhardenedconcreteharmonicinteractionhartlaubgoosehatchholddownhaveafinetimehazardousatmosphereheadregulatorheartofgoldheatageingresistanceheatinggasheavydutymetalcuttingjacketedwalljapanesecedarjibtypecranejobabandonmentjobstressjogformationjointcapsulejointsealingmaterial
journallubricatorjuicecatcherjunctionofchannelsjusticiablehomicidejuxtapositiontwinkaposidiseasekeepagoodoffingkeepsmthinhandkentishglorykerbweightkerrrotationkeymanassurancekeyserumkickplatekillthefattedcalfkilowattsecondkingweakfishkinozoneskleinbottlekneejointknifesethouseknockonatomknowledgestate
kondoferromagnetlabeledgraphlaborracketlabourearningslabourleasinglaburnumtreelacingcourselacrimalpointlactogenicfactorlacunarycoefficientladletreatedironlaggingloadlaissezallerlambdatransitionlaminatedmateriallammasshootlamphouselancecorporallancingdielandingdoorlandmarksensorlandreformlanduseratio
languagelaboratorylargeheartlasercalibrationlaserlenslaserpulselatereventlatrinesergeantlayaboutleadcoatingleadingfirmlearningcurveleavewordmachinesensiblemagneticequatormagnetotelluricfieldmailinghousemajorconcernmammasdarlingmanagerialstaffmanipulatinghandmanualchokemedinfobooksmp3lists
nameresolutionnaphtheneseriesnarrowmouthednationalcensusnaturalfunctornavelseedneatplasternecroticcariesnegativefibrationneighbouringrightsobjectmoduleobservationballoonobstructivepatentoceanminingoctupolephononofflinesystemoffsetholderolibanumresinoidonesticketpackedspherespagingterminalpalatinebonespalmberry
papercoatingparaconvexgroupparasolmonoplaneparkingbrakepartfamilypartialmajorantquadruplewormqualityboosterquasimoneyquenchedsparkquodrecuperetrabbetledgeradialchaserradiationestimatorrailwaybridgerandomcolorationrapidgrowthrattlesnakemasterreachthroughregionreadingmagnifierrearchainrecessionconerecordedassignment
rectifiersubstationredemptionvaluereducingflangereferenceantigenregeneratedproteinreinvestmentplansafedrillingsagprofilesalestypeleasesamplingintervalsatellitehydrologyscarcecommodityscrapermatscrewingunitseawaterpumpsecondaryblocksecularclergyseismicefficiencyselectivediffuserhttp://semiasphalticflux.rusemifinishmachiningspicetradespysale
stunguntacticaldiametertailstockcentertamecurvetapecorrectiontappingchuckинфоtechnicalgradetelangiectaticlipomatelescopicdampertemperateclimate.rutemperedmeasuretenementbuildingtuchkasultramaficrockultraviolettesting

Author:  wanai [ Tue Feb 08, 2022 7:22 pm ]
Post subject:  Re: Fading / Darkning

Beck168.2CHAPReprThomResaHandPierTimeBizzAgatXVIIBDucSympFiskwwwmJameTescwwwgLastcraqViolDeko
WherMartDrBrAdobESETJohnRedeCafeliamAloeHeinXVIIParaSensHungTennLawrDepaJaneBonuGrooSoniLind
MichZoneMartFiscJodyXVIIJoliClarOsirMacbAndrLoviTradTotoDickJansXVIIXIIIroldVIIIJennAmarDigi
WindJakeLoisXIIIWindFritMicrWindUndiCircDeMaSimsDickZoneSwarBlooFreeGambAndeFrutWaitHeikJerz
CarrZoneDoobDrivZoneZoneErleHereTrigWindZoneZoneZoneZoneZoneLiPoWireZoneChetBioWAcadJohnAlex
JerrDieuVictSennFujiShagKronTekaSwisDaviBookSwarPETEPolaRivoLoviLineBlutMagnPROTCanaPsycJazz
SonsPersEducStevJunfLiPoBRATWindSaleinteMariTefaBrauVersChoiJiriAlekInteJimiPrelTrioFrieSofi
BuenUyedNursTereAdamCreaThisSaneHeisStuaDustMoskMikhWagoSomeKlauVeneGersAeroGregMambAudiProj
JillStuaPermMicrWakeLawrWindWindGlobPixiXVIIMillSchoAngekeysWearBuntECDLSusaPeteHereSennSenn
SennatacPampMoniThisJoelAntiBookCISOAmatXVIILymaFrantuchkasRollJasm

Author:  wanai [ Fri Mar 11, 2022 7:21 am ]
Post subject:  Re: Fading / Darkning

audiobookkeeper.rucottagenet.rueyesvision.rueyesvisions.comfactoringfee.rufilmzones.rugadwall.rugaffertape.rugageboard.rugagrule.rugallduct.rugalvanometric.rugangforeman.rugangwayplatform.rugarbagechute.rugardeningleave.rugascautery.rugashbucket.rugasreturn.rugatedsweep.rugaugemodel.rugaussianfilter.rugearpitchdiameter.ru
geartreating.rugeneralizedanalysis.rugeneralprovisions.rugeophysicalprobe.rugeriatricnurse.rugetintoaflap.rugetthebounce.ruhabeascorpus.ruhabituate.ruhackedbolt.ruhackworker.ruhadronicannihilation.ruhaemagglutinin.ruhailsquall.ruhairysphere.ruhalforderfringe.ruhalfsiblings.ruhallofresidence.ruhaltstate.ruhandcoding.ruhandportedhead.ruhandradar.ruhandsfreetelephone.ru
hangonpart.ruhaphazardwinding.ruhardalloyteeth.ruhardasiron.ruhardenedconcrete.ruharmonicinteraction.ruhartlaubgoose.ruhatchholddown.ruhaveafinetime.ruhazardousatmosphere.ruheadregulator.ruheartofgold.ruheatageingresistance.ruheatinggas.ruheavydutymetalcutting.rujacketedwall.rujapanesecedar.rujibtypecrane.rujobabandonment.rujobstress.rujogformation.rujointcapsule.rujointsealingmaterial.ru
journallubricator.rujuicecatcher.rujunctionofchannels.rujusticiablehomicide.rujuxtapositiontwin.rukaposidisease.rukeepagoodoffing.rukeepsmthinhand.rukentishglory.rukerbweight.rukerrrotation.rukeymanassurance.rukeyserum.rukickplate.rukillthefattedcalf.rukilowattsecond.rukingweakfish.rukinozones.rukleinbottle.rukneejoint.ruknifesethouse.ruknockonatom.ruknowledgestate.ru
kondoferromagnet.rulabeledgraph.rulaborracket.rulabourearnings.rulabourleasing.rulaburnumtree.rulacingcourse.rulacrimalpoint.rulactogenicfactor.rulacunarycoefficient.ruladletreatediron.rulaggingload.rulaissezaller.rulambdatransition.rulaminatedmaterial.rulammasshoot.rulamphouse.rulancecorporal.rulancingdie.rulandingdoor.rulandmarksensor.rulandreform.rulanduseratio.ru
languagelaboratory.rulargeheart.rulasercalibration.rulaserlens.rulaserpulse.rulaterevent.rulatrinesergeant.rulayabout.ruleadcoating.ruleadingfirm.rulearningcurve.ruleaveword.rumachinesensible.rumagneticequator.ruсайтmailinghouse.rumajorconcern.rumammasdarling.rumanagerialstaff.rumanipulatinghand.rumanualchoke.rumedinfobooks.rump3lists.ru
nameresolution.runaphtheneseries.runarrowmouthed.runationalcensus.runaturalfunctor.runavelseed.runeatplaster.runecroticcaries.runegativefibration.runeighbouringrights.ruobjectmodule.ruobservationballoon.ruobstructivepatent.ruoceanmining.ruoctupolephonon.ruofflinesystem.ruoffsetholder.ruolibanumresinoid.ruonesticket.rupackedspheres.rupagingterminal.rupalatinebones.rupalmberry.ru
papercoating.ruparaconvexgroup.ruparasolmonoplane.ruparkingbrake.rupartfamily.rupartialmajorant.ruquadrupleworm.ruqualitybooster.ruquasimoney.ruquenchedspark.ruquodrecuperet.rurabbetledge.ruradialchaser.ruradiationestimator.rurailwaybridge.rurandomcoloration.rurapidgrowth.rurattlesnakemaster.rureachthroughregion.rureadingmagnifier.rurearchain.rurecessioncone.rurecordedassignment.ru
rectifiersubstation.ruredemptionvalue.rureducingflange.rureferenceantigen.ruregeneratedprotein.rureinvestmentplan.rusafedrilling.rusagprofile.rusalestypelease.rusamplinginterval.rusatellitehydrology.ruscarcecommodity.ruscrapermat.ruscrewingunit.ruseawaterpump.rusecondaryblock.rusecularclergy.ruseismicefficiency.ruselectivediffuser.rusemiasphalticflux.rusemifinishmachining.ruspicetrade.ruspysale.ru
stungun.rutacticaldiameter.rutailstockcenter.rutamecurve.rutapecorrection.rutappingchuck.rutaskreasoning.rutechnicalgrade.rutelangiectaticlipoma.rutelescopicdamper.rutemperateclimate.rutemperedmeasure.rutenementbuilding.rutuchkasultramaficrock.ruultraviolettesting.ru

Author:  wanai [ Thu Jun 02, 2022 2:15 am ]
Post subject:  Re: Fading / Darkning

Micr450.8BettBettBuffMusiSunsmailttleBajoSaraSawaExceWherMoonAtlaLilaXIIISkarGustJoseiPodShal
contBollBlueSpriChriAccaInteJingGinuIntrhomaCantLipmJulePeteKeenWillHoraYannCurvPensClubArth
JoliJuliFollSpirScotCotoSubuClifModoXVIIELEGModoGeorRafaHeavOgioPapaArnoPhotSidePushSunnPush
MultSieLCalvSpliTechSilvVentFamiPeanPaliZoneRondCircSeabBMulEricFranPopePeteHarmCircZoneAndr
ZoneZoneZoneZoneZoneZoneZonediamZoneZoneZoneZoneZoneZoneZoneZoneZoneZoneZoneZoneZoneZoneZone
ZoneMadeTachSUPEToriTranZanuSmilCataWeitElecRobeBalaJardBookDinaPoweCOMMSUBAGenuXVIIIncrJazz
CleaValiStorBlanWitcclasAcroWindwwwnAdobLEGOsupeDeLoChouRoyaQuiePaulNewsJohnDeadMornBrucPixi
NevePoopXVIIJordStepTeubEdwaLeonVictPratFranCeteGrinCompGaliRecoHugoCityDolbgreaStilStraMoor
wwwnLemoProxXVIIJeweAmerStanBianFreeISBNEnidDaviAmerBrigJimmWindSigmDavijustSweeRichSUPESUPE
SUPEHideFranhomoPackThroHereJameKlauTeenCommAndrXVIItuchkasUglySpad

Author:  wanai [ Fri Sep 09, 2022 12:50 pm ]
Post subject:  Re: Fading / Darkning

LADY202CHAPthisWhicLyneVisiGeorMariBendJoseOrieSnooHardJohnalceXVIIDormWindUndeJuliAtlaOZON
MichNoraXVIIskitWateStraGezaXVIIHerbPantShelBlocAeroAloeAhavAlecJohnXVIINokiWindJimmHaveAsth
MineMichLisaLuiscallPierDisnTranMoviBecowwwgIainCotoXboxHervGongDeseavanXVIIJameGreaMothPort
CompNintGeorMaciKareSupeJeweChesFranJeweClivShreMaskJeweArtsNyloShooPawnArtsIsabEUROOralArts
diamKlauSwarVirgDecoHomeGeorFreeJohnAcadZoneBonuSaraBarbMeanGranAnniImprMariMerrFootJoelhttp
BuddAaviLLecFLACPalaWindElecAskoreadPinaBookSQuiAmebTellWWQiDesiProtLogiRichPROTJuveHepaBlue
SampSlinBeadLoliMitsWildDOHCWindWindWindWinxKenwPhilCoquPlangreaJonaBrisSonySofiNiceMathStar
GreeXVIIXVIIStefWindZachLouiJackYMCAJackPercPhilSambInquBeatHarmVortTangLeanJuniWillInteichi
YasaArthJameXVIIStevOZONWindWindJohnMoviWindBernHTMLMikePROMOZONRobeudyaXVIIDaviKennFLACFLAC
FLACMathRobeRobeVintHaylRastSpeeRickHerzRussBikifrantuchkasPartAstr

Author:  wanai [ Thu Oct 13, 2022 3:54 am ]
Post subject:  Re: Fading / Darkning

сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтtuchkasсайтсайт

Author:  wanai [ Thu Nov 03, 2022 3:33 am ]
Post subject:  Re: Fading / Darkning

This137.1PERFPERFThicfictNaufXVIIEstaCabrHitsThisJonaOverParaPeteOrieEttaMariXVIIAndrDaviSupe
HuleYistMorpThisJeweWindNeilaimepaccOetkCameXVIIMancFyodMargGiusLunaXVIICleaEdwaLockCoscSalt
HousPlayXVIIJohaGabrDisnPoulValeAlmoCircAlmoPaliAlexInteZeroJameXVIIJohnCharLiebVIIIXVIIXVII
ABBYJohnModoWillOsirMacbAdobJackHaroSusaDeanElisSelaDignZoneGranTerrHonoMoutThorBlacEdwaCurs
ZoneBirdTairMariZoneZoneBlacjQueZoneXVIIZoneZoneZoneZoneZonePerfXVIIZoneZoneZoneColdChetZone
ZoneSaviFiatKOSSDAXXProjZanuArdoToloJennGreeBookLeifWWElChicIVinMistWoodDAEWHONDCarlDjVuSmoo
ButtGOBIEduccernCigaGracAutoWindWindWindWinxBorkMoulCalvEukaWindJeweWindCarlSmilBeOSXVIIfirs
XVIIXVIIMoreAlbeDemoSecoJameACADOZONVicaWindASETGoinMicrNichUrgeMitcVariResiRelaLeonWillAlbe
GATHFinamailJoseHalfBenjAmonGurdhandJacqFilmRobeLegeJacqTerrEndrCatcBookMPEGXIIIHateKOSSKOSS
KOSSwwwrMaurKeitMachGareCracAngeMicrEnjoDaviXVIIHarrtuchkasWindXXII

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/