Rubrik: System/Windows · Desktop/Bildschirm/Display | VB-Versionen: VB4, VB5, VB6 | 01.10.03 |
Windows-Startbutton Text setzen/auslesen Dieses Beispiel demonstriert, wie sich der Text des Startbuttons setzen und auslesen lässt. | ||
Autor: --Florian-- | Bewertung: | Views: 13.814 |
t-g-f.de | System: WinXP, Win8, Win10, Win11 | Beispielprojekt auf CD |
Nachfolgendes Beispiel demonstriert, wie sich der Text des Startbuttons setzen und auslesen lässt.
Hierzu benötigen Sie eine Form, eine TextBox, sowie 2 CommandButtons (cmd_setzen und cmd_reset).
Option Explicit ' zunächst die benötigten API-Deklarationen Private Declare Function FindWindow Lib "user32" _ Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Declare Function GetWindow Lib "user32" ( _ ByVal hwnd As Long, _ ByVal wCmd As Long) As Long Private Declare Function WindowFromPoint Lib "user32" ( _ ByVal xPoint As Long, _ ByVal yPoint 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 GW_CHILD = 5 Private Const WM_GETTEXT = &HD Private Const WM_SETTEXT As Long = &HC Dim ohWnd As Long
Private Sub Form_Load() ' Button-Handle ermitteln ohWnd = FindWindow("shell_traywnd", "") ohWnd = GetWindow(ohWnd, GW_CHILD) Dim lLength As Long Dim sWindowText As String * 255 lLength = SendMessage(ohWnd, WM_GETTEXT, _ Len(sWindowText) + 1, ByVal sWindowText) Text1.Text = Left$(sWindowText, lLength) End Sub
Private Sub cmd_setzen_Click() ' neuen Text setzen SendMessage ohWnd, WM_SETTEXT, 1, ByVal Text1.Text End Sub
Private Sub cmd_reset_Click() ' Buttontext wiederherstellen SendMessage ohWnd, WM_SETTEXT, 1, ByVal "Start" End Sub