TRUCS ET ASTUCES


AFFICHER DU TEXTE SUR LE BACK BUFFER:


BOOL DDrawTextout(int xout, int yout,BYTE r,BYTE v,BYTE b, const char *txout)
{
if (BackBuffer->GetDC(&hdc) == DD_OK)
{
SetBkMode(hdc, OPAQUE); //TRANSPARENT
SetBkColor(hdc,RGB(0,0,0));
SetTextColor(hdc, RGB(r,v,b));
TextOut(hdc, xout, yout, txout, strlen(txout));
BackBuffer->ReleaseDC(hdc);
return TRUE;
}
return FALSE;
}

Les coordonnees x et y correspondent a xout,yout. La couleur de la police a r, v et b et le texte a *txout..
Si vous voulez un fond transparent de texte, remplacez OPAQUE par TRANSPARENT.
La couleur de fond si mode OPAQUE est definie par la methode SetBkColor(hdc,RGB(0,0,0)).


AFFICHER/CACHER LA SOURIS

case IDM_EXIT: //Menu Quitter
ShowCursor(TRUE); //Reaffiche la souris
DestroyWindow(hWnd);
break;
//
//
//
//
//
if (!hWnd)
{
MessageBox(NULL,"Erreur création de la fenêtre","Totalwar",MB_OK);
return FALSE;
}

ShowWindow(hWnd,nCmdShow);
ShowCursor(FALSE);

Dans le corps du squelette d'application, il suffit de rajouter la ligne ShowCursor(TRUE) afin de reafficher la souris en sortie d'application ( Fonction WinProc) et ShowCursor(FALSE) dans la Fonction WinMain.