Thread: Window Titles check

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    932

    Window Titles check

    I would like to make a check on window titles.
    Whats wrong with this condition?
    I tried both
    Code:
    if(Buff != "Default IME"
    and
    Code:
     if(Buff != TEXT("Default IME"))
    Code:
    BOOL EnumWindowsProc(HWND hTaskbar, long lParam)
    {
          char Buff[255], NameOfClass[255];
    
          //hTaskbar = FindWindow(TEXT("Shell_TrayWnd"), NULL);
    
          GetWindowText(hTaskbar, Buff, 254);
          GetClassName(hTaskbar, NameOfClass, 254);
        if(Buff != TEXT("Default IME"))  //????????????????
        {
          cout << "Window Text: " << Buff << "\n"
               << "Class Name: "  << NameOfClass << endl << endl;
        }
    
          return TRUE;
    }
    
    
    int main(int argc, char* argv[])
    {
          EnumWindows((WNDENUMPROC)EnumWindowsProc, 0);
          cin.ignore();
          return 0;
    }
    Using Windows 10 with Code Blocks and MingW.

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    You have to use strcmp. Strings are pointers to arrays of characters (hence char *) so comparing the pointers is incorrect, you have to use a function

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    932
    Thank you very much Tonto!

    You made my rainy sunday sunshiny!

    Have a nice day!
    Last edited by Ducky; 04-26-2009 at 05:10 AM.
    Using Windows 10 with Code Blocks and MingW.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  2. Adding buttons, edit boxes, etc to the window
    By rainmanddw in forum Windows Programming
    Replies: 1
    Last Post: 04-10-2006, 03:07 PM
  3. My Window Class
    By Epo in forum Game Programming
    Replies: 2
    Last Post: 07-10-2005, 02:33 PM
  4. internet
    By yeah in forum C Programming
    Replies: 16
    Last Post: 02-12-2005, 10:37 PM
  5. Adding colour & bmps to a Win 32 Window??
    By carey_sizer in forum Windows Programming
    Replies: 4
    Last Post: 09-04-2004, 05:55 PM