Pregunta

Esto debería ser muy simple:

Tengo un CDialog con 2 botones. El diálogo siempre se abre en pantalla completa (No hay barra de título \ Estado, etc ...) utilizando m_pMainWnd->ShowWindow(SW_MAXIMIZE);

Quiero que mis botones se encajen a presión hasta el borde de la pantalla.

No hay cambio de tamaño o nada.

¿Fue útil?

Solución

Usted sabe que el ancho del cuadro de diálogo (GetClientRect). Usted sabe que el ancho de los botones.

Suponiendo que está alineando el borde derecho ...

Dentro de su CDialog :: OnSize:

 // Grab the CDialog's rect.
 CRect winRect;
 GetClientRect( &winRect );

 // Grab the button's rect.
 CRect buttonRect;
 button.GetClientRect( &buttonRect );

 // Now we need to set the top, left of the button to the right edge - the button width.
 // The y position will remain the same.
 button.SetWindowPos( NULL, winRect.right - buttonRect.Width(), buttonRect.top, 0, 0, SWP_NOZORDER | SWP_NOMOVE );
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top