Window Titles check

This is a discussion on Window Titles check within the Windows Programming forums, part of the Platform Specific Boards category; I would like to make a check on window titles. Whats wrong with this condition? I tried both Code: if(Buff ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Location
    France
    Posts
    749

    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;
    }
    Compiler MSVC++ 2010 with Code::Blocks.

  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

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

  3. #3
    Registered User
    Join Date
    Dec 2007
    Location
    France
    Posts
    749
    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.
    Compiler MSVC++ 2010 with Code::Blocks.

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, 10: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, 09: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

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