I want to load a BMP image in the main window, that is, as a background.
That it covers the yellow background, but not the rest of the colors. I have tried with LoadImage and SelectObject but there is no way.
Thank you so much!!!!
Code: Select all
'-------------------------------------------------------------------------------
#include "windows.bi"
const ProgrammName = "Bitmaps blitten"
DIM shared Tiempo as double
dim shared Ancho as integer
dim shared Alto as integer
declare function Fenster(byval hWnd as HWND, byval message as UINTEGER,_
byval wParam as WPARAM, byval lParam as LPARAM) as LRESULT
dim as WNDCLASS wcMeinFenster
with wcMeinFenster
'.style = CS_OWNDC Or CS_VREDRAW Or CS_HREDRAW
.lpfnWndProc = ProcPtr(Fenster)
.cbClsExtra = 0
.cbWndExtra = 0
.hInstance = GetModuleHandle(NULL)
.hCursor = LoadCursor(NULL, IDC_ARROW)
.hIcon = LoadIcon(NULL, IDI_APPLICATION)
.hbrBackground = GetStockObject(WHITE_BRUSH)
.lpszClassName = StrPtr(ProgrammName)
.lpszMenuName = NULL
end with
RegisterClass @wcMeinFenster
dim as HWND hMeinFenster = CreateWindow(_
ProgrammName, "Titelzeile", WS_OVERLAPPEDWINDOW,_
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,_
NULL, NULL, GetModuleHandle(NULL), NULL)
ShowWindow hMeinFenster, SW_NORMAL
UpdateWindow hMeinFenster
dim as MSG msg
do while getmessage(@msg, NULL, 0, 0) <> 0
DispatchMessage @msg
loop
end msg.wParam
function Fenster(byval hWnd as HWND, byval message as UINTEGER,_
byval wParam as WPARAM, byval lParam as LPARAM) as LRESULT
static as HBRUSH Brush
static as RECT ClientRect
static as HBITMAP hBitmap
static as HDC hDC2
dim as HDC hDC
select case message
case WM_DESTROY
print "WM_DESTROY"
DeleteDC(hDC2)
DeleteObject(hBitmap)
PostQuitMessage 0
return 0
case WM_CREATE
print "WM_CREATE"
Brush = CreateSolidBrush(&HFFFF)
getclientrect(hwnd,@ClientRect)
dim x as integer
dim y as integer
for x=0 to 1000 step 120
for y=0 to 1000 step 25
CreateWindowEx( 0, "BUTTON", "Button 1", WS_VISIBLE Or WS_CHILD, x, y, 100, 20, hwnd, 0, 0, 0 )
next y
next x
hDC = GetDC(hWnd)
hBitmap = CreateCompatibleBitmap(hDC, 1300, 1300)
hDC2 = CreateCompatibleDC(hDC)
ReleaseDC(hWnd, hDC)
SelectObject(hDC2, hBitmap)
FillRect(hDC2, @ClientRect, Brush)
'---------------------------
'----- paint bitmap here
'---------------------------
dim as INTEGER ix, iy
for ix = 0 to 255
for iy = 0 to 255
SetPixel hDC2, ix +50, iy+50, RGBA(ix, iy, 128, 0)
next
next
'----------------------------------
for x=0 to 1500 step 15
for y=0 to 1500 step 15
Ellipse hDC2,x,y,x+10,y+10
next y
next x
'----------------------------------
return 0
case WM_PAINT
print "WM_PAINT"
dim as PAINTSTRUCT pnt
hDC = BeginPaint(hWnd, @pnt)
BitBlt hDC, 0, 0, 1300, 1300, hDC2, 0, 0, SRCCOPY
EndPaint(hWnd, @pnt)
return 0
end select
return DefWindowProc(hWnd, message, wParam, lParam)
end function