Jump to content
  • Advertisement

RonHiler

Member
  • Content count

    427
  • Joined

  • Last visited

Community Reputation

214 Neutral

About RonHiler

  • Rank
    Member
  1. I have a rich edit control, but in certain cases I need to resize it.   Basically, it comes down to this. I know the contents of the control. I know the width. Given those, I need to calculate the height.   I've played with all kinds of variations of EN_REQUESTRESIZE, but no matter the width of the window I pass in, it doesn't recalculate the height properly (I even deliberately set the window height to something ridiculous (5) to force a recalculation of the height of the REQRESIZE fuction, but it always comes back with the same values in rc->top and rc->bottom (0 and 825 to be exact)), so I think I need to do a more manual recalculation of the height of the window.   It seems like this should be something you ought to be able to do, but there doesn't seem to be an obvious way to do it.   Here is the code I am using:           case WM_NOTIFY:             {             ostringstream ss;             if (wParam == TTW_TOOLTIPTEXT)                 {                 if (((NMHDR*)lParam)->code == EN_REQUESTRESIZE)                     {                     GetWindowRect(ConfiningWindow, &ConfiningRect);                     ReqResize = (REQRESIZE*)lParam;                     GetCursorPos(&CursorPoint);                     X = CursorPoint.x + 10;                     Y = CursorPoint.y + 10;                     //don't fall off the bottom of the confining window                     if (Y + (ReqResize->rc.bottom - ReqResize->rc.top) +15 > ConfiningRect.bottom)                         Y = ConfiningRect.bottom - (ReqResize->rc.bottom - ReqResize->rc.top) - 15;                     //also, don't go past the right side of the main window                     if (X + (ReqResize->rc.right - ReqResize->rc.left) +15 > ConfiningRect.right)                         X = CursorPoint.x - (ReqResize->rc.right - ReqResize->rc.left) - 15;                     //at this point we should be entirely inside the window, unless the text is so large the tooltip is higher than the entire window itself.                     if (Y < ConfiningRect.top)                         {                         ss << "Retry: X,Y: " << X << "," << Y << "    ReqResize: " << ReqResize->rc.left << "," << ReqResize->rc.right << "," << ReqResize->rc.top << "," << ReqResize->rc.bottom << "    Confining: " << ConfiningRect.left << "," << ConfiningRect.right << "," << ConfiningRect.top << "," << ConfiningRect.bottom << "\r\n";                         OutputDebugString(ss.str().c_str());                         ReqResize->rc.right += 50;                         SetWindowPos(ToolTipWindow, HWND_TOPMOST, X, Y, ReqResize->rc.right - ReqResize->rc.left+8, ReqResize->rc.bottom - ReqResize->rc.top+8, SWP_HIDEWINDOW);                         SetWindowPos(ToolTipText, HWND_TOP, 0, 0, ReqResize->rc.right - ReqResize->rc.left, ReqResize->rc.bottom - ReqResize->rc.top, SWP_HIDEWINDOW);                         SendMessage(ReqResize->nmhdr.hwndFrom, EM_REQUESTRESIZE, 0, 0);                         return 0;                         }                       SetWindowPos(ToolTipWindow, HWND_TOPMOST, X, Y, ReqResize->rc.right - ReqResize->rc.left+8, ReqResize->rc.bottom - ReqResize->rc.top+8, SWP_SHOWWINDOW);                     SetWindowPos(ToolTipText, HWND_TOP, 0, 0, ReqResize->rc.right - ReqResize->rc.left, ReqResize->rc.bottom - ReqResize->rc.top, SWP_SHOWWINDOW);                     return 0;                     }                 return 0;                 }             return 0;             }     So, just to clarify, that ODS string gives values like such:   Retry: X,Y: 1015,30    ReqResize: 0,200,0,825    Confining: 460,1460,330,870 Retry: X,Y: 1015,30    ReqResize: 0,250,0,825    Confining: 460,1460,330,870 Retry: X,Y: 1015,30    ReqResize: 0,300,0,825    Confining: 460,1460,330,870   Notice ReqResize width is increasing by 50 at a time, but the height isn't changing.   Any suggestions?
  2.   Ahhh, there it is. It's a child window alright. I didn't know they couldn't be TOPMOST.   Huh. Now I have to figure out a way to get it to draw where I want. Drat it.
  3. Ah, gotcha.   It was a great idea, but still no go. With two separate calls, the window again moves and resizes, but still won't stay above other windows (one window in particular). It's the weirdest thing. The window drawing on top of it is definitely not a TopMost window. I wonder if I have an issue with painting or something. Grrrr.
  4.   The application is in the foreground (it is the acive application).   The hwnd is the active window. But just to be sure, I modified the code:     SetActiveWindow(ReqResize->nmhdr.hwndFrom);     SetWindowPos(ReqResize->nmhdr.hwndFrom, HWND_TOPMOST, X, Y, ReqResize->rc.right - ReqResize->rc.left, ReqResize->rc.bottom - ReqResize->rc.top, SWP_SHOWWINDOW); Sadly, no difference.   I gave this a try in place of SetWindowPos(), and it works just like HWND_TOP (even though I created the window with a WS_EX_TOPMOST flag, it's not acting as such). MoveWindow(ReqResize->nmhdr.hwndFrom, X, Y, ReqResize->rc.right - ReqResize->rc.left, ReqResize->rc.bottom - ReqResize->rc.top, true);   Uh, the window is moved and resized because the purpose of the routine is to move and resize the window. I think you are misunderstanding the purpose.
  5. Hey guys,   I have a weird problem I can't figure out:   This code is meant to calculate a position of a window and put it there. And it pretty much works just fine, the window appears where it is supposed to be. The only issue with it is I really need the final line to make it a topmost window.         case WM_NOTIFY:             {             if (wParam == MEW_TOOLTIPWINDOW || wParam == EW_TOOLTIPWINDOW)                 {                 if (((NMHDR*)lParam)->code == EN_REQUESTRESIZE)                     {                     ReqResize = (REQRESIZE*)lParam;                     GetWindowRect(EnhancementWindowHandle, &WindowRect);                     GetCursorPos(&CursorPoint);                     X = CursorPoint.x - WindowRect.left+10;                     Y = CursorPoint.y - WindowRect.top+10;                     //don't fall off the bottom of the main window                     if (Y + (ReqResize->rc.bottom - ReqResize->rc.top) > (WindowRect.bottom - WindowRect.top))                         Y = (WindowRect.bottom - WindowRect.top) - (ReqResize->rc.bottom - ReqResize->rc.top);                     //also, don't go past the right side of the main window                     if (X + (ReqResize->rc.right - ReqResize->rc.left) > (WindowRect.right - WindowRect.left))                         X = (CursorPoint.x - WindowRect.left) - (ReqResize->rc.right - ReqResize->rc.left) - 10;                     //at this point we should be entirely inside the window, unless the text is so large the tooltip is higher than the entire window itself.                     // TODO: Handle fringe case of too tall a tooltip window...                     SetWindowPos(ReqResize->nmhdr.hwndFrom, HWND_TOP, X, Y, ReqResize->rc.right - ReqResize->rc.left, ReqResize->rc.bottom - ReqResize->rc.top, SWP_SHOWWINDOW);                     }                 }             return 0;             } so I changed the final line to such:   SetWindowPos(ReqResize->nmhdr.hwndFrom, HWND_TOPMOST, X, Y, ReqResize->rc.right - ReqResize->rc.left, ReqResize->rc.bottom - ReqResize->rc.top, SWP_SHOWWINDOW); That's the only change I made, just changed HWND_TOP to HWND_TOPMOST. And the result is the window no longer resizes or moves. It is in it's default size at parent window 0,0. The return value of the function does not indicate a failure (return is non-zero), it just doesn't do what I expect it to do.   I even tried forcing it to move:   SetWindowPos(ReqResize->nmhdr.hwndFrom, HWND_TOPMOST, 100, 100, 500, 500, SWP_SHOWWINDOW); Same thing, it is ignoring the x, y, sizex, and sizey parameters when using HWND_TOPMOST   Any ideas why? What am I doing wrong?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!