Use cCJCommandBarSystem.pkg Use Wingdi.pkg Use LanguageText.pkg // User interface constant strings: #IFSAME Language$Current Language$English Define CS_NoSkinShort for "-None" Define CS_NoSkinLong for "Do not use a skin" #ENDIF #IFSAME Language$Current Language$Svenska Define CS_NoSkinShort for "-None" Define CS_NoSkinLong for "Do not use a skin" #ENDIF #IFSAME Language$Current Language$Nederlands Define CS_NoSkinShort for "-None" Define CS_NoSkinLong for "Do not use a skin" #ENDIF #IFSAME Language$Current Language$Deutsch Define CS_NoSkinShort for "-None" Define CS_NoSkinLong for "Do not use a skin" #ENDIF #IFSAME Language$Current Language$Dansk Define CS_NoSkinShort for "-None" Define CS_NoSkinLong for "Do not use a skin" #ENDIF #IFSAME Language$Current Language$Portugues Define CS_NoSkinShort for "-None" Define CS_NoSkinLong for "Do not use a skin" #ENDIF #IFSAME Language$Current Language$Francais Define CS_NoSkinShort for "-None" Define CS_NoSkinLong for "Do not use a skin" #ENDIF #IFSAME Language$Current Language$Italiano Define CS_NoSkinShort for "-None" Define CS_NoSkinLong for "Do not use a skin" #ENDIF #IFSAME Language$Current Language$Espanol Define CS_NoSkinShort for "-None" Define CS_NoSkinLong for "Do not use a skin" #ENDIF #IFSAME Language$Current Language$Norsk Define CS_NoSkinShort for "-None" Define CS_NoSkinLong for "Do not use a skin" #ENDIF Class cSkinComboBoxCJMenuItem is a cCJMenuItem Procedure Construct_Object Forward Send Construct_Object Set peControlType to xtpControlComboBox Property tSkinInformation[] pSkins End_Procedure Procedure End_Construct_Object Forward Send End_Construct_Object End_Procedure // Custom array sort for the tSkinInformation struct array. // Used by LoadSkins message to sort the skin array alphabetically after it has been loaded. // Why? // First of all, structs can't be used with the standard SortArray function, that is why we need to // create a custom sort algorithm. // Secondly the list of skins would else be sorted in the alphabetical order by the file names. // However, it is not always the case that the skin description (sName) is the same as the file name. // If it isn't (which is almost always the case if you have many skin files) the list will look // randomly ordered. This custom sort method will take care of that. Function SkinSort tSkinInformation sDescription tSkinInformation sSearchDescription Returns Integer If ((sDescription.sName * sDescription.sSkinIni) > (sSearchDescription.sName * sSearchDescription.sSkinIni)) Begin Function_Return (GT) End If ((sDescription.sName * sDescription.sSkinIni) < (sSearchDescription.sName * sSearchDescription.sSkinIni)) Begin Function_Return (LT) End Function_Return (EQ) End_Function Procedure OnCreateControl Handle hoObj Forward Send OnCreateControl hoObj Send LoadSkins Send FillComboList hoObj End_Procedure // Load all skins. We will only look for skins in expected // directory which is the Programs folder. // Important: When loading skins they will be sorted alphabetically. (See Skinsort function above). // This is not the case with the 'standard' VDF behaviour. Procedure LoadSkins Integer iCount iItems iSize Boolean bFound String sFile sIni sSkin tSkinInformation[] SkinsArray SkinsArrayNoLarge tSkinInformation NoneRow If (ghoSkinFramework > 0) Begin Get EnumerateSkins of ghoSkinFramework "" True to SkinsArray Move (SortArray(SkinsArray, Self, get_SkinSort)) to SkinsArray Move CS_NoSkinShort to NoneRow.sName Move CS_NoSkinLong to NoneRow.sSkinfile Move CS_NoSkinLong to NoneRow.sSkinIni Move (InsertInArray(SkinsArray, 0, NoneRow)) to SkinsArray // Get the currently loaded skin. Get psSkinFile of ghoSkinFramework to sFile Get psSkinIni of ghoSkinFramework to sIni // Remove all Extra Large and Large skins from the array. Move (SizeOfArray(SkinsArray)) to iItems Decrement iItems For iCount from 0 to iItems Move SkinsArray[iCount].sSkinIni to sSkin Move (Uppercase(sSkin) contains " LARGE") to bFound If (bFound = False) Begin Move (SizeOfArray(SkinsArrayNoLarge)) to iSize Move SkinsArray[iCount].sName to SkinsArrayNoLarge[iSize].sName Move SkinsArray[iCount].sSkinfile to SkinsArrayNoLarge[iSize].sSkinfile Move SkinsArray[iCount].sSkinIni to SkinsArrayNoLarge[iSize].sSkinIni End Loop Set pSkins to SkinsArrayNoLarge End End_Procedure // Fills the CodeJock combobox with all skins from the current Programs folder. Procedure FillComboList Handle hoCombo Integer iCount iItems iCurrent iTxtEntentSize String sFile sIni sCurrSkin String sSkin sSkinText tSkinInformation[] SkinsArray Integer iSize If (ghoSkinFramework < 1) Begin Procedure_Return End // Get the currently loaded skin. Get psSkinFile of ghoSkinFramework to sFile Get psSkinIni of ghoSkinFramework to sIni Get pSkins to SkinsArray Move (SizeOfArray(SkinsArray)) to iItems Decrement iItems Send ComClear of hoCombo For iCount from 0 to iItems Move SkinsArray[iCount].sSkinIni to sSkin Move (Replace(".ini", sSkin, "")) to sSkin Move (SkinsArray[iCount].sName * "-" * sSkin) to sSkinText Send ComAddItem of hoCombo sSkinText (iCount +1) Get Text_Extent sSkinText to iSize If (iSize > iTxtEntentSize) Begin Move iSize to iTxtEntentSize End Move (SkinsArray[iCount].sSkinFile * "-" * SkinsArray[iCount].sSkinIni) to sCurrSkin If (sCurrSkin = (sFile * "-" * sIni)) Begin Move iCount to iCurrent End Loop Move (Low(iTxtEntentSize) + 30) to iSize Set ComDropDownWidth of hoCombo to iSize Set ComWidth of hoCombo to (iSize + 100) Set ComListIndex of hoCombo to (iCurrent +1) End_Procedure // Event for when an item is selected from the comboform Procedure OnExecute Variant vCommandBarControl Handle hoCombo Integer iSelection String sSkinFile sSkinIni tSkinInformation[] SkinsArray // Create and bind proxy control Get CreateProxyControl vCommandBarControl to hoCombo // Get the current selection Get ComListIndex of hoCombo to iSelection Decrement iSelection Get pSkins to SkinsArray Move SkinsArray[iSelection].sSkinfile to sSkinFile Move SkinsArray[iSelection].sSkinIni to sSkinIni Send DoChangeSkin sSkinFile sSkinIni // Dispose of the proxy control Send Destroy of hoCombo End_Procedure // Send this message to change the current skin. Procedure DoChangeSkin String sSkinFile String sSkinIni Handle hoClient Set psSkinFile of ghoSkinFramework to sSkinFile Set psSkinIni of ghoSkinFramework to sSkinIni Send ApplySkin of ghoSkinFramework // Note: The following line is essential for the resizing logic // to function properly when changing a skin and a view is maximized. Move (Client_Id(phoMainPanel(ghoApplication))) to hoClient Set Size of hoClient to (Hi(Size(hoClient))) (Low(Size(hoClient) +2)) Set Size of hoClient to (Hi(Size(hoClient))) (Low(Size(hoClient) -2)) End_Procedure // Returns: DPI setting as an integer. // Normal DPI setting: iDPI=96 is "Normal setting" 100% // iDPI=120 is "Medium setting" 125% // iDPI= 144 is "Large setting" 150% Function GetCurrentDPI Returns Integer Handle hDC Integer iPixelsX Move (GetDC(0)) to hDC Move (GetDeviceCaps(hDC, LOGPIXELSX)) to iPixelsX Move (ReleaseDC(0, hDC)) to hDC Function_Return iPixelsX End_Function End_Class