Форум программистов «Весельчак У»
  *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

  • Рекомендуем проверить настройки временной зоны в вашем профиле (страница "Внешний вид форума", пункт "Часовой пояс:").
  • У нас больше нет рассылок. Если вам приходят письма от наших бывших рассылок mail.ru и subscribe.ru, то знайте, что это не мы рассылаем.
   Начало  
Наши сайты
Помощь Поиск Календарь Почта Войти Регистрация  
 
Страниц: [1]   Вниз
  Печать  
Автор Тема: LOWORD / HIWORD для LPARAM ; WM_SIZE  (Прочитано 39571 раз)
0 Пользователей и 1 Гость смотрят эту тему.
Malaja
Команда клуба

de
Offline Offline
Пол: Женский

« : 16-03-2005 10:00 » 

Люди, кто помнит, как заполнить LOWORD / HIWORD для LPARAM?
Т.е. надо отправить WM_SIZE и указать новые размеры окна.

pDlg->PostMessage(WM_SIZE, wparam, lparam)

WM_SIZE
fwSizeType = wParam;      // resizing flag
nWidth = LOWORD(lParam);  // width of client area
nHeight = HIWORD(lParam); // height of client area
Если просто написать lParam = 50, то получается заполненным соответственно только nWidth   Здесь была моя ладья...
« Последнее редактирование: 17-03-2005 12:52 от Malaja » Записан

холоднокровней, Маня, Ви не на работе
---------------------------------------
четкое определение сущности бытия:
- А мы в прошлом или в будущем?- спросила Алиса.
- Мы в жопе, - ответил кролик.
- А "жопа" - это настоящее? - спросила Алиса.
- А "жопа" - это у нас символ вечности.
Pu
Большой босс

ru
Offline Offline
78


« Ответ #1 : 16-03-2005 10:25 » 

а зачем помнить? есть мсдн

WM_SIZE Notification

--------------------------------------------------------------------------------

The WM_SIZE message is sent to a window after its size has changed.

A window receives this message through its WindowProc function.


Syntax

WM_SIZE

    WPARAM wParam
    LPARAM lParam;
   
Parameters

wParam
Specifies the type of resizing requested. This parameter can be one of the following values.
SIZE_MAXHIDE
Message is sent to all pop-up windows when some other window is maximized.
SIZE_MAXIMIZED
The window has been maximized.
SIZE_MAXSHOW
Message is sent to all pop-up windows when some other window has been restored to its former size.
SIZE_MINIMIZED
The window has been minimized.
SIZE_RESTORED
The window has been resized, but neither the SIZE_MINIMIZED nor SIZE_MAXIMIZED value applies.
lParam
The low-order word of lParam specifies the new width of the client area.
The high-order word of lParam specifies the new height of the client area.
Записан

Насколько я опытен? Достаточно, чтобы понимать, что дураков нельзя заставить думать по–другому, но недостаточно, чтобы отказаться от попыток это сделать.
(с) Артур Джонс
Pu
Большой босс

ru
Offline Offline
78


« Ответ #2 : 16-03-2005 10:31 » 

а заполнить соответственно так -
Код:
WORD nWidth = 100; // LOWORD(lParam);   width of client area 
WORD nHeight = 200; //HIWORD(lParam);  height of client area
DWORD lParam = nWidth | (nHeight<<16);
« Последнее редактирование: 16-03-2005 10:45 от Pu » Записан

Насколько я опытен? Достаточно, чтобы понимать, что дураков нельзя заставить думать по–другому, но недостаточно, чтобы отказаться от попыток это сделать.
(с) Артур Джонс
Pu
Большой босс

ru
Offline Offline
78


« Ответ #3 : 16-03-2005 10:37 » 

а еще есть такой макрос -

LPARAM MAKELPARAM(
    WORD wLow,
    WORD wHigh
);

Код:
nWidth = 100; // LOWORD(lParam);   width of client area 
nHeight = 200; //HIWORD(lParam);  height of client area
lParam = MAKELPARAM( nWidth, nHeight);

Код:
#define MAKELONG(a, b)      ((LONG)(((WORD)((DWORD_PTR)(a) & 0xffff)) | ((DWORD)((WORD)((DWORD_PTR)(b) & 0xffff))) << 16))
#define MAKELPARAM(l, h)      ((LPARAM)(DWORD)MAKELONG(l, h))
Записан

Насколько я опытен? Достаточно, чтобы понимать, что дураков нельзя заставить думать по–другому, но недостаточно, чтобы отказаться от попыток это сделать.
(с) Артур Джонс
Malaja
Команда клуба

de
Offline Offline
Пол: Женский

« Ответ #4 : 16-03-2005 10:49 » 

Заяц, миленький, я тебя обожаю! Ага Именно этот макрос я и искала, т.е. я помнила, что он был, но как его звали - не помнила! А что касается побитовых сдвижек, тут я просто пас - ну просачковала я еще на лекзиях эту тему, а потом нигде не надо было, посему я это никогда не помню Ага Говорю же - я женщина забывчивая Ага
Записан

холоднокровней, Маня, Ви не на работе
---------------------------------------
четкое определение сущности бытия:
- А мы в прошлом или в будущем?- спросила Алиса.
- Мы в жопе, - ответил кролик.
- А "жопа" - это настоящее? - спросила Алиса.
- А "жопа" - это у нас символ вечности.
Malaja
Команда клуба

de
Offline Offline
Пол: Женский

« Ответ #5 : 16-03-2005 11:17 » 

Упс, а wm_size что-то не работает. ;-(
Создала обычное mdi - приложение, в нем создала диалог как popup / dialog frame, в котором толко title bar есть. Стартую его как немодальный из View, при старте перемещаю в правый верхний угол основного приложения и хочу задать ему определенные размеры. Но это ничего не дает - т.е. окно перемещается куда надо, а вот размеры остаются неизменными. А почему - не пойму... ;-(

   LPARAM lparam = MAKELPARAM(50, 50);
   WPARAM wParam = (WPARAM)SIZE_RESTORED;
   m_pClockShow->PostMessage(WM_SIZE, wParam, lparam);

Записан

холоднокровней, Маня, Ви не на работе
---------------------------------------
четкое определение сущности бытия:
- А мы в прошлом или в будущем?- спросила Алиса.
- Мы в жопе, - ответил кролик.
- А "жопа" - это настоящее? - спросила Алиса.
- А "жопа" - это у нас символ вечности.
Pu
Большой босс

ru
Offline Offline
78


« Ответ #6 : 16-03-2005 11:36 » 

 
Цитата
The WM_SIZE message is sent to a window AFTER its size has changed.
WM_SIZE - не служит для того чтобы изменить размеры виндоу. Оно посылается окну после того как размеры изменили. И в качестве параметров передается состояние окна текущее.
Записан

Насколько я опытен? Достаточно, чтобы понимать, что дураков нельзя заставить думать по–другому, но недостаточно, чтобы отказаться от попыток это сделать.
(с) Артур Джонс
Pu
Большой босс

ru
Offline Offline
78


« Ответ #7 : 16-03-2005 11:39 » 

попробуй вот эту функцию АПИ -
Цитата
The MoveWindow function changes the position and dimensions of the specified window. For a top-level window, the position and dimensions are relative to the upper-left corner of the screen. For a child window, they are relative to the upper-left corner of the parent window's client area.

Syntax

BOOL MoveWindow(          HWND hWnd,
    int X,
    int Y,
    int nWidth,
    int nHeight,
    BOOL bRepaint
);
Parameters

hWnd
[in] Handle to the window.
X
[in] Specifies the new position of the left side of the window.
Y
[in] Specifies the new position of the top of the window.
nWidth
[in] Specifies the new width of the window.
nHeight
[in] Specifies the new height of the window.
bRepaint
[in] Specifies whether the window is to be repainted. If this parameter is TRUE, the window receives a message. If the parameter is FALSE, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent window uncovered as a result of moving a child window.
Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

« Последнее редактирование: 20-12-2007 17:57 от Алексей1153++ » Записан

Насколько я опытен? Достаточно, чтобы понимать, что дураков нельзя заставить думать по–другому, но недостаточно, чтобы отказаться от попыток это сделать.
(с) Артур Джонс
Finch
Спокойный
Администратор

il
Offline Offline
Пол: Мужской
Пролетал мимо


« Ответ #8 : 16-03-2005 12:36 » 

Есть еше одна функция для этих целей
Цитата
The SetWindowPos function changes the size, position, and Z order of a child, pop-up, or top-level window. Child, pop-up, and top-level windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order.

BOOL SetWindowPos(

    HWND hWnd,   // handle of window
    HWND hWndInsertAfter,   // placement-order handle
    int X,   // horizontal position
    int Y,   // vertical position
    int cx,   // width
    int cy,   // height
    UINT uFlags    // window-positioning flags
   );   
 

Parameters

hWnd

Identifies the window.

hWndInsertAfter

Identifies the window to precede the positioned window in the Z order. This parameter must be a window handle or one of the following values:

Value   Meaning
HWND_BOTTOM   Places the window at the bottom of the Z order. If the hWnd parameter identifies a topmost window, the window loses its topmost status and is placed at the bottom of all other windows.
HWND_NOTOPMOST   Places the window above all non-topmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a non-topmost window.
HWND_TOP   Places the window at the top of the Z order.
HWND_TOPMOST   Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.
 

For more information about how this parameter is used, see the following Remarks section.

X

Specifies the new position of the left side of the window.

Y

Specifies the new position of the top of the window.

cx

Specifies the new width of the window, in pixels.

cy

Specifies the new height of the window, in pixels.

uFlags

Specifies the window sizing and positioning flags. This parameter can be a combination of the following values:

Value   Meaning
SWP_DRAWFRAME   Draws a frame (defined in the window's class description) around the window.
SWP_FRAMECHANGED   Sends a WM_NCCALCSIZE message to the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZE is sent only when the window's size is being changed.
SWP_HIDEWINDOW   Hides the window.
SWP_NOACTIVATE   Does not activate the window. If this flag is not set, the window is activated and moved to the top of either the topmost or non-topmost group (depending on the setting of the hWndInsertAfter parameter).
SWP_NOCOPYBITS   Discards the entire contents of the client area. If this flag is not specified, the valid contents of the client area are saved and copied back into the client area after the window is sized or repositioned.
SWP_NOMOVE   Retains the current position (ignores the X and Y parameters).
SWP_NOOWNERZORDER   Does not change the owner window's position in the Z order.
SWP_NOREDRAW   Does not redraw changes. If this flag is set, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent window uncovered as a result of the window being moved. When this flag is set, the application must explicitly invalidate or redraw any parts of the window and parent window that need redrawing.
SWP_NOREPOSITION   Same as the SWP_NOOWNERZORDER flag.
SWP_NOSENDCHANGING   Prevents the window from receiving the WM_WINDOWPOSCHANGING message.
SWP_NOSIZE   Retains the current size (ignores the cx and cy parameters).
SWP_NOZORDER   Retains the current Z order (ignores the hWndInsertAfter parameter).
SWP_SHOWWINDOW   Displays the window.
 

Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

If the SWP_SHOWWINDOW or SWP_HIDEWINDOW flag is set, the window cannot be moved or sized.
All coordinates for child windows are client coordinates (relative to the upper-left corner of the parent window's client area).
A window can be made a topmost window either by setting the hWndInsertAfter parameter to HWND_TOPMOST and ensuring that the SWP_NOZORDER flag is not set, or by setting a window's position in the Z order so that it is above any existing topmost windows. When a non-topmost window is made topmost, its owned windows are also made topmost. Its owners, however, are not changed.

If neither the SWP_NOACTIVATE nor SWP_NOZORDER flag is specified (that is, when the application requests that a window be simultaneously activated and its position in the Z order changed), the value specified in hWndInsertAfter is used only in the following circumstances:

·   Neither the HWND_TOPMOST nor HWND_NOTOPMOST flag is specified in hWndInsertAfter.
·   The window identified by hWnd is not the active window.

 

An application cannot activate an inactive window without also bringing it to the top of the Z order. Applications can change an activated window's position in the Z order without restrictions, or it can activate a window and then move it to the top of the topmost or non-topmost windows.
If a topmost window is repositioned to the bottom (HWND_BOTTOM) of the Z order or after any non-topmost window, it is no longer topmost. When a topmost window is made non-topmost, its owners and its owned windows are also made non-topmost windows.

A non-topmost window can own a topmost window, but the reverse cannot occur. Any window (for example, a dialog box) owned by a topmost window is itself made a topmost window, to ensure that all owned windows stay above their owner.
If an application is not in the foreground, and should be in the foreground, it must call the SetForegroundWindow function.
« Последнее редактирование: 20-12-2007 17:59 от Алексей1153++ » Записан

Не будите спашяго дракона.
             Джаффар (Коша)
Malaja
Команда клуба

de
Offline Offline
Пол: Женский

« Ответ #9 : 16-03-2005 12:51 » 

Pu,

Это идея, но возникает проблема - мне известны чистые размеры окна (без учета title bar). Для MoveWindow надо указать полные размеры... Т.е. как посчитать полную высоту (а точнее, как вычислить высоту title bar обычного диалога)?
Записан

холоднокровней, Маня, Ви не на работе
---------------------------------------
четкое определение сущности бытия:
- А мы в прошлом или в будущем?- спросила Алиса.
- Мы в жопе, - ответил кролик.
- А "жопа" - это настоящее? - спросила Алиса.
- А "жопа" - это у нас символ вечности.
Finch
Спокойный
Администратор

il
Offline Offline
Пол: Мужской
Пролетал мимо


« Ответ #10 : 16-03-2005 13:16 » 

Есть функция GetSystemMetrics. Её вызовы с параметрами SM_CYCAPTION и SM_CYMENU, и SM_CXBORDER, и SM_CYBORDER тебе дадут размеры не клиентской области.
Цитата
The GetSystemMetrics function retrieves various system metrics and system configuration settings.

System metrics are the dimensions (widths and heights) of Windows display elements. All dimensions retrieved by GetSystemMetrics are in pixels.

int GetSystemMetrics(

    int nIndex    // system metric or configuration setting to retrieve 
   );   
 

Parameters

nIndex

Specifies the system metric or configuration setting to retrieve. All SM_CX* values are widths. All SM_CY* values are heights. The following values are defined: 

Value   Meaning
SM_ARRANGE   Flags specifying how the system arranged minimized windows. For more information about minimized windows, see the following Remarks section.
SM_CLEANBOOT   Value that specifies how the system was started:0  Normal boot1  Fail-safe boot2  Fail-safe with network bootFail-safe boot (also called SafeBoot) bypasses the user's startup files.
SM_CMOUSEBUTTONS   Number of buttons on mouse, or zero if no mouse is installed.
SM_CXBORDER,
SM_CYBORDER   The width and height, in pixels, of a window border. This is equivalent to the SM_CXEDGE value for windows with the 3-D look.
SM_CXCURSOR,
SM_CYCURSOR   Width and height, in pixels, of a cursor. These are the cursor dimensions supported by the current display driver. The system cannot create cursors of other sizes.
SM_CXDLGFRAME,
SM_CYDLGFRAME   Same as SM_CXFIXEDFRAME and SM_CYFIXEDFRAME.
SM_CXDOUBLECLK,
SM_CYDOUBLECLK   Width and height, in pixels, of the rectangle around the location of a first click in a double-click sequence. The second click must occur within this rectangle for the system to consider the two clicks a double-click. (The two clicks must also occur within a specified time.)
SM_CXDRAG,
SM_CYDRAG   Width and height, in pixels, of a rectangle centered on a drag point to allow for limited movement of the mouse pointer before a drag operation begins. This allows the user to click and release the mouse button easily without unintentionally starting a drag operation.
SM_CXEDGE,
SM_CYEDGE   Dimensions, in pixels, of a 3-D border. These are the 3-D counterparts of SM_CXBORDER and SM_CYBORDER.
SM_CXFIXEDFRAME,
SM_CYFIXEDFRAME   Thickness, in pixels, of the frame around the perimeter of a window that has a caption but is not sizable. SM_CXFIXEDFRAME is the width of the horizontal border and SM_CYFIXEDFRAME is the height of the vertical border. Same as SM_CXDLGFRAME and SM_CYDLGFRAME.
SM_CXFRAME,
SM_CYFRAME   Same as SM_CXSIZEFRAME and SM_CYSIZEFRAME.
SM_CXFULLSCREEN, SM_CYFULLSCREEN   Width and height of the client area for a full-screen window. To get the coordinates of the portion of the screen not obscured by the tray, call the SystemParametersInfo function with the SPI_GETWORKAREA value.
SM_CXHSCROLL, SM_CYHSCROLL   Width, in pixels, of the arrow bitmap on a horizontal scroll bar; and height, in pixels, of a horizontal scroll bar.
SM_CXHTHUMB   Width, in pixels, of the thumb box in a horizontal scroll bar.
SM_CXICON,
SM_CYICON   The default width and height, in pixels, of an icon. These values are typically 32x32, but can vary depending on the installed display hardware.The LoadIcon function can only load icons of these dimensions.
SM_CXICONSPACING, SM_CYICONSPACING   Dimensions, in pixels, of a grid cell for items in large icon view. Each item fits into a rectangle of this size when arranged. These values are always greater than or equal to SM_CXICON and SM_CYICON.
SM_CXMAXIMIZED,
SM_CYMAXIMIZED   Default dimensions, in pixels, of a maximized top-level window.
SM_CXMAXTRACK,
SM_CYMAXTRACK   Default maximum dimensions, in pixels, of a window that has a caption and sizing borders. The user cannot drag the window frame to a size larger than these dimensions. A window can override these values by processing the WM_GETMINMAXINFO message.
SM_CXMENUCHECK,
SM_CYMENUCHECK   Dimensions, in pixels, of the default menu check-mark bitmap.
SM_CXMENUSIZE,
SM_CYMENUSIZE   Dimensions, in pixels, of menu bar buttons, such as multiple document (MIDI) child close.
SM_CXMIN,
SM_CYMIN   Minimum width and height, in pixels, of a window.
SM_CXMINIMIZED,
SM_CYMINIMIZED   Dimensions, in pixels, of a normal minimized window.
SM_CXMINSPACING
SM_CYMINSPACING   Dimensions, in pixels, of a grid cell for minimized windows. Each minimized window fits into a rectangle this size when arranged. These values are always greater than or equal to SM_CXMINIMIZED and SM_CYMINIMIZED.
SM_CXMINTRACK, SM_CYMINTRACK   Minimum tracking width and height, in pixels, of a window. The user cannot drag the window frame to a size smaller than these dimensions. A window can override these values by processing the WM_GETMINMAXINFO message.
SM_CXSCREEN,
SM_CYSCREEN   Width and height, in pixels, of the screen.
SM_CXSIZE,
SM_CYSIZE   Width and height, in pixels, of a button in a window's caption or title bar.
SM_CXSIZEFRAME,
SM_CYSIZEFRAME   Thickness, in pixels, of the sizing border around the perimeter of a window that can be resized. SM_CXSIZEFRAME is the width of the horizontal border and SM_CYSIZEFRAME is the height of the vertical border. Same as SM_CXFRAME and SM_CYFRAME.
SM_CXSMICON,
SM_CYSMICON   Recommended dimensions, in pixels, of a small icon. Small icons typically appear in window captions and in small icon view.
SM_CXSMSIZE
SM_CYSMSIZE   Dimensions, in pixels, of small caption buttons.
SM_CXVSCROLL, SM_CYVSCROLL   Width, in pixels, of a vertical scroll bar; and height, in pixels, of the arrow bitmap on a vertical scroll bar.
SM_CYCAPTION   Height, in pixels, of normal caption area.
SM_CYKANJIWINDOW   For double-byte character set versions of Windows, height, in pixels, of the Kanji window at the bottom of the screen.
SM_CYMENU   Height, in pixels, of single-line menu bar.
SM_CYSMCAPTION   Height, in pixels, of a small caption.
SM_CYVTHUMB   Height , in pixels, of the thumb box in a vertical scroll bar.
SM_DBCSENABLED   TRUE or nonzero if the double-byte character set (DBCS) version of USER.EXE is installed; FALSE, or zero otherwise.
SM_DEBUG   TRUE or nonzero if the debugging version of USER.EXE is installed; FALSE, or zero, otherwise.
SM_MENUDROPALIGNMENT   TRUE, or nonzero if drop-down menus are right-aligned relative to the corresponding menu-bar item; FALSE, or zero if they are left-aligned.
SM_MIDEASTENABLED   TRUE if the system is enabled for Hebrew/Arabic languages.
SM_MOUSEPRESENT   TRUE or nonzero if a mouse is installed; FALSE, or zero, otherwise.
SM_MOUSEWHEELPRESENT   Windows NT only: TRUE or nonzero if a mouse with a wheel is installed; FALSE, or zero, otherwise.
SM_NETWORK   The least significant bit is set if a network is present; otherwise, it is cleared. The other bits are reserved for future use.
SM_PENWINDOWS   TRUE or nonzero if the Microsoft Windows for Pen computing extensions are installed; zero, or FALSE, otherwise.
SM_SECURE   TRUE if security is present, FALSE otherwise.
SM_SHOWSOUNDS   TRUE or nonzero if the user requires an application to present information visually in situations where it would otherwise present the information only in audible form; FALSE, or zero, otherwise.
SM_SLOWMACHINE   TRUE if the computer has a low-end (slow) processor, FALSE otherwise.
SM_SWAPBUTTON   TRUE or nonzero if the meanings of the left and right mouse buttons are swapped; FALSE, or zero, otherwise.
 

Return Values

If the function succeeds, the return value is the requested system metric or configuration setting.
If the function fails, the return value is zero. GetLastError does not provide extended error information.

Remarks

System metrics may vary from display to display.
The SM_ARRANGE setting specifies how the system arranges minimized windows, and consists of a starting position and a direction. The starting position can be one of the following values.

Value   Meaning
ARW_BOTTOMLEFT   Start at lower-left corner of screen (default position).
ARW_BOTTOMRIGHT   Start at lower-right corner of screen. Equivalent to ARW_STARTRIGHT.
ARW_HIDE   Hide minimized windows by moving them off of the visible area of the screen.
ARW_TOPLEFT   Start at upper-left corner of screen. Equivalent to ARV_STARTTOP.
ARW_TOPRIGHT   Start at upper-right corner of screen. Equivalent to ARW_STARTTOP | SRW_STARTRIGHT.
 

The direction in which to arrange can be one of the following values.

Value   Meaning
ARW_DOWN   Arrange vertically, top to bottom.
ARW_LEFT   Arrange horizontally, left to right.
ARW_RIGHT   Arrange horizontally, right to left.
ARW_UP   Arrange vertically, bottom to top.
 
« Последнее редактирование: 20-12-2007 18:01 от Алексей1153++ » Записан

Не будите спашяго дракона.
             Джаффар (Коша)
Malaja
Команда клуба

de
Offline Offline
Пол: Женский

« Ответ #11 : 16-03-2005 13:59 » 

Finch,

спасибочки! Ага
Записан

холоднокровней, Маня, Ви не на работе
---------------------------------------
четкое определение сущности бытия:
- А мы в прошлом или в будущем?- спросила Алиса.
- Мы в жопе, - ответил кролик.
- А "жопа" - это настоящее? - спросила Алиса.
- А "жопа" - это у нас символ вечности.
Malaja
Команда клуба

de
Offline Offline
Пол: Женский

« Ответ #12 : 17-03-2005 13:08 » 

Люди, опять караул, но с другой стороны : опять же есть MDI, т.е. MainFrame снаружи и View внутри. Сверху еще болтается немодальный диалог.
Мне надо при изменении размеров Frame-a (т.е. самого внешнего окна) изменять размеры View таким образом, чтобы окно View всегда было в пределах окна Frame. Попыталась сделать так :

Код:
void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect) 
{
CMDIFrameWnd::OnSizing(fwSide, pRect);

CRect rect1, rect2, rect3;
int nWidth1, nHight1, nWidth2, nHight2;

CTest_visuView* pView = NULL; 

getView(&pView);
if (pView)
{
// view
pView->GetClientRect(&rect1);
nWidth1 = rect1.Width();
nHight1 = rect1.Height();

// the main frame
this->GetClientRect(&rect2);
nWidth2 = rect2.Width();
nHight2 = rect2.Height();

if (nWidth1 < nWidth2 && nHight1 < nHight2)
{
return;
}

int nTBp = 0, nFS_Xp = 0, nFS_Yp = 0, nMS_Yp = 0;

// width of the title bar
nTBp = GetSystemMetrics(SM_CYCAPTION);
// Thickness, in pixels, of the sizing border around the perimeter of a
                                // window that can be resized.
nFS_Xp = GetSystemMetrics(SM_CXFRAME);
nFS_Yp = GetSystemMetrics(SM_CYFRAME);
// width of the menu bar
nMS_Yp = GetSystemMetrics(SM_CYMENUSIZE);

// resize the view
pView->SetWindowPos(&wndNoTopMost, rect1.left, rect1.top,
                                                nWidth2,nHight2,
SWP_DEFERERASE | SWP_DRAWFRAME |
                                       SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOMOVE);
//
// pView->MoveWindow(rect1.left, rect1.top, nWidth2 - 2 * nFS_Yp,
//   nHight2 - nTBp - nMS_Yp - 2 * nFS_Xp, TRUE);
pView->Invalidate();
Invalidate();
}
}


Не помогает ;-( Т.е. размеры окна View, судя по всему, меняются (видно из debuga), но чисто визуально не меняется ничего... А почему - не пойму, ведь Paint явно вызывается, во-первых, с помощью Invalidate, а во-вторых, флагом SWP_DRAWFRAME | SWP_FRAMECHANGED!
Записан

холоднокровней, Маня, Ви не на работе
---------------------------------------
четкое определение сущности бытия:
- А мы в прошлом или в будущем?- спросила Алиса.
- Мы в жопе, - ответил кролик.
- А "жопа" - это настоящее? - спросила Алиса.
- А "жопа" - это у нас символ вечности.
Finch
Спокойный
Администратор

il
Offline Offline
Пол: Мужской
Пролетал мимо


« Ответ #13 : 17-03-2005 13:33 » 

Цитата
  pView->SetWindowPos(&wndNoTopMost, rect1.left, rect1.top,
                                                nWidth2,nHight2,
SWP_DEFERERASE | SWP_DRAWFRAME |
                                       SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOMOVE);
Сразу предупрежу, Я не знаком с MFC.
Поэтому первое: Что есть такое wndNoTopMost и почему в функцию посылается его указатель. Если это подрузомевался параметр HWND hWndInsertAfter. То можно смело ставить NULL. Так как он должен игнорироваться согласно
Цитата
SWP_NOZORDER   Retains the current Z order (ignores the hWndInsertAfter parameter).
Ну и второе: заместо rect1.left, rect1.top можно просто указать нули, так как эти параметры игнорируются
Цитата
SWP_NOMOVE   Retains the current position (ignores the X and Y parameters).
Записан

Не будите спашяго дракона.
             Джаффар (Коша)
Malaja
Команда клуба

de
Offline Offline
Пол: Женский

« Ответ #14 : 17-03-2005 13:57 » 

Finch,

это были остатки предыдущих попыток Ага Но проблемы это, к сожалению, не решает...
Записан

холоднокровней, Маня, Ви не на работе
---------------------------------------
четкое определение сущности бытия:
- А мы в прошлом или в будущем?- спросила Алиса.
- Мы в жопе, - ответил кролик.
- А "жопа" - это настоящее? - спросила Алиса.
- А "жопа" - это у нас символ вечности.
Finch
Спокойный
Администратор

il
Offline Offline
Пол: Мужской
Пролетал мимо


« Ответ #15 : 17-03-2005 14:16 » 

Где то теряется посылка на обновление окна. Вот где. Нужно искать.
Есть пара коментариев:
1. Ты где либо запретила обновление окна.
2. У сообшения на обновление (WM_PAINT) есть два свойства.
   а) Это сообшение имеет очень низкий приоритет т.е. выполняется в самую последнюю очередь.
   б) Функции BeginPaint, EndPaint Которые обычно ставятся в обработчике сообшения WM_PAINT. Убивают все остальные сообшения WM_PAINT в очереди.
3. Посмотри в дебаге. Может быть твои попытки на изменение размеров провалились. Поля размеров остались прежними.
« Последнее редактирование: 17-03-2005 14:23 от Finch » Записан

Не будите спашяго дракона.
             Джаффар (Коша)
Malaja
Команда клуба

de
Offline Offline
Пол: Женский

« Ответ #16 : 17-03-2005 14:36 » 

да я с самого начала посмотрела - поменялись, но не перерисовались ;-(
Записан

холоднокровней, Маня, Ви не на работе
---------------------------------------
четкое определение сущности бытия:
- А мы в прошлом или в будущем?- спросила Алиса.
- Мы в жопе, - ответил кролик.
- А "жопа" - это настоящее? - спросила Алиса.
- А "жопа" - это у нас символ вечности.
Finch
Спокойный
Администратор

il
Offline Offline
Пол: Мужской
Пролетал мимо


« Ответ #17 : 17-03-2005 14:39 » 

В MFC не знаю, в Borland VCL сам факт изменения координат, уже вел к отрисовке, насколько я знаю.
Записан

Не будите спашяго дракона.
             Джаффар (Коша)
Finch
Спокойный
Администратор

il
Offline Offline
Пол: Мужской
Пролетал мимо


« Ответ #18 : 17-03-2005 15:31 » 

Цитата
pView->Invalidate();
Invalidate();
Да кстати, Если pView является дочерним окном. То в принципе должно быть достаточно вызова на прорисовку родительского окна. И оно само автоматом даст команду на прорисовку всем дочерним окнам.
Записан

Не будите спашяго дракона.
             Джаффар (Коша)
Finch
Спокойный
Администратор

il
Offline Offline
Пол: Мужской
Пролетал мимо


« Ответ #19 : 17-03-2005 15:35 » 

Вот еше нашел
Цитата
The WM_SIZE message is sent to a window after its size has changed.

WM_SIZE 
fwSizeType = wParam;      // resizing flag
nWidth = LOWORD(lParam);  // width of client area
nHeight = HIWORD(lParam); // height of client area
 

Parameters

fwSizeType

Value of wParam. Specifies the type of resizing requested. This parameter can be one of the following values:

Value   Meaning
SIZE_MAXHIDE   Message is sent to all pop-up windows when some other window is maximized.
SIZE_MAXIMIZED   Window has been maximized.
SIZE_MAXSHOW   Message is sent to all pop-up windows when some other window has been restored to its former size.
SIZE_MINIMIZED   Window has been minimized.
SIZE_RESTORED   Window has been resized, but neither the SIZE_MINIMIZED nor SIZE_MAXIMIZED value applies.
 

nWidth

Value of the low-order word of lParam. Specifies the new width of the client area.

nHeight

Value of the high-order word of lParam. Specifies the new height of the client area.

 

Return Values

If an application processes this message, it should return zero.

Remarks

If the SetScrollPos or MoveWindow function is called for a child window as a result of the WM_SIZE message, the bRedraw parameter should be nonzero to cause the window to be repainted.
Although the width and height of a window are 32-bit values, the nWidth and nHeight parameters of the WM_SIZE message contain only the low-order 16 bits.
В нашем случае интересен выделенный абзац. Ненадо давать на прорисовку. Просто надо "bRedraw parameter should be nonzero"
Записан

Не будите спашяго дракона.
             Джаффар (Коша)
Hooter
Опытный

ru
Offline Offline
Пол: Мужской

« Ответ #20 : 17-03-2005 20:37 » 

Код:
void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect) 

А почему ты говоришь об обработке сообщения WM_SIZE, а используешь OnSizing?
OnSizing - это обработчик сообщения WM_SIZING в MFC
Код:
afx_msg void OnSizing(UINT nSide, LPRECT lpRect);

Обработчик WM_SIZE вообще другой вид имеет:
Код:
afx_msg void OnSize(UINT nType, int cx, int cy);

Имхо, ты просто не туда ткнула в ClassWizard'е  Улыбаюсь
Для решения твоей задачи тебе именно OnSize нужно использовать.
Вот пример кода из MSDN:
Код:
// Resize the list control contained in the view to
// fill the entire view when the view's window is
// resized. CMyView is a CView derived class.
void CMyView::OnSize(UINT nType, int cx, int cy)
{
   CView::OnSize(nType, cx, cy);
   // Resize list to fill the whole view.
   m_List.MoveWindow (0, 0, cx, cy);
}
И работает без Paint или Invalidate.
« Последнее редактирование: 20-12-2007 18:05 от Алексей1153++ » Записан
Malaja
Команда клуба

de
Offline Offline
Пол: Женский

« Ответ #21 : 18-03-2005 07:46 » 

Finch, Hooter,

Я взяла WM_SIZING для более плавной перерисовки картинки (т.к. у меня еще сверху на всем этом немодальный диалог болтается, который должен всегда находиться в правом верхнем углу View).
Проблема заключается в том, что вне зависимости от обработчика (WM_SIZING или WM_SIZЕ) и функции ( MoveWindow(..., TRUE) или SetWindowPos ) размеры View меняются, но его перерисовка не происходит, т.е. визуально он остается все время одного размера.
Записан

холоднокровней, Маня, Ви не на работе
---------------------------------------
четкое определение сущности бытия:
- А мы в прошлом или в будущем?- спросила Алиса.
- Мы в жопе, - ответил кролик.
- А "жопа" - это настоящее? - спросила Алиса.
- А "жопа" - это у нас символ вечности.
Hooter
Опытный

ru
Offline Offline
Пол: Мужской

« Ответ #22 : 18-03-2005 23:09 » 

Слушай, а зачем тебе вот это условие?
Код:
		if (nWidth1 < nWidth2 && nHight1 < nHight2)
{
return;
}

Если у тебя View меньше, чем мейнфрейм или развернут на весь мейнфрейм, то условие всегда истинно. И код, который после условия - там, где ты пытаешься резмеры изменить - не выполняется.
Я вот сгенерил приложеньце и вставил твой код. Не работало. Убрал условие - все нормально стало. Здесь была моя ладья...
Или я что-то не понял в твоем коде?
Записан
Malaja
Команда клуба

de
Offline Offline
Пол: Женский

« Ответ #23 : 21-03-2005 08:24 » 

Hooter,

согласна - условие можно убрать. Но и при этом перерисовка не происходит, т.е. при старте изначально View меньше MainFrame, если я тяну контур MainFrame, то ничего не меняется, хотя я и меняю размер View. Xотя я ожидаю, что при первом же изменении размера MainFrameразмер View будет изменен (согласно кода в обработчике OnSize()).
Записан

холоднокровней, Маня, Ви не на работе
---------------------------------------
четкое определение сущности бытия:
- А мы в прошлом или в будущем?- спросила Алиса.
- Мы в жопе, - ответил кролик.
- А "жопа" - это настоящее? - спросила Алиса.
- А "жопа" - это у нас символ вечности.
Hooter
Опытный

ru
Offline Offline
Пол: Мужской

« Ответ #24 : 21-03-2005 18:49 » 

Тогда давай попробуем "плясать от печки", как говорится... Ага

Попробуй убрать всё в OnSizing, оставь только минимум кода.
И никаких относительных координат для View - при создании View сделай ему RECT{0, 0, 0, 0}, а в OnSizing задай размеры жестко.
Например, так:
Код:
void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect) 
{
    CMDIFrameWnd::OnSizing(fwSide, pRect);
    getView(&pView);
    if (pView)
    {
        pView->MoveWindow(0, 0, 1024, 1024);
    }
}

Посмотрим, что получится...
Записан
Malaja
Команда клуба

de
Offline Offline
Пол: Женский

« Ответ #25 : 22-03-2005 08:39 » 

Hooter,

пробовала - не спасает ;-( Ситуация какая-то бредовая - если тянешь сам View, то resize срабатывает правильно и область перерисовывается. Если же тянешь MainFrame, то resize срабатывает правильно, но область View НЕ перерисовывается, а точнее перерисовывается только та область, которая не больше изначально при старте нарисованной. Если же новая область меньше изначально нарисованной, то только эта новая и перерисовывается, а остальное - нет...
А почему - не пойму!!! Ведь View получает свой OnSize!
Записан

холоднокровней, Маня, Ви не на работе
---------------------------------------
четкое определение сущности бытия:
- А мы в прошлом или в будущем?- спросила Алиса.
- Мы в жопе, - ответил кролик.
- А "жопа" - это настоящее? - спросила Алиса.
- А "жопа" - это у нас символ вечности.
Джон
просто
Администратор

de
Offline Offline
Пол: Мужской

« Ответ #26 : 22-03-2005 08:55 » 

Malaja, я просмотрел топики и понял, что ничего не понял. Например как View может быть меньше MianFrame? Он вообще безразмерный - те заполняет всегда клиентскую область. Самое идеальное - если у тебя есть тестовый проектик - кинь на мыло.
Записан

Я вам что? Дурак? По выходным и праздникам на работе работать. По выходным и праздникам я работаю дома.
"Just because the language allows you to do something does not mean that it’s the correct thing to do." Trey Nash
"Physics is like sex: sure, it may give some practical results, but that's not why we do it." Richard P. Feynman
"All science is either physics or stamp collecting." Ernest Rutherford
"Wer will, findet Wege, wer nicht will, findet Gründe."
Malaja
Команда клуба

de
Offline Offline
Пол: Женский

« Ответ #27 : 22-03-2005 09:10 » 

Dgon, spasibochki - uge skinula!
Записан

холоднокровней, Маня, Ви не на работе
---------------------------------------
четкое определение сущности бытия:
- А мы в прошлом или в будущем?- спросила Алиса.
- Мы в жопе, - ответил кролик.
- А "жопа" - это настоящее? - спросила Алиса.
- А "жопа" - это у нас символ вечности.
Джон
просто
Администратор

de
Offline Offline
Пол: Мужской

« Ответ #28 : 22-03-2005 13:58 » 

В общем как я и думал... Речь идёт о MDI под изменением View наверно понимается изменение размеров CChildFrame.
В CMainFrame достаточно реагировать на WM_MOVE, обычно все ing-овые означают процесс, непосредственное действие (проще говоря начало действия, а не конечный результат)
WM_SIZE отлавливается в самом View, что она и сделала. Недостаёт только перемещений CChldFrame в пределах клиенской области CMainFrame.

Malaja, не удержался (может ещё кому-нить будет полезно):

bool CTest_visuView::moveDlg()
{
   CRect rect1, rect2;
   GetClientRect(&rect1);
   ClientToScreen(&rect1);
   if(rect1.Width()!=0 && rect1.Height()!=0)
   {
      m_pClockShow->GetWindowRect(&rect2);
      m_pClockShow->MoveWindow(rect1.right - rect2.Width(),
                         rect1.top, rect2.Width(), rect2.Height(), TRUE);
      return true;
   }
   return false;
}

В CChildFrame добавь:
1. #include "test_visuDoc.h"  в .срр
2. #include "test_visuView.h" в .срр
3.  ON_WM_MOVE()
4.

void CChildFrame::OnMove(int x, int y)
{
   CMDIChildWnd::OnMove(x, y);
   CView *pView = GetActiveView();
   if(pView)
   {
      ((CTest_visuView*)pView)->moveDlg();
   }
}

CMainFrame

1. OnSize можешь выкинуть - непонятно зачем оно вообще нужно?
2. OnMoving можешь выкинуть
3. View можно проще достать,вернее говоря твоя ф-я

CView* CTest_visuApp::getView()
{
   POSITION pos = this->GetFirstDocTemplatePosition();
   CDocTemplate* templ =  this->GetNextDocTemplate(pos);      
   POSITION posD = templ->GetFirstDocPosition();
   CDocument* docTmp = templ->GetNextDoc(posD);
   POSITION posV = docTmp->GetFirstViewPosition();
   CView* pView = docTmp->GetNextView(posV);
   return pView;
}

возвращает ТОЛЬКО первый View ТОЛЬКО первого документа, а если это не первый? тогда как? обычно для иттераций необходимо доп. условие поиска, тогда ты бежишь по всем въю всех документов пока не найдёшь нужный)

View активного документа (именно его ты перемещаешь и видишь)
CView *CMainFrame::GetActiveView()
{
   CMDIChildWnd *pChild = (CMDIChildWnd*)GetActiveFrame();
   if(pChild && pChild->IsKindOf(RUNTIME_CLASS(CChildFrame)))
   {
      return ((CChildFrame*)pChild)->GetActiveView();
   }
   return NULL;
}

4. Вместо ON_WM_MOVING используй ON_WM_MOVE

void CMainFrame::OnMove(int x, int y)
{
   CMDIFrameWnd::OnMove(x,y);
   CView *pView = GetActiveView();
   if (pView)
   {
      ((CTest_visuView*)pView)->moveDlg();
   }
}

5. Вместо (CTest_visuApp*)AfxGetApp() проще использовать theApp

В общем изменённый проект я тебе на мыло кину. Только я не уверен, что ты именно этого хотела - я имею ввиду привязку диалога к View. Но тут уже действует логика технического задания.
« Последнее редактирование: 22-03-2005 14:08 от Джон » Записан

Я вам что? Дурак? По выходным и праздникам на работе работать. По выходным и праздникам я работаю дома.
"Just because the language allows you to do something does not mean that it’s the correct thing to do." Trey Nash
"Physics is like sex: sure, it may give some practical results, but that's not why we do it." Richard P. Feynman
"All science is either physics or stamp collecting." Ernest Rutherford
"Wer will, findet Wege, wer nicht will, findet Gründe."
Страниц: [1]   Вверх
  Печать  
 

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines