Changing variable

This is a discussion on Changing variable within the Windows Programming forums, part of the Platform Specific Boards category; For some reason my variable iPrevHeight keeps changing everytime I collapse and resize my window ... Here is the relevant ...

  1. #1
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293

    Changing variable

    For some reason my variable iPrevHeight keeps changing everytime I collapse and resize my window ... Here is the relevant code ...

    (iPrevHeight is an int in the struct lpms)

    Code:
     case WM_NCLBUTTONDBLCLK: {
     		  
     		  if( wParam == HTCAPTION && !lpms->bCollapsed ) {
     			
     			RECT rc;
     			GetWindowRect( hwnd, &rc );
     			rc.right-=rc.left;
     			rc.bottom-=rc.top;
     			int n = (int)GetSystemMetrics(SM_CYCAPTION);
     			if ( rc.bottom <= n )
     				return 0;
     			lpms->iPrevHeight = rc.bottom+n;
     		    SetWindowPos( hwnd, HWND_TOPMOST, 1,1,rc.right,n, SWP_NOMOVE );
     			lpms->bCollapsed = true;
     		  }else if ( wParam == HTCAPTION && lpms->bCollapsed ) {
     			
     			RECT rc;
     			GetClientRect( hwnd, &rc );
     		    SetWindowPos( hwnd, HWND_TOPMOST, 1,1,rc.right,lpms->iPrevHeight, SWP_NOMOVE );
     			lpms->bCollapsed = false;
     			
     		  }
     		  
     		  return 0;
     		}

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,630
    Well, the"relevant" code looks ok to me. If you're using a debugger and the values in that structure are changing mysteriously, that's usually an indication that your code stomping around (in memory) where it shouldn't.

    gg

  3. #3
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    Yeah it is increasing in the debugger when I watched it ... how can I correct this?

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,630
    Well, you can do a binary search using breakpoints. Put a watch on the memory that's changing. Find and set a breakpoint somewhere before where the memory changes and another somewhere after where the the memory changes. Then narrow in the search on the area of code that't causing the change.

    Or just go back and do a quick buffer overrun review of your code - make sure strings are null-terminated, and that parameters to functions like memcpy() are reasonable, etc...

    gg

  5. #5
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    Okey dokey ...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to put a check on an extern variable set as flag
    By rebelsoul in forum C Programming
    Replies: 18
    Last Post: 05-25-2009, 03:13 AM
  2. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 04:23 AM
  3. static class variable vs. global variable
    By nadamson6 in forum C++ Programming
    Replies: 18
    Last Post: 09-30-2005, 03:31 PM
  4. Replies: 2
    Last Post: 04-12-2004, 01:37 AM
  5. write Variable and open Variable and get Information
    By cyberbjorn in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2004, 01:30 AM

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