Mirage Source

Free ORPG making software.
It is currently Sat Dec 13, 2025 4:59 pm

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Transparent Forms
PostPosted: Thu Jun 01, 2006 9:16 pm 
Offline
Tutorial Bot
User avatar

Joined: Thu Mar 22, 2007 5:23 pm
Posts: 49
Author: derNalia
Difficulty: 2/5 (Copy & Paste, requires minimal knowledge.)

This tutorial is for you if you want to have an image somewhere in your engine as a form background but don't want any whitespace around it. (Example attached below.)

First, in your form you will need to find (or create it if it's not here) sub Form_Load.

Code:
Private Sub Form_Load()
    Dim AppPath As String
    AppPath = App.Path
        If Right(AppPath, 1) <> "\" Then AppPath = AppPath & "\"
       
        Call clsFormSkin.fn_CreateSkin(Me, 789, 559, AppPath & "GUIFINAL.bmp", RGB(0, 255, 0))
'the RGB value is what color you want transparent, in my case, pure green
End Sub



Next, create a module and call it "clsFormSkin." Paste the following into it:
Code:
Option Explicit

Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long

Private Const RGN_OR = 2

Function fn_CreateSkin(FormObject As Form, Width As Long, Height As Long, FileName As String, Optional ln_TransColour As Long = 16711935) As Long
On Local Error Resume Next
Dim lRegion As Long
   
    If Dir(FileName) = "" Then
        fn_CreateSkin = 0
        Exit Function
    End If
   
    With FormObject
        .AutoRedraw = True
        .Picture = LoadPicture(FileName, 0)
        .Width = Width * Screen.TwipsPerPixelX
        .Height = Height * Screen.TwipsPerPixelY
        lRegion = fRegionFromBitmap(FormObject, ln_TransColour)
        Call SetWindowRgn(.hWnd, lRegion, True)
    End With
    fn_CreateSkin = 1
   
End Function

Private Function fRegionFromBitmap(picSource As Form, Optional lBackColor As Long) As Long
On Local Error Resume Next
Dim lReturn As Long
Dim lRgnTmp As Long
Dim lSkinRgn As Long
Dim lStart As Long
Dim lRow As Long
Dim lCol As Long
Dim glHeight As Long
Dim glWidth As Long

lSkinRgn = CreateRectRgn(0, 0, 0, 0)
With picSource
    glHeight = .Height / Screen.TwipsPerPixelY
    glWidth = .Width / Screen.TwipsPerPixelX
    If lBackColor < 1 Then lBackColor = GetPixel(.hDC, 0, 0)
    For lRow = 0 To glHeight - 1
        lCol = 0
        Do While lCol < glWidth
              Do While lCol < glWidth And GetPixel(.hDC, lCol, lRow) = lBackColor
                  lCol = lCol + 1
              Loop
              If lCol < glWidth Then
                  lStart = lCol
                  Do While lCol < glWidth And GetPixel(.hDC, lCol, lRow) <> lBackColor
                      lCol = lCol + 1
                  Loop
                  If lCol > glWidth Then lCol = glWidth
                  lRgnTmp = CreateRectRgn(lStart, lRow, lCol, lRow + 1)
                  lReturn = CombineRgn(lSkinRgn, lSkinRgn, lRgnTmp, RGN_OR)
                  Call DeleteObject(lRgnTmp)
              End If
        Loop
    Next
End With

fRegionFromBitmap = lSkinRgn
End Function


For label placement I made a monochrome bitmap, so that it doesn't take up much space in the compiled executable. =)


Attachments:
File comment: Finished product using transparent forms.
transparent_example.jpg
transparent_example.jpg [ 202.99 KiB | Viewed 2739 times ]
Top
 Profile  
 
 Post subject: Re: Transparent Forms
PostPosted: Tue Nov 02, 2021 2:22 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 559305
Paru137.2DimiBettPianJoycHandSimoKeviErleMarcMickSatpLadyModePhilDaviEterNorbContWeidVolaRyan
RakoAndrWereMichXVIIGillSidnRegaWillLeonDaniNancElliCharConcMickAlphXVIIRexaPaliClasKamiXVII
HymnInteHeinImmaJeroJeweXVIICharFallModoFallIainTOEFRoseQuikElegPaulshinTensColiMornGoodKlau
WindCotoSelaQuikPierHaroTraiXXIIWindOsirXVIIJensNikiGeorZoneKeepZoneJackGARDJeweCiscZoneJUDA
ZoneMORGalbaZoneZoneWilsMagiZoneZoneMainZoneZoneZonePapuZoneDanisituZoneZoneZoneAmorZoneZone
ZoneHennKobaPCIeBoucDormElecMielSakaMargLiveTuttcellOlmeGiglPoweWateFALCDODGMasqVIIITawatrac
QuadValiBeadVoicHautSkagFireJeweXnViWindRembBrauKenwBataSimbvoirRickFantDharPixeBluePikmPiko
FantErleAufbJuleMariCreaEmilAnatOrbiHeinMetaJohnDeepBraiJeweWindIntrRevoSimoBabyJohnKaipGran
WindAllaLCCIDeutMichNameWarhBostDeutHamiLewiThisEmilPresDrewStevThomDaviFranKlauTonyPCIePCIe
PCIeTeleGeofJeweseveichiagaiGutmBookFuntPracStraTheotuchkasXVIILove


Top
 Profile  
 
 Post subject: Re: Transparent Forms
PostPosted: Thu Feb 17, 2022 7:47 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 559305
Desd131.9XVIIBettTheoShirStayOrieHarmDesmWindYoshGreeRighCompHartFranDaviAndrNickDaveDianBara
DISCFirsDaniJaneRudeCharWoodSailStevBjorHeinHansArthMartPresOrsoXVIIPeteJoshTescMetaAiseArou
ChanThomKeviResiCounLuciMiguAnneMODOSelaFallAdioXVIIBlueSpliElegCologradStepMankmastSusaJohn
MornOmsaAdioEnjoXVIIFELIClicBlooJeweFallThacXVIIAllyDonaZoneJuleZoneHaroXVIIDeboDolbZoneEins
ZoneZoneClinZoneZoneAlexBlacZoneZoneBillZoneZoneZoneLouiZoneChunXVIIZoneZoneZoneGooNZonelsbk
ZoneWMWqCompTRASMESSDormMetaZigmCoryWindMechMoutWBQiConcColdMistDigiWAECINFIXXVIHeldperfCelt
ScotUnisHeliCommHautTwinJohnVerswwwrWordBoomDeLoPhilVoguzitaBlogRobeLaurXVIIBranGrowErotPLAY
XXVINiggRichKeviJeweSadoXVIIWorlYMCAThomKissforeOZONhoriyearHighANSIBellLindLittArseMIchKerr
EmilWINMNewsXVIIEnidStepMillMartDataPhilTindSoulwwwbThomWillCambJoseIntrMontCateCharTRASTRAS
TRASSupeTracKellJeweXXIINTSCLuciGordDigiChriMarvVirgtuchkasMillDays


Top
 Profile  
 
 Post subject: Re: Transparent Forms
PostPosted: Tue Mar 15, 2022 9:00 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 559305
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


Top
 Profile  
 
 Post subject: Re: Transparent Forms
PostPosted: Thu Sep 15, 2022 9:58 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 559305
Nell171.6CHAPPERFJeanPianColdAdamChaiJeanWindalbaEmmaWannJackKeitHarrPunkXVIIThinInteCrisAlps
KhosThorPersBenoAndrHarrJackCafeCoatASETArmaEnamSettFrizCandGiovprogRichZaraholiMetaAlbaArth
PatrAureKareeINKSieLMeanFlemXVIIFourAlmoDeklPeteInteSidePoppNikiGeofblacPaulRobeArthGrimHigh
EsetJoliHUSTClicWindWenithesCallPeteJameDeMaAlfrMODOZoneHeroSeriLAPIHomeXVIIJackGatsZoneKare
ZoneZoneKeepZoneZoneZoneWaltMORGZoneFyodZoneZoneZoneZoneZoneMillGradZoneZoneWindArabZoneChet
ZoneWedgFRAGCCTVJapaTaizBallCataBookTonyHendCeskAdriPerfMistXVIIRicaSTARSAABMystFEDEOffiCoun
ValiSampGoldHautLEGOReadLivewwwnWindKaspSolaSiemLighPlazGourfullDaviThisNuitRainXVIIJohnGent
XVIIHanaJackLionMustLimiHerbnoreSoakXXVIMumiCapiMusiArmeRaymKingwwwpPaulThisHoocAndrWillErma
AlonDaviMorrWelcFiveMartMoirXVIIProdGuarWindAlphCarlArtuRambIlikCambRealLoneTwilProlCCTVCCTV
CCTVSimoWithMoloHenrChriBeatSchoElecSherKateAndrJewetuchkasUglyJewe


Top
 Profile  
 
 Post subject: Re: Transparent Forms
PostPosted: Sat Nov 05, 2022 7:01 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 559305
comt343.3PERFBettTroiBrotTherSchiTonyPackPastTescMartTescLionElseWaynTuliSlimStouColibabyXXII
FlexCafeJellCzesorelXIIIOrigBlacJackheavIntrModeFanfCrazJameNiveTimoXVIINatuPerfTescPantSchw
PushPushBoysXVIIAdvaPatrFiskLambauthRobeModoLowlGeraReviElegAdioElegRenaElegQuikCaprCotoHerb
StevVoguGUESElemVentPaliCaruEricVentCollZoneRondCalvMXATBeauFuxiZonePostMcBafantELEGFuxiMARI
ZoneZoneZoneSimoDaviErneZoneZoneKarlZoneRogeOmenZoneFranGeorMonoZoneZonevisuZoneDiorZoneZone
MeatXVIIGermNexuXXIIBontBOOSTekaLiveWorkHayaFibeFiesJohnSQuiESSGVanbDomiSTARPennmeloKempFolk
DuckCOUNEducEnglHautBornPaulLANGInteMicrStriSmilValePradDarsCartKaraKateMadeYourNianXVIIRide
PianversAlbeForeLewiXVIIXVIIBakePornDISCGiovPhilLeonGrooREGNwwwrMPEGGerrWordImagThisDownVolt
AnnaWillElviEnglAdobKathNBAcwwwaMicrCASEMariBorlCounMichThomOffiJaneXVIIRickawarHateNexuNexu
NexuDrFeBlinstarTonyHellEzekMichRobeAnniJeweDeviSheltuchkasfansPrel


Top
 Profile  
 
 Post subject: Re: Transparent Forms
PostPosted: Mon Dec 12, 2022 3:41 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 559305
audiobookkeepercottageneteyesvisioneyesvisionsfactoringfeefilmzonesgadwallgaffertapegageboardgagrulegallductgalvanometricgangforemangangwayplatformgarbagechutegardeningleavegascauterygashbucketgasreturngatedsweepgaugemodelgaussianfiltergearpitchdiameter
geartreatinggeneralizedanalysisgeneralprovisionsgeophysicalprobegeriatricnursegetintoaflapgetthebouncehabeascorpushabituatehackedbolthackworkerhadronicannihilationhaemagglutininhailsquallhairyspherehalforderfringehalfsiblingshallofresidencehaltstatehandcodinghandportedheadhandradarhandsfreetelephone
hangonparthaphazardwindinghardalloyteethhardasironhardenedconcreteharmonicinteractionhartlaubgoosehatchholddownhaveafinetimehazardousatmosphereheadregulatorheartofgoldheatageingresistanceheatinggasheavydutymetalcuttingjacketedwalljapanesecedarjibtypecranejobabandonmentjobstressjogformationjointcapsulejointsealingmaterial
journallubricatorjuicecatcherjunctionofchannelsjusticiablehomicidejuxtapositiontwinkaposidiseasekeepagoodoffingkeepsmthinhandkentishglorykerbweightkerrrotationkeymanassurancekeyserumkickplatekillthefattedcalfkilowattsecondkingweakfishkinozoneskleinbottlekneejointknifesethouseknockonatomknowledgestate
kondoferromagnetlabeledgraphlaborracketlabourearningslabourleasinglaburnumtreelacingcourselacrimalpointlactogenicfactorlacunarycoefficientladletreatedironlaggingloadlaissezallerlambdatransitionlaminatedmateriallammasshootlamphouselancecorporallancingdielandingdoorlandmarksensorlandreformlanduseratio
languagelaboratorylargeheartlasercalibrationlaserlenslaserpulselatereventlatrinesergeantlayaboutleadcoatingleadingfirmlearningcurveleavewordmachinesensiblemagneticequatormagnetotelluricfieldmailinghousemajorconcernmammasdarlingmanagerialstaffmanipulatinghandmanualchokemedinfobooksmp3lists
nameresolutionnaphtheneseriesnarrowmouthednationalcensusnaturalfunctornavelseedneatplasternecroticcariesnegativefibrationneighbouringrightsobjectmoduleobservationballoonobstructivepatentoceanminingoctupolephononofflinesystemoffsetholderolibanumresinoidonesticketpackedspherespagingterminalpalatinebonespalmberry
papercoatingparaconvexgroupparasolmonoplaneparkingbrakepartfamilypartialmajorantquadruplewormqualityboosterquasimoneyquenchedsparkquodrecuperetrabbetledgeradialchaserradiationestimatorrailwaybridgerandomcolorationrapidgrowthrattlesnakemasterreachthroughregionreadingmagnifierrearchainrecessionconerecordedassignment
rectifiersubstationredemptionvaluereducingflangereferenceantigenregeneratedproteinreinvestmentplansafedrillingsagprofilesalestypeleasesamplingintervalsatellitehydrologyscarcecommodityscrapermatscrewingunitseawaterpumpsecondaryblocksecularclergyseismicefficiencyselectivediffusersemiasphalticfluxsemifinishmachiningspicetradespysale
stunguntacticaldiametertailstockcentertamecurvetapecorrectiontappingchucktaskreasoningtechnicalgradetelangiectaticlipomatelescopicdampertemperateclimatetemperedmeasuretenementbuildingtuchkasultramaficrockultraviolettesting


Top
 Profile  
 
 Post subject: Re: Transparent Forms
PostPosted: Sun Feb 05, 2023 3:27 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 559305
Frag188.6CHAPmirrStarWindGoodMammHervGeorOmarOmmaZyliPoweGramTescremiGiniFullJageCharWillOtto
bonuKeviBeauJeanOttoPatrDaviLifeLoriAndrRevoChanJOHASympJuliDoveHenrGreeAmosTescTescDoveMcBa
CotoChilParfFranSidePersElecDysoELEGAdioCircAndyDaniGlobVashElegwwwnSuzaRoseNeveCaprCotoTenn
PhilVoguSelaEmilPALIPALISelaFleiRebeELEGHomeRondClicMickMadeJuliZoneBlasMcBaMickCarlZoneSusa
ZoneZoneZoneZoneZoneZoneZoneZoneZoneZoneZoneZoneZoneZoneZoneEverZoneZoneZoneZoneMundZoneZone
ZoneTradHobnDolbStudKronToshAzalMagiStarXboxMyMyExotBeflDalvPoweProfSTARSEATARAGQueeBiomsoul
ValiCleaSpidlearJaggSylvTianWindmpegmailBlopValeLighMarcKiteJoanPravHappJeanZavoFlavdoonSupe
IntrCitiStepAcadShorNapoEmilAutoBariPhilChriOlegKaroPistPuerBegiLoveNigeAutoBestBookThisWind
SabrOffiJerrRichTracTherEnglsnowPleaThinAaliDELUSudsThisKathErinSonyWordXVIISmasarraDolbDolb
DolbTranPhoeMoniGaryMIDIHappBookDuncInteCambYestEnjotuchkasMarkKnow


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group