-
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;
}
-
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
-
Yeah it is increasing in the debugger when I watched it ... how can I correct this?
-
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
-