Bonjour,
afin de me familiariser avec les coordonnées, j'essaie de faire une petite fonction qui centre une fenetre par raport a une autre mais ça a pas l'air de coller au niveau des coordonnées Horizontales
Quelqu'un peut il me dire ce qui ne colle pas ...
Merci d'avance.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
void CenterWindow(HWND hsmall, HWND hbig) 
{ 
static RECT rectS; 
static RECT rectB;
POINT ptS;
POINT ptB;
static int Larg, Haut;
char tmp1[5];
char tmp2[5];

  
  if (hbig == NULL) {
    GetWindowRect(hsmall,&rectS);
    SetWindowPos(hsmall,NULL,(GetSystemMetrics(SM_CXSCREEN)-rectS.right)/2,(GetSystemMetrics(SM_CYSCREEN)-rectS.bottom)/2,0, 0,SWP_NOSIZE); 
  }
  else {
    GetWindowRect(hsmall,&rectS);
	ptS.x = rectS.left;
	ptS.y = rectS.top;
	ScreenToClient (hsmall, &ptS);
    GetClientRect(hbig,&rectB);
    Larg = (UINT)(rectB.right-rectB.left);
    Haut = (UINT)(rectB.bottom-rectB.top);
    SetWindowPos(hsmall,NULL,(Larg-ptS.x)/2,(Haut-ptS.y)/2,0, 0,SWP_NOSIZE); 
  }
}