PDA

Click to See Complete Forum and Search --> : Replace Splash Screen Image


PaulLewis
Sep 20th, 2000, 10:42 PM
There is no doubt a way to do what you are trying to do, but in the meantime, here is an all-vb method for you.

To Test:
On a Form with a picturebox and a command button, add the following code.

1) Edit the code to point to an image file you want to use
2) Compile the code and note the exe byte size.
3) Edit the code and change the offset value in the SaveSpashImage Sub
4) Compile the code again
5) Copy the exe to another name like Tester.exe
6) Run Tester.exe and hit the append button.
7) Run Project1 and observe your splash image is present when the form loads.


Option Explicit


Private Sub SaveSplashImage()
Dim f, offset As Long
Dim picFile, exeFile As String
' this is the file to use as the splash image
picFile = "d:\!dev\bitmaps\snslogo-sm.jpg"

' this is the exe file you already have
exeFile = "d:\!dev\vb-world\SaveSplashImage\Project1.exe"

' this is the known length of the exe file
offset = 20480
'offset = 24576

' dim an array of bytes that will hold the image
ReDim bytes(FileLen(picFile)) As Byte


f = FreeFile
Open picFile For Binary As #f
' read the image
Get #f, , bytes
Close #f

f = FreeFile
Open exeFile For Binary As #f
' write the image
Put #f, offset, bytes
Close #f

End Sub
Private Sub GetSplashImage()
Dim f, offset As Long
Dim picFile, exeFile As String
' this is a temporary file
picFile = "c:\tmp.jpg"

' this is the exe that is running
exeFile = App.Path & "\" & App.EXEName & ".exe"

' this is the known length of the exe
offset = 20480

' byte array to store the image
ReDim bytes(FileLen(exeFile) - offset) As Byte

f = FreeFile
Open exeFile For Binary As #f
' read the image
Get #f, offset, bytes
Close #f

f = FreeFile
Open picFile For Binary As #f
' save the image as a tmp file
Put #f, , bytes
Close #f

On Error Resume Next
' use vb to read the image
Set Picture1.Picture = LoadPicture(picFile)

' kill the tmp file
Kill picFile

On Error GoTo 0
End Sub


Private Sub Command1_Click()
SaveSplashImage
End Sub

Private Sub Form_Load()
GetSplashImage
End Sub


Hope it is useful

Dark Rain
Sep 23rd, 2000, 01:53 AM
Well maybe I dont understand what you want to do but wouldnt it be waaaaay more simple to get the program to load a .bmp that isnt in the exe. Just get your other program to change that bitmap. If there's text not in the bitmap, just put the company name in a textfile read by the program.

PaulLewis
Sep 23rd, 2000, 02:06 AM
Dark Rain,

I think that would make it too easy for non System Integrators to modify the bitmap. Presumably there is a sound marketing reason for mct wanting to give this feature only to certified users of his product.

Cheers

Dark Rain
Sep 23rd, 2000, 02:33 AM
Well I didnt think it was important non sys-user couldnt modify it. Well you can always change the extension of the .bmp to I dont know, .rsc or say it's a .gif while it's a bmp. The average user wont know.

PaulLewis
Sep 23rd, 2000, 02:58 AM
Another technique is to add a sequence of bytes to the start of the image file which your program strips off. This is what I do in an app where jpegs are being stored and retrieved from VB in an Access DB.

The advantage of Dark Rain's idea is that at least this way your application will remain the same size regardless of what bitmap is used.

Cheers

Sep 23rd, 2000, 04:47 PM
Change the Splash Screen? Easy!

All you have to do (and not even API) is make a bitmap and place it as 256 colors with the name logo.sys in the Windows Folder.

If you want to find the winfolder, use GetWinPathDir (or something like that, I can't remember well).