// variables globales int posrelX = 0; int posrelY = 0; ... LRESULT CALLBACK MainDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: { RECT Window; RECT ButPos; GetWindowRect(GetDlgItem(hDlg,IDOK), &ButPos); GetWindowRect(hDlg, &Window); posrelX = Window.right - ButPos.left; posrelY = Window.bottom - ButPos.top; return 1; } case WM_SIZE: { switch(wParam) { case SIZE_MAXIMIZED:case SIZE_RESTORED: { RECT Window; RECT ButPos; GetWindowRect(GetDlgItem(hDlg,IDOK), &ButPos); int iLongueur = ButPos.right - ButPos.left; int iHauteur = ButPos.bottom - ButPos.top; GetClientRect(hDlg,&Window); MoveWindow(GetDlgItem(hDlg,IDOK), Window.right-posrelX+4, Window.bottom+4-posrelY, iLongueur, iHauteur, TRUE); break; } } }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questioncase WM_SIZE: { switch(wParam) { case SIZE_MAXIMIZED:case SIZE_RESTORED: { RECT ButPos; GetClientRect(GetDlgItem(hDlg,IDOK), &ButPos); int iLongueur = ButPos.right - ButPos.left; int iHauteur = ButPos.bottom - ButPos.top; int cx = LOWORD(lParam); int cy = HIWORD(lParam); MoveWindow(GetDlgItem(hDlg,IDOK),cx-posrelX+4,cy-posrelY+4,iLongueur,iHauteur,TRUE); break; }