BYREF args fault again.. i hate those suckers. This test worked fine:
option explicit
#include once "win\kernel32.bi"
#include once "win\user32.bi"
#include once "win\gdi32.bi"
#include once "fblogo.bi"
declare function WinMain ( byval hInstance as long, _
byval hPrevInstance as long, _
szCmdLine as string, _
byval iCmdShow as integer ) as integer
end WinMain( GetModuleHandle( null ), null, Command$, SW_NORMAL )
function WndProc ( byval hWnd as long, _
byval message as long, _
byval wParam as long, _
byval lParam as long ) as integer
dim rct as RECT
dim pnt as PAINTSTRUCT
dim hDC as long
static logoinfo as BITMAPINFO ptr
static logodib as long
WndProc = 0
select case ( message )
case WM_CREATE
'' pointer to bitmap file
dim logo as BITMAPFILEHEADER ptr = @fblogo_data(0)
'' ponter to bitmap header
logoinfo = logo + SizeOf(BITMAPFILEHEADER)
'' create a DIB
logodib = CreateDIBitmap( GetDC( hWnd ), byval @logoinfo->bmiHeader, _
CBM_INIT, byval logo + logo->bfOffBits, byval logoinfo, DIB_RGB_COLORS )
exit function
case WM_PAINT
hDC = BeginPaint( hWnd, pnt )
'' load DIB to a compatible DC
dim memDC as long
memDC = CreateCompatibleDC( hDC )
dim oldobj as long
oldobj = SelectObject( memDC, logodib )
'' blit compatible DC to this window
BitBlt( hDC, 0, 0, logoinfo->bmiHeader.biWidth, logoinfo->bmiHeader.biHeight, _
memDC, 0, 0, SRCCOPY )
'' restore
SelectObject( memDC, oldobj )
DeleteDC( memDC )
EndPaint( hWnd, pnt )
exit function
case WM_KEYDOWN
if( lobyte( wParam ) = 27 ) then
PostMessage hWnd, WM_CLOSE, 0, 0
end if
case WM_DESTROY
PostQuitMessage 0
exit function
end select
WndProc = DefWindowProc( hWnd, message, wParam, lParam )
end function
function WinMain ( byval hInstance as long, _
byval hPrevInstance as long, _
szCmdLine as string, _
byval iCmdShow as integer ) as integer
dim wMsg as MSG
dim wcls as WNDCLASS
dim szAppName as string
dim hWnd as unsigned long
WinMain = 0
szAppName = "Test"
with wcls
.style = CS_HREDRAW or CS_VREDRAW
.lpfnWndProc = @WndProc
.cbClsExtra = 0
.cbWndExtra = 0
.hInstance = hInstance
.hIcon = LoadIcon( null, byval IDI_APPLICATION )
.hCursor = LoadCursor( null, byval IDC_ARROW )
.hbrBackground = GetStockObject( byval WHITE_BRUSH )
.lpszMenuName = null
.lpszClassName = strptr( szAppName )
end with
if ( RegisterClass( wcls ) = false ) then
exit function
end if
hWnd = CreateWindowEx( 0, szAppName, "Test", WS_OVERLAPPEDWINDOW, _
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, _
null, null, hInstance, null )
ShowWindow hWnd, iCmdShow
UpdateWindow hWnd
while ( GetMessage( wMsg, null, 0, 0 ) <> false )
TranslateMessage wMsg
DispatchMessage wMsg
wend
WinMain = wMsg.wParam
end function