Re: Change app.title at runtime?



Karl E. Peterson wrote:
JT wrote:
I have tested almost all possible properties and it's definitely the
title property. But it only changes in SQL current activity if i
change it at design time.(project properties)
Do I need some sort of PostMessage API or something to refresh it's
properties?

Ask yourself, "What Would SQL Do?" IOW, how do you presume this
value is being extracted? Until that can be answered, it's just wild
thrashing to suggest possible solutions.

Okay, here's the test that was necessary.

1) Brand new project,
2) Set title to unique string in Project Properties,
3) Compile and run,
4) Find it with Spy++
5) Note that our title (step 2) isn't a property of this window,
6) Note that our title *is* the Window Caption of window's owner!

Shazam!!! So, enough hints, or...? Aw, what the heck... Call
SetWindowText on the handle returned by FindHiddenTopWindow:

Private Declare Function GetWindowLong Lib "user32" Alias
"GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function EnumThreadWindows Lib "user32" (ByVal dwThreadId
As Long, ByVal lpfn As Long, ByVal lParam As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory"
(Destination As Any, Source As Any, ByVal Length As Long)

' Constants used with above APIs
Private Const GWL_HWNDPARENT As Long = (-8)

Public Function FindHiddenTopWindow() As Long
' This function returns the hidden toplevel window
' associated with the current thread of execution.
Call EnumThreadWindows(App.ThreadID, AddressOf EnumThreadWndProc,
VarPtr(FindHiddenTopWindow))
End Function

Private Function EnumThreadWndProc(ByVal hWnd As Long, ByVal lpResult As
Long) As Long
' Test to see if this window is parented.
' If not, it's the one we're looking for!
If GetWindowLong(hWnd, GWL_HWNDPARENT) Then
' Continue enumeration.
EnumThreadWndProc = True
Else
' Copy hWnd to result variable pointer,
' and stop enumeration.
Call CopyMemory(ByVal lpResult, hWnd, 4)
EnumThreadWndProc = False
End If
End Function

Hmmmmm, testing this entire notion, I note that setting App.Title does
indeed alter the caption of our hidden window! So, back to the beginning,
I'm stumped too. All I can guess at this point is that SQL isn't going to
notice the updated title, and just goes with whatever you start with?
<shrug>

Later... Karl
--


.



Relevant Pages

  • Re: Creating new appointment & setting its properties
    ... The window and process subclassing I've seen with WordMail is horrendous, it's miles of code just to get a true hWnd for a WordMail window usually. ... Private Declare Function GetForegroundWindow Lib "User32.dll" As Long ... Private Declare Function FindWindowEx Lib "User32.dll" Alias "FindWindowExA" (ByVal hwndParent As Long, ByVal hwndChildAfter As Long, ByVal lpszClass As String, ByVal lpszWindow As String) As Long ...
    (microsoft.public.outlook.program_vba)
  • Re: Are VBA userforms always child of Windows desktop?
    ... Private Declare Function GetDesktopWindow Lib "user32" As Long ... Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long ... The system restores the window to its original state. ... Dim hWndDesktop As Long ...
    (microsoft.public.excel.programming)
  • Re: Are VBA userforms always child of Windows desktop?
    ... I only need this Hwnd of the parent, ... GetAncestor API (with GA_PARENT) to get Parent. ... I suppose which window you need will depend on the overall objective. ... Private Declare Function GetDesktopWindow Lib "user32" As Long ...
    (microsoft.public.excel.programming)
  • re: Get the list of applications which are running
    ... Private Declare Function GetDesktopWindow Lib "user32" ... Alias "GetWindowLongA" (ByVal hwnd As Long, ... As String, ByVal cch As Long) As Long ... ' - An integer array used to return the window handles ...
    (microsoft.public.excel.programming)
  • Re: Name Box
    ... (ByVal hwnd As Long, _ ... Private Declare Function GetDesktopWindow Lib "user32" As Long ... ' Get the ID of the process that a window belongs to ...
    (microsoft.public.excel.worksheet.functions)