FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FindWindow Help
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
FindWindow Help
Posted: Thu Sep 08, 2011 02:34 PM

Hi,

I want the ability to close a window opened by one of my apps while i'm in another application. I can do this with the following:

SendMessage( FindWindow( 0, "Customer View" ), WM_CLOSE )

However, I want to change the title of the customer view window to display the customers name, so in my other app, I will no longer know what the name of the window is.

Is there a way of doing a wild search to find the window handle (like "Customer View*" - my window will always start with Customer View)

Thanks in advance

Pete

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: FindWindow Help
Posted: Fri Sep 09, 2011 08:20 AM
Try this:

Code (fw): Select all Collapse
#define GW_HWNDFIRST 0
#define GW_HWNDLAST  1
#define GW_HWNDNEXT  2
#define GW_HWNDPREV  3
#define GW_OWNER     4
#define GW_CHILD     5


FUNCTION FINDWND( cTitle )

    LOCAL hWnd := GETWINDOW( GETDESKTOPWINDOW(), GW_CHILD )

    WHILE hWnd != 0
        IF UPPER( cTitle ) $ UPPER( GETWINDOWTEXT( hWnd ) )
            RETURN hWnd
        ENDIF

        hWnd = GETWINDOW( hWnd, GW_HWNDNEXT )
    ENDDO

    RETURN NIL


EMG
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
Re: FindWindow Help
Posted: Fri Sep 09, 2011 08:29 AM

Works perfectly, many thanks Enrico

Regards,

Pete

Continue the discussion