Problème : déclaration variable globale HBRUSH

unlimited72 Messages postés 13 Date d'inscription jeudi 24 novembre 2005 Statut Membre Dernière intervention 19 août 2008 - 18 juil. 2008 à 11:08
Original72 Messages postés 2 Date d'inscription vendredi 27 avril 2007 Statut Membre Dernière intervention 18 juillet 2008 - 18 juil. 2008 à 22:52
Bonjour à tous voila je veux déclarer en global des brush pour définir les couleurs de mon texte de mon fond d'appli pour ne pas créer dans chaque méthode createSolideBrush(COLOREF).

J'ai donc déclarer en globale :

COLORREF color_rouge = RGB(255,0,0);
COLORREF color_blanc = RGB(255,255,255);
COLORREF color_bleupastel = RGB(224,224,255);
COLORREF color_vert = RGB(0,255,0);
COLORREF color_bleu = RGB(0,0,255);
COLORREF color_noir = RGB(0,0,0);
COLORREF color_vertpastel = RGB(224,255,224);
COLORREF color_gris = RGB(192,192,192);

HBRUSH CreateSolidBrush(color_rouge);
HBRUSH brush_blanc = CreateSolidBrush(color_blanc);
HBRUSH brush_bleupastel = CreateSolidBrush(color_bleupastel);
HBRUSH brush_vert = CreateSolidBrush(color_vert);
HBRUSH brush_bleu = CreateSolidBrush(color_bleu);
HBRUSH brush_noir = CreateSolidBrush(color_noir);
HBRUSH brush_vertpastel = CreateSolidBrush(color_vertpastel);
HBRUSH brush_gris = CreateSolidBrush(color_gris);

lors de la compilation j'ai une erreur sur les HBRUSH : "initializer element is not constant"

???

Que dois-je faire svp ??

4 réponses

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
18 juil. 2008 à 11:45
VARIABLES GLOBALES:
HBRUSH brush_blanc;
HBRUSH brush_bleupastel;
HBRUSH brush_vert;
HBRUSH brush_bleu;
HBRUSH brush_noir;
HBRUSH brush_vertpastel;
HBRUSH brush_gris;


DANS WinMain (au début avant leur utilisation):
brush_blanc = CreateSolidBrush(color_blanc);
brush_bleupastel = CreateSolidBrush(color_bleupastel);
brush_vert = CreateSolidBrush(color_vert);
brush_bleu = CreateSolidBrush(color_bleu);
brush_noir = CreateSolidBrush(color_noir);
brush_vertpastel = CreateSolidBrush(color_vertpastel);
brush_gris = CreateSolidBrush(color_gris);

ciao...
BruNews, MVP VC++
0
unlimited72 Messages postés 13 Date d'inscription jeudi 24 novembre 2005 Statut Membre Dernière intervention 19 août 2008
18 juil. 2008 à 12:07
Merci,

ça marche nickel, mais en fait je comprend pas trop pourquoi il ma jeter comme ça !!
0
vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
18 juil. 2008 à 20:27
Tu ne peux tout simplement pas appeler une fonction en dehors d'une fonction.
Tu peux en revanche appeler RGB car c'est une macro et non une fonction.

_____________________________________
Un éditeur de ressources gratuit pour Windows
0
Original72 Messages postés 2 Date d'inscription vendredi 27 avril 2007 Statut Membre Dernière intervention 18 juillet 2008
18 juil. 2008 à 22:52
Ok, je vous remercie pour votre aide..
0
Rejoignez-nous