My mess of sub calls!

This is a discussion on My mess of sub calls! within the Windows Programming forums, part of the Platform Specific Boards category; Code: GetWindowText( FindWindowEx( FindWindowEx( FindWindowEx( FindWindow( "IEFrame", 0), 0, "WorkerW", 0), 0, "ReBarWindow32", 0), 0, "ComboBoxEx32", 0), hbWnd, MAX_PATH ); ...

  1. #1
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342

    Unhappy My mess of sub calls!

    Code:
     
    			   GetWindowText( 
    				 FindWindowEx(
    				   FindWindowEx( 
    					 FindWindowEx( 
    					   FindWindow(
    					   "IEFrame",
    					   0),
    					 0,
    					 "WorkerW",
    					 0),
    				   0,
    				   "ReBarWindow32",
    				   0),
    				 0,
    				 "ComboBoxEx32",
    				 0),
    			   hbWnd,
    			   MAX_PATH );
    why isn't hbWnd getting anything?
    (Text is in IE's address bar.)

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,262
    That is probably the ugliest code I have ever seen. How about you check the return values for the 4 FindWindow() functions?

  3. #3
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Yes, and it returns valid! see! What iv'e got now:...

    Code:
    #define WIN32_LEAN_AND_MEAN
    #include <windows.h>
    #include <gwc.h>
    #include <windowsx.h>
    #include <commctrl.h>
    #include <mmsystem.h>
    int WINAPI WinMain (HINSTANCE hThisInstance,
    					HINSTANCE hPrevInstance,
    					LPSTR lpszArgument,
    					int nFunsterStil)
    {
      char hbWnd[MAX_PATH];
     
     HWND hwnd = FindWindowEx(
    			   FindWindowEx(  
    				 FindWindowEx( 
    				   FindWindowEx( 
    					 FindWindowEx( 
    					   FindWindow(
    					   "IEFrame",
    					   0),
    					 0,
    					 "WorkerW",
    					 0),
    				   0,
    				   "ReBarWindow32",
    				   0),
    				 0,
    				 "ComboBoxEx32",
    				 0),
    			   0,
    			   "ComboBox",
    			   0),
    			 0,
    			 "Edit",
    			 0);
    
       GetWindowText(hwnd,hbWnd,MAX_PATH);
     
      if((hwnd && NULL) || (hwnd == NULL))
      MessageBox( 0, "Didn't get 'er!   ):<", "stinker!", MB_OK);
      else
      MessageBox( 0, hbWnd, "well...", MB_OK);
     
      return 0;
    }
    Last edited by Queatrix; 02-14-2006 at 05:29 PM.

  4. #4
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    If you had read this msdn page carefully you would have noticed this:
    If the lpszWindow parameter is not NULL, FindWindowEx calls the GetWindowText function to retrieve the window name for comparison. For a description of a potential problem that can arise, see the Remarks section of GetWindowText.
    Which leads you here, where you will find:
    If the target window is owned by the current process, GetWindowText causes a WM_GETTEXT message to be sent to the specified window or control. If the target window is owned by another process and has a caption, GetWindowText retrieves the window caption text. If the window does not have a caption, the return value is a null string.
    [...]
    To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.
    And also, what is the purpose of this?
    Code:
    if((hwnd && NULL)|| (hwnd == NULL))
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  5. #5
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Okay I see it now, and got it working too, thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 11:43 AM
  2. How do you make calls?
    By scatterice in forum C Programming
    Replies: 1
    Last Post: 03-09-2009, 07:07 PM
  3. Which I/O calls do you use the most?
    By _Elixia_ in forum Tech Board
    Replies: 10
    Last Post: 07-11-2003, 12:58 PM
  4. Follow Iraq, North Korea trying to mess the World.
    By KingoftheWorld in forum A Brief History of Cprogramming.com
    Replies: 81
    Last Post: 01-14-2003, 07:12 AM
  5. C/C++ Memory Calls!
    By Joda in forum C++ Programming
    Replies: 7
    Last Post: 10-25-2002, 05:50 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21