Quote:Original post by lordikon
Quote:Original post by kittycat768
Quote:Original post by lordikon
Because it is code from work I cannot copy and paste it, and I'm not currently at work so I don't have the code in front of me anyhow.
Which comments do you mean, the only stuff I think I left out what the corner sizing. For the corner sizing if the user has resized the window more horizontally then I treat the movement the same as I would if they were dragging the the right or left, and so I adjust the width, otherwise I adjust the height.
Okay, I understand why you can't post your code. I just can't offer any more information w/o actually seeing your code. I guess your code would probably be your companies code. Best of luck.
WTB a programming job ;_;
Here is what I'm doing inside the corner dragging cases, nothing special.if ( widthDiffGreaterThanHeightDiff ){ if ( fAspectRatio < MIN_ASPECT_RATIO ) // Not wide enough { // Make window shorter fHeight = (fWidth / MIN_ASPECT_RATIO) ; } // If window is too wide else if ( fAspectRatio > MAX_ASPECT_RATIO ) { // Make window taller fHeight = (fWidth / MAX_ASPECT_RATIO); }}else{ // If window is not wide enough, make it wider if ( fAspectRatio < MIN_ASPECT_RATIO) { // Set height so that we reach MIN_ASPECT_RATIO fWidth = (fHeight * MIN_ASPECT_RATIO) + 0.5f; } // If window is too wide after shortening it, make it less wide else if ( fAspectRatio > MAX_ASPECT_RATIO ) { // Set width so that we reach MAX_ASPECT_RATIO fWidth = (fHeight * MAX_ASPECT_RATIO) + 0.5f; }}
I understand what you're doing with this. I just today added this type of code and now my window can scale based on the x movement or y movement when being resized from a corner. before I would have to move the mouse on the x-axis.
The way I snap my cursor is if I scale the height while dragging the bottom edge, I set the cursor y coordinate to the y of the bottome edge after I scale it. I can't help but keep coding on this idea. I've implemented a lot of what you've posted. I don't know if I'll ever stop playing with my code. I just hope that you can find some of my code as useful as I've found some of your code. [smile]
case WMSZ_TOPLEFT: // The cursor move further or as much along the x axis as it did on the y axis if(abs((int)(p.x - pold.x)) >= abs((int)(p.y - pold.y))) { // Snap the corner to the cursor. rcWnd -> left = p.x; // Limit how far the left edge can go. constraint = rcWnd -> right - GetSystemMetrics(SM_CXMIN); if(p.x > constraint) p.x = rcWnd -> left = constraint; width = rcWnd -> right - rcWnd -> left - xborder; // Subtract the border from the width of the window. // Scale the height of the window using the aspect ratio of it's client area. rcWnd -> top = rcWnd -> bottom - yborder - ycaption - (long)((float)width * yaspect); // Snap the cursor to the corner. p.y = rcWnd -> top; } // The cursor moved further along the y axis than it did on the x axis else { // Snap the top edge to the cursor. rcWnd -> top = p.y; // Limit how far the top edge can go. SM_CXMIN includes the border, so subtract it when neccessary. constraint = rcWnd -> bottom - yborder - ycaption - (long)((float)(GetSystemMetrics(SM_CXMIN) - xborder) * yaspect); if(p.y > constraint) p.y = rcWnd -> top = constraint; // Subtract the border and caption from the height of the window. height = rcWnd -> bottom - rcWnd -> top - yborder - ycaption; // Scale the width of the window using the aspect ratio of it's client area. rcWnd -> left = rcWnd -> right - xborder - (long)((float)height * xaspect); // Snap the cursor to the corner. p.x = rcWnd -> left; }break;
I throw this in at the end of WM_SIZING:
pold = p;SetCursorPos(p.x, p.y);rcWnd = 0;
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------I once read that World of Warcraft is poor fishing simulator. I don't know about you but I catch a lot more fish in World of Warcraft than I do in real life.