fredsor
Messages postés198Date d'inscriptionlundi 24 avril 2006StatutMembreDernière intervention 3 avril 2008
-
8 nov. 2007 à 16:56
fredsor
Messages postés198Date d'inscriptionlundi 24 avril 2006StatutMembreDernière intervention 3 avril 2008
-
16 nov. 2007 à 09:45
Salu a vous,
Je créé une appli win32 sous devc++ en C.
Je créé la fenetre avec CreateWindow, et j'aimerais que le fond soit blanc. Or l'appli se met désespérément avec son fond gris tout terne. Pourtant je spécifie bien mon objet dans ma WNDCLASS :
char szClassName[ ] = "GV3 Mobile";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil){
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
hinst=hThisInstance;
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = (WNDPROC) WndProc; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"GV3 Mobile", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
500, /* The programs width */
600, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
UpdateWindow(hwnd);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{ /* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages); }
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;}
J'ai essayé également des méthodes trouvés sur cppfrance avec ERASEBKGROUND, sans succès
Voyez vous ce qui ne va pas?
fredsor
Messages postés198Date d'inscriptionlundi 24 avril 2006StatutMembreDernière intervention 3 avril 2008 16 nov. 2007 à 09:45
Youpi!!
En créant un deuxieme projet vide, j'avais bien une fenetre blanche, j'ai donc rajouté petit a petit les éléments de mon projet existant pour voir que... j'avais un WM_PAINT dans ma WindowProcedure principale, qui ne me servait a rien, sauf a m'empecher d'avoir le fond bland!! ;)
cs_juju12
Messages postés966Date d'inscriptionsamedi 3 avril 2004StatutMembreDernière intervention 4 mars 20104 8 nov. 2007 à 17:17
Au risque de te faire t'arracher les cheveux, chez moi, ca marche parfaitement (Visual C++ Express 2005) sans changer une ligne.
Essaie voir en créant un brush blanc(CreateSolidBrush(0xFFFFFF)) toi-même...
fredsor
Messages postés198Date d'inscriptionlundi 24 avril 2006StatutMembreDernière intervention 3 avril 2008 8 nov. 2007 à 18:12
Merci a vous, en effet j'ai plus de cheveux là! lol
Avec vos dexu exemples ca ne fonctionne pas meixu, voici la tete de mon ecran si l'image fonctionne :
Ouhh comme ce gris m'exaspere!!
A noter : que le blanc que l'on voit est dû au WM_CTLCOLOREDIT que je fais sur mes EDIT, et au CTLCOLORSTATIC fais sur les labels...
Vous n’avez pas trouvé la réponse que vous recherchez ?
et dans le WndMain :
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = (WNDPROC) WndProc; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
....
fredsor
Messages postés198Date d'inscriptionlundi 24 avril 2006StatutMembreDernière intervention 3 avril 2008 12 nov. 2007 à 11:41
RE a tous,
voici mon fichier "Affichage.c", enfin surtout sa structure. J'ai "vidé" plein de choses comme vous le constater, pour ne pas que ce soit trop lourd.
Peut etre que ca va deja vous donner une indication... :
#include <windows.h>
#include "Description.h"
#include "Parsing.h"
#include "Affichage.h"
#include "Connexion.h"
case WM_TIMER:
{
switch (wParam)
{
case IDT_TIMER: {
...
}
break;
}
break;
}
case WM_KEYUP:
{
GererKeyUp(hWnd,message,wParam,lParam);
break;
}
case WM_CTLCOLOREDIT://Dessin du contrôle EDIT
{
int i;
for(i=0;i<GetNombreComposant();i++)
{
if (((HWND)lParam==hEdit[i]))
{
SetTextColor((HDC)wParam,couleurTexte[i]);
SetBkColor((HDC)wParam,couleurFondTexte[i]);
return (BOOL) couleurFond[i];
}
}
return 0;
}
case WM_CTLCOLORSTATIC://Dessin des controles "static"
{
int i;
for(i=0;i<GetNombreComposant();i++)
{
if (((HWND)lParam==hLib[i]))
{
SetTextColor((HDC)wParam,couleurTexte[i]);
SetBkColor((HDC)wParam,couleurFondTexte[i]);
return (BOOL) couleurFond[i];
}
}
// permet de mettre en gris les entetes de tableaux...
SetTextColor((HDC)wParam,RGB(0,0,0)); // texte noir
SetBkColor((HDC)wParam,RGB(192,192,192)); // fond texte gris
return (LONG) CreateSolidBrush(RGB(192,192,192)); // fond gris
}
case WM_CTLCOLORLISTBOX://Dessin des tableaux listbox
{
int i;
for(i=0;i<GetNombreComposant();i++)
{
if ((HWND)lParam==hTab[i])
{
SetTextColor((HDC)wParam,couleurTexte[i]);
SetBkColor((HDC)wParam,couleurFondTexte[i]);
return (BOOL) couleurFond[i];
}
}
return 0;
}
case WM_CTLCOLORBTN://Dessin des boutons
{
int i;
for(i=0;i<GetNombreComposant();i++)
{
if (((HWND)lParam==hBtn[i]))
{
SetTextColor((HDC)wParam,couleurTexte[i]);
SetBkColor((HDC)wParam,couleurFondTexte[i]);
return (BOOL) couleurFond[i];
}
}
return 0;
}
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
switch (wmId)
{
case ID_BUTTON: // en cas d'action sur un bouton
{
...
}
}
break;
case WM_USER:
{
...
}
case WM_CREATE:
{
...
}
break;
case WM_PAINT:
{
RECT rt;
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rt);
FillRect(hdc, &rt, (HBRUSH) (1));
EndPaint(hWnd, &ps);
break;
}
case WM_DESTROY:
DestroyWindow(hWnd); // destruction de la fenetre
PostQuitMessage(0); // exit
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
break;
}
return 0;
}
char szClassName[ ] = "GV3 Mobile";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
char** tableau=NULL;
LancerParsing(tableau);
hinst=hThisInstance;
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = (WNDPROC) WndProc; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"GV3 Mobile", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
500, /* The programs width */
600, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
UpdateWindow(hwnd);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
Bon courage a ceux qui sont motivés pour le lire, et encore merci!
fredsor
Messages postés198Date d'inscriptionlundi 24 avril 2006StatutMembreDernière intervention 3 avril 2008 13 nov. 2007 à 21:09
Euh je t'aouve là Darunia que tu me pose une colle...
je suppose qu'ils sont définis automatiquement, a partir du moment ou je créé un projet vide Appli Win32 Windows?