bonjour
voila je veux mettre un bmp dans un static.
dans le fichier rc ya:
SniperImg BITMAP "C:/sniper.bmp"
et dans le main ya (en simplifie)
#include <windows.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("Sniper's Launcher") ;
HWND hwnd ;MSG msg ;WNDCLASS wndclass ;
wndclass.style = CS_DBLCLKS;wndclass.lpfnWndProc = WndProc ;wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra = 0 ;wndclass.hInstance = hInstance ;wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;wndclass.hbrBackground = (HBRUSH) COLOR_BTNSHADOW;wndclass.lpszMenuName = NULL ;wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{MessageBox (NULL, TEXT ("Ce programme fonctionne exclusivement sous Windows NT!"),szAppName, MB_ICONERROR) ;return 0 ;}
hwnd = CreateWindow (szAppName, TEXT ("Sniper's Launcher"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,460, 370, NULL, NULL, hInstance, NULL) ;
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HINSTANCE hInstance ;
switch (message)
{
case WM_CREATE :
HDC hdc;
HBITMAP hBitmap;
hInstance = (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE) ;
static HWND imghWnd = CreateWindowEx(WS_EX_CLIENTEDGE, "STATIC", NULL, WS_VISIBLE|WS_CHILD|SS_BITMAP,
0, 0, 384, 128, hwnd, (HMENU)0, hInstance, NULL);
hBitmap = LoadBitmap (hInstance,"SniperImg") ;
SendMessage(imghWnd, BM_SETIMAGE ,IMAGE_BITMAP ,(long) hBitmap);
//ShowWindow(imghWnd, SW_SHOW);
return 0 ;
case WM_DESTROY :
PostQuitMessage (0) ;
return 0 ;
case WM_COMMAND:
break;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
et comme vous l'aurez subtilemet deviné, ca marche pas.
je précise que les dims du bmp ne st pas des puissances de 2, et qu'il est bien dans C:\ (meme si l'ese n'y est pas)
how could I do please?
huge thanks, merci bcp d'avance.
______________________
Omnia vincit labor improbus