Bonsoir à tous,
j'ai beaucoup cherché (en particulier sur le site de microsoft) comment mettre une image comme fond d'écran d'une fenêtre créée avec l'api windows, mais je ne dois pas avoir très bien compris parce que avec le code que j'ai créé je n'arrive même pas à charger l'image via loadimage (la valeur de retour de la fonction est NULL) et encore moins à l'afficher en fond d'écran du coup !
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <windows.h>
const int nScreenWidth=GetSystemMetrics(SM_CXSCREEN), nScreenHeight=GetSystemMetrics(SM_CYSCREEN);
 
LRESULT WINAPI MelterProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	switch(Msg){
		case WM_CREATE:
			{
				ShowWindow(hWnd, SW_SHOW);
				HBITMAP hImage = (HBITMAP)LoadImage(NULL, (LPCSTR)"fond.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
				HWND hImageView = CreateWindowEx(NULL, (LPCSTR)"STATIC", NULL, SS_BITMAP | WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, hWnd, NULL, GetModuleHandle(NULL), NULL);
                SendMessage(hImageView, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hImage);
                return 0;
			}
                case WM_PAINT:
                        {
                            ??
                         return 0;
                         }
		case WM_DESTROY:
		    PostQuitMessage(0);
			return 0;
	}
	return DefWindowProc(hWnd, Msg, wParam, lParam);
}
 
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowCmd)
{
	WNDCLASS wndClass = { 0, MelterProc, 0, 0, hInstance, NULL, LoadCursor(NULL, IDC_ARROW), GetSysColorBrush(COLOR_3DFACE), NULL, "nom" };
	if(!RegisterClass(&wndClass)) return MessageBox(HWND_DESKTOP, "Cannot register class!", NULL, MB_ICONERROR | MB_OK);
	HWND hWnd = CreateWindow("nom", NULL, WS_POPUP , 0, 0, nScreenWidth, nScreenHeight, HWND_DESKTOP, NULL, hInstance, NULL);
	if(!hWnd) return MessageBox(HWND_DESKTOP, "Cannot create window!", NULL, MB_ICONERROR | MB_OK);
	MSG messages = { 0 };
	 while (GetMessage (&messages, NULL, 0, 0))
    {
        TranslateMessage(&messages);
        DispatchMessage(&messages);
    }
	return 0;
}
Quelqu'un pourrait il m'aider à corriger la partie du code qui est traitée lors du message WM_CREATE et m'indiquer s'il y a des choses à traiter lors de la reception du message WM_PAINT ?
Merci beaucoup d'avance !