Jump to content

BasicTrans 4.5


Iuli
 Share

Recommended Posts

Hi,

I just created a new application for Windows Home Basic operating system users that like the AeroGlass effect. Practically, it just patches the theme so it will force AeroGlass to run, even if Windows does not officially support this. I'm ataching the compiled exe and the source also, since there is very easy to create such an app.

Screenshot

Posted Image

Download

iSoft-Online.com Download

Source

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=C:\Users\Administrator\Desktop\512 blank.ico
#AutoIt3Wrapper_outfile=BasicTrans.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Description=BasicTrans - AeroGlass on your Home Basic OS.
#AutoIt3Wrapper_Res_Fileversion=4.5.0.0
#AutoIt3Wrapper_Res_LegalCopyright=(c) 2009 iSoft-Online.com
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <GDIPlus.au3>
#include <GuiComboBox.au3>
#include <File.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
#include "hover.au3"
Opt("MustDeclareVars", 0)

Global Const $AC_SRC_ALPHA = 1
Global $GFX_BK_IMAGE=@ScriptDir & "\gfx\bk.bmp"
Global $GFX_APPLY=@ScriptDir & "\gfx\apply_patch.bmp"
Global $GFX_APPLY_OVER=@ScriptDir & "\gfx\apply_patch_over.bmp"
Global $GFX_GREY=@ScriptDir & "\gfx\grey.gif"


; Load PNG file as GDI bitmap
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($GFX_BK_IMAGE)
$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)

; Create layered window
$GUI = GUICreate("BasicTrans", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
SetBitmap($GUI, $hImage, 0)
_GuiRoundCorners ($GUI, Default, 0, 20, 20, 1)
; Register notification messages
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState()
;fade in png background
For $i = 0 To 255 Step 15
    SetBitmap($GUI, $hImage, $i)
Next


$controlGui = GUICreate("ControlGUI", $width, $height, 0,0,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$GUI)

GUICtrlCreatePic($GFX_GREY,0,0,$width,$height)
GuiCtrlSetState(-1,$GUI_DISABLE)
$apply=GUICtrlCreatePic($GFX_APPLY,180,125,105,123)
GuiCtrlSetOnHover(-1,"Hover_Func","Leave_Hover_Func")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            For $i = 255 To 0 Step -15
                SetBitmap($GUI, $hImage, $i)
            Next
            ExitLoop
        case $msg=$apply
            $file=FileOpenDialog("Open the *.msstyles file for patching",""," MSStyles (*.msstyles)")
            If @error<>1 Then
                If _ApplyAeroPatch($file)=0 Then
                    MsgBox(0,"Error !","Error while patching. The file may be already patched.")
                Else
                    MsgBox(0,"Done !","File has been sucessfully patched. Please re-apply the theme.")
                EndIf   
            EndIf   
    EndSelect
WEnd

Exit

Func _ApplyAeroPatch ($sFile)
    
    $hFile=FileOpen($sFile,16)
    $sHexFile=Hex(FileRead($hFile))
    FileClose($hFile)
    
    If StringInStr($sHexFile,"DFDFDFFF") Then
        $sHexFile=StringReplace($sHexFile,"DFDFDFFF","00000000") ; this is where magic happens people :P
    Else
        ;MsgBox(0,"Error !","Error while patching. The file may be already patched.")
        SetError(1,0,1)
        Return 0
    EndIf   
    
    $hWriteFile=FileOpen($sFile,2)
    FileWrite($hWriteFile,Binary("0x" & $sHexFile))
    FileClose($hWriteFile)
    
    Return 1
EndFunc 





Func Hover_Func($CtrlID)
    Switch $CtrlID
        Case $apply
            GUICtrlSetImage($CtrlID, $GFX_APPLY_OVER)
    EndSwitch
EndFunc

Func Leave_Hover_Func($CtrlID)
    Switch $CtrlID
        Case $apply
            GUICtrlSetImage($CtrlID, $GFX_APPLY)
    EndSwitch
EndFunc

Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3, $BotCrnrs = True); thanks gafrost
    Local $XS_pos, $XS_ret, $XS_ret2
    $XS_pos = WinGetPos($h_win)
    If Not $BotCrnrs Then $ret2 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", _
                $i_x1, "long", $XS_pos[3]-$i_y3, "long", $XS_pos[2]-1, "long", $XS_pos[3])  
    $XS_ret = DllCall("gdi32.dll",  "long", "CreateRoundRectRgn", _
                                    "long", $i_x1, _
                                    "long", $i_y1, _
                                    "long", $XS_pos[2], _
                                    "long", $XS_pos[3], _
                                    "long", $i_x3, _
                                    "long", $i_y3)
    If Not $BotCrnrs Then DllCall("gdi32.dll", "long", "CombineRgn", "long", $XS_ret[0], "long", $XS_ret[0], _
                                                             "long", $ret2[0], "int", 2)
    If $XS_ret[0] Then
        $XS_ret = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $XS_ret[0], "int", 1)
    EndIf
EndFunc   ;==>_GuiRoundCorners


; ====================================================================================================

; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ====================================================================================================

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST

; ====================================================================================================

; SetBitMap
; ====================================================================================================

Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>SetBitmap

Waiting for comments, criticism and suggestions :)

Edited by Iuli
[size="2"]SFXMaker[/size] - The most complete switchless installer creator software[indent][/indent]
Link to comment
Share on other sites

@Mat

I'm assuming absolutely NOT. While DFDFDFFF may be a unique byte sequence in that file, I highly doubt that 00000000 is unique at all. You will likely kill your theme file if you do this. You'd have to find and save the offset of the patch string replacement in order to do a proper patch removal.

Link to comment
Share on other sites

Before I run it... I don't see an undo function anywhere... I presume you can just switch the "$sHexFile=StringReplace($sHexFile,"DFDFDFFF","00000000")" round??

Mat

No, as wraithdu said, "00000000" is not an unique identification string, as "DFDFDFFF" is. However, i will add support for undoing this in the next version.

[size="2"]SFXMaker[/size] - The most complete switchless installer creator software[indent][/indent]
Link to comment
Share on other sites

Maybe you should create a copy of the msstyles-file you want to modify :)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Is it same like uxtheme multi-patch?

No, it does not patch uxtheme.dll, but a theme to force AeroGlass.

[size="2"]SFXMaker[/size] - The most complete switchless installer creator software[indent][/indent]
Link to comment
Share on other sites

I will work only on Windows Vista and Windows 7. Officially, Home Basic OS does not support AeroGlass, but this patch will force the theme to load AeroGlass.

Edited by Iuli
[size="2"]SFXMaker[/size] - The most complete switchless installer creator software[indent][/indent]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...