Results 1 to 4 of 4

Thread: Comparing two strings (not working)

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    Comparing two strings (not working)

    I have hooked my window and I am trying to know when a menu window is created as a new window is created. The class for the menu window is #32770 (I think) so I am using the following chunk of code to check when a menu window is created:
    PHP Code:
    LRESULT CALLBACK CallWndProc(int nCodeWPARAM wParamLPARAM lParam)
    {
        
    CWPSTRUCT *cw;
        
    string classname;
        switch (
    nCode)
        {
        case 
    HC_ACTION:
            
    cw = (CWPSTRUCT*)lParam;
            
    GetTheClassName(cw->hwndclassname);
        
    //    MessageBox(cw->hwnd,classname.c_str(),"",MB_OK);
            
    if(strcmp(classname.c_str(),"#32770") == 0)
            {
            
    MessageBox("A menu window was created","",MB_OK);
                
    //A menu window was created
            
    }
            return 
    CallNextHookEx(myhook,nCode,wParam,lParam);
        }
        
        return 
    CallNextHookEx(myhook,nCode,wParam,lParam);
    }

    void GetTheClassName(HWND hWndstring &classdest)
    {
        
    char classname[128];
        
    GetClassName(hWnd,classname128);
        
    classdest classname;

    Now if I uncomment the line MessageBox(cw
    >hwnd,classname.c_str(),"",MB_OK);
    before I use the if statement, some of the class names ARE "#32770" so it should actually return 0 from strcmpy but it's NOT. It never shows the message box inside the if statement which says "A menu window was created".
    Baaaaaaaaah

  2. #2
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Try making a temp VAR to hold your string compare and then if that VAR
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  3. #3

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Nope, that doesn't work.
    Baaaaaaaaah

  4. #4
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Well what is the VAR equal to when you run it? 0, -1, > 0 ?

    Maybe there is a return in your string

    Try if(strcmp(classname.c_str(),"#32770") >= 0)
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width