VB and VBA Users Source Code: Get and set a dialogs caption/title
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Get and set a dialogs caption/title
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Wednesday, February 28, 2001
Hits:
573
Category:
Windows API
Article:
The following routines allow the user to get and set a dialogs caption/title. Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long 'Purpose : Returns the window caption of a specified window. 'Inputs : lHwnd The handle of the window to determine the caption of. 'Outputs : Returns the window caption of a specified window. 'Author : Andrew Baker 'Date : 26/02/2001 21:21 'Notes : 'Assumptions : Function DialogGetCaption(lHwnd As Long) As String Const clMaxLen As Long = 255 Dim lLen As Long, sValue As String * clMaxLen lLen = GetWindowText(lHwnd, sValue, clMaxLen) If lLen Then DialogGetCaption = Left$(sValue, lLen) End If End Function 'Purpose : Sets the caption and window handle of the current clipboard owner. 'Inputs : lHwnd The handle of the window to change the caption of. ' sNewCaption The new window caption 'Outputs : Returns True on success. 'Author : Andrew Baker 'Date : 26/02/2001 21:21 'Notes : 'Assumptions : Function DialogSetCaption(lHwnd As Long, sNewCaption As String) As Boolean DialogSetCaption = CBool(SetWindowText(lHwnd, sNewCaption)) End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder