Originariamente inviato da Il Pazzo
Niente... sempre lo sfondo bianco.... forse manca qualche linea di codice prima?
Non so che dirti .... il seguente codice (che poi è quello che posto sempre in questi casi ) funziona perfettamente e mostra la finestra con lo stesso colore di sfondo delle dialog-box.
codice:
#define STRICT
#include <windows.h>
#define MAIN_WNDCLASS "MiaClasseFinestra"
LRESULT CALLBACK Main_WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_CREATE:
return 0;
case WM_DESTROY:
PostQuitMessage (0);
return 0;
case WM_CLOSE:
DestroyWindow (hWnd);
return 0;
}
return DefWindowProc (hWnd, uMsg, wParam, lParam);
}
INT APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevious, LPSTR lpszCmdLine, INT iCmdShow)
{
WNDCLASSEX wcx;
HWND hWnd;
MSG msg;
wcx.cbSize = sizeof (wcx);
wcx.style = CS_HREDRAW | CS_VREDRAW;
wcx.lpfnWndProc = (WNDPROC) Main_WndProc;
wcx.cbClsExtra = 0;
wcx.cbWndExtra = 0;
wcx.hInstance = hInstance;
wcx.hIcon = NULL;
wcx.hIconSm = NULL;
wcx.hCursor = LoadCursor (NULL, IDC_ARROW);
wcx.hbrBackground = (HBRUSH) (COLOR_3DFACE+1);
wcx.lpszMenuName = NULL;
wcx.lpszClassName = MAIN_WNDCLASS;
if (!RegisterClassEx (&wcx))
{
MessageBox (NULL, "Errore nella registrazione della classe",
"ERRORE", MB_OK | MB_ICONEXCLAMATION);
return 1;
}
hWnd = CreateWindow (MAIN_WNDCLASS, "Titolo finestra", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, 300, 300,
NULL, NULL, hInstance, NULL);
if (hWnd == NULL)
{
MessageBox (NULL, "Errore nella creazione della finestra",
"ERRORE", MB_OK | MB_ICONEXCLAMATION);
return 1;
}
ShowWindow (hWnd, SW_SHOWNORMAL);
UpdateWindow (hWnd);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return 0;
}