CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    How to put label's caption into taskbar

    Thank You


  2. #2
    Join Date
    Sep 1999
    Location
    Red Wing, MN USA
    Posts
    312

    Re: How to put label's caption into taskbar

    If you mean how can you make the Taskbar Caption different to the Forms Caption, try this Code Snippet I put together a while ago:
    In a Module..

    public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (byval hwnd as Long, byval nIndex as Long, byval dwNewLong as Long) as Long
    private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination as Any, Source as Any, byval Length as Long)
    private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (byval lpPrevWndFunc as Long, byval hwnd as Long, byval Msg as Long, byval wParam as Long, byval lParam as Long) as Long

    public Const GWL_WNDPROC = (-4)
    private Const WM_GETTEXT = &HD

    public lPrevWnd as Long
    public sFormCaption as string

    public Function SubWindow(byval hwnd as Long, byval Msg as Long, byval wParam as Long, byval lParam as Long) as Long
    If Msg = WM_GETTEXT then
    'Substitute the Default Form Caption for our own Caption
    CopyMemory byval lParam, byval sFormCaption, len(sFormCaption)
    wParam = len(sFormCaption)
    SubWindow = wParam
    else
    SubWindow = CallWindowProc(lPrevWnd, hwnd, Msg, wParam, byval lParam)
    End If
    End Function



    In the Form..

    private Sub Form_Load()
    'The Taskbar Caption is set using the Normal Caption property
    Caption = "TaskBar Caption"
    'set the Forms Caption
    sFormCaption = "Form Caption" & Chr(0)
    'Subclass the Form
    lPrevWnd = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf SubWindow)
    End Sub

    private Sub Form_Unload(Cancel as Integer)
    'Release the Subclassing
    Call SetWindowLong(hwnd, GWL_WNDPROC, lPrevWnd)
    End Sub



    Use the Caption Property of the Form to Set the TaskBar Caption, and the sFormCaption Variable to Set the Forms Caption.


    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]
    Aaron Young
    Senior Programmer Analyst (Red Wing Software)
    Certified AllExperts Expert

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured