Question

Cela devrait être simple:

J'ai un CDialog avec 2 boutons. La boîte de dialogue est toujours ouvert en plein écran (Pas barre de titre \ Etat, etc ...) en utilisant m_pMainWnd->ShowWindow(SW_MAXIMIZE);

Je veux que mes boutons pour se calent sur le bord de l'écran.

Il n'y a pas Redimensionnement ou quoi que ce soit.

Était-ce utile?

La solution

Vous savez que la largeur de la boîte de dialogue (GetClientRect). Vous connaissez la largeur des boutons.

En supposant que vous Magnétisme sur le bord droit ...

Dans votre 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 );
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top