Hallo Alex,
ich hab mal ein wenig in den Win-API's gestöbert und folgendes zusammengetragen.
Einfach mal ein neues Projekt starten, auf die Form zwei CommandButtons plazieren (Command1 = Neues Bild zuordnen / Command2 = alten Button wiederherstellen), und folgenden Code einfügen:
Option Explicit
Dim hwndTaskbar As Long
Dim hwndStartButton As Long
Dim hbmpOriginal As Long
Private Declare Function FindWindowEx Lib "User32" _
Alias "FindWindowExA" (ByVal hwnd As Long, _
ByVal hWndChild As Long, ByVal lpszClassName As Any, _
ByVal lpszWindow As Any) As Long
Private Declare Function LoadImage Lib "User32" Alias _
"LoadImageA" (ByVal hInst As Long, _
ByVal lpsz As String, ByVal iImageType As Long, _
ByVal cx As Long, ByVal cy As Long, _
ByVal fFlags As Long) As Long
Private Declare Function SendMessage Lib "User32" Alias _
"SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Private Const BM_GETIMAGE = &HF6
Private Const BM_SETIMAGE = &HF7
Private Sub Form_Load()
<font color=green>' Fenster-Handle der Taskbar</font>
hwndTaskbar = FindWindowEx(0, 0, "Shell_TrayWnd", 0&)
<font color=green>' Fenster-Handle des StartButtons</font>
hwndStartButton = FindWindowEx(hwndTaskbar, 0, _
"BUTTON", 0&)
<font color=green>' Original-Bitmap lesen</font>
hbmpOriginal = SendMessage(hwndStartButton, _
BM_GETIMAGE, 0, ByVal 0&)
End Sub <font color=green>' Neues Bild zuordnen</font>
Private Sub Command1_Click()
Dim hbmpNew As Long
Dim strFilename As String
<font color=green>' Dateiname des neuen Bitmaps</font>
strFilename = "c: est.bmp"
<font color=green>' Neues Bitmap laden</font>
hbmpNew = LoadImage(0&, strFilename, 0, 0, 0, _
&H0 Or &H10 Or &H40)
<font color=green>' Neues Bitmap zuweisen</font>
SendMessage hwndStartButton, BM_SETIMAGE, 0, _
ByVal hbmpNew
End Sub <font color=green>' Alten Button wiederherstellen</font>
Private Sub Command2_Click()
SendMessage hwndStartButton, BM_SETIMAGE, 0, _
ByVal hbmpOriginal
End Sub</code> Probier's einfach mal aus - ich bin nicht ganz sicher, ob's funktioniert.
Ich habe den Code unter Win2000 getestet mit folgendem Effekt:
Bei der Zuweisung eines neuen Buttons wurde das "alte" Bitmap zwar aus dem Start-Button entfernt, das neue Bild aber auch nicht angezeigt. Bei mir zeigt der Start-Button also momentan eine leere "Fläche". Vielleicht funktioniert es aber unter Win9x korrekt. Vielleicht ist auch irgendwo noch ein kleiner Fehler?
Jedenfalls, viel Spass damit!
Cu
Dieter |