Vista and the Win API
Vista and the Win API
Does Vista require a revised Win32 API library?
The problem seems to be library related - whether I use BCX or FreeBASIC to create a Win32 window (non-OpenGL), the result is fine on Win 98, 2k, and XP. But on Vista, there exists empty bands in the window where nothing is plotted.
http://www21.brinkster.com/copysense/images/maurer.gif
The problem seems to be library related - whether I use BCX or FreeBASIC to create a Win32 window (non-OpenGL), the result is fine on Win 98, 2k, and XP. But on Vista, there exists empty bands in the window where nothing is plotted.
http://www21.brinkster.com/copysense/images/maurer.gif
I got this error:
The image “http://www21.brinkster.com/copysense/images/maurer.gif” cannot be displayed, because it contains errors.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Last edited by D.J.Peters on Oct 03, 2017 6:02, edited 1 time in total.
-
- Posts: 2428
- Joined: Jul 19, 2006 19:17
- Location: Sunnyvale, CA
- Contact:
I think the MSDN online manual will tell you if certain functions have changed for Vista.
If you're using a library that might be incompatible, check with its authors.
In that screen shot, maybe you need something like FBGFX's ScreenLock() because only part of the image is drawn when the active page is shown, or maybe your clipping is wrong.
FreeBasic itself works fine with Vista. ;-)
If you're using a library that might be incompatible, check with its authors.
In that screen shot, maybe you need something like FBGFX's ScreenLock() because only part of the image is drawn when the active page is shown, or maybe your clipping is wrong.
FreeBasic itself works fine with Vista. ;-)
Thanks Kristopher, and sorry for the delay.
Ugh - I haven't enjoyed my re-acquaintance with Win32 code, but this example seems to show the effect on the PCs I've currently got access to. I compiled it with FB0.18.2 on Vista, and the executable run on the same Vista PC shows 'blank columns' (where no pixels are plotted) in the window. On an XP machine, the same executable plots pixels across the window area.
Ugh - I haven't enjoyed my re-acquaintance with Win32 code, but this example seems to show the effect on the PCs I've currently got access to. I compiled it with FB0.18.2 on Vista, and the executable run on the same Vista PC shows 'blank columns' (where no pixels are plotted) in the window. On an XP machine, the same executable plots pixels across the window area.
Code: Select all
#include once "windows.bi"
Declare Function WinMain ( Byval hInstance As HINSTANCE, _
Byval hPrevInstance As HINSTANCE, _
szCmdLine As String, _
Byval iCmdShow As Integer ) As Integer
End WinMain( GetModuleHandle( null ), null, Command$, SW_NORMAL )
Function WndProc ( Byval hWnd As HWND, _
Byval message As UINT, _
Byval wParam As WPARAM, _
Byval lParam As LPARAM ) As LRESULT
Function = 0
DIM AS INTEGER i, xp , yp
Select Case( message )
Case WM_CREATE
Exit Function
Case WM_PAINT
Dim rct As RECT
Dim pnt As PAINTSTRUCT
Dim hDC As HDC
hDC = BeginPaint( hWnd, @pnt )
GetClientRect( hWnd, @rct )
FOR i = 0 TO 500000
xp = CINT(RND * 1000)
yp = CINT(RND * 1000)
SetPixelV( hDC, xp,yp, RGB(255,255,255) )
NEXT
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
Function = DefWindowProc( hWnd, message, wParam, lParam )
End Function
Function WinMain ( Byval hInstance As HINSTANCE, _
Byval hPrevInstance As HINSTANCE, _
szCmdLine As String, _
Byval iCmdShow As Integer ) As Integer
Dim wMsg As MSG
Dim wcls As WNDCLASS
Dim szAppName As String
Dim hWnd As HWND
Function = 0
szAppName = "PixelTest"
With wcls
.style = CS_HREDRAW Or CS_VREDRAW
.lpfnWndProc = @WndProc
.cbClsExtra = 0
.cbWndExtra = 0
.hInstance = hInstance
.hIcon = LoadIcon( NULL, IDI_APPLICATION )
.hCursor = LoadCursor( NULL, IDC_ARROW )
.hbrBackground = GetStockObject( WHITE_BRUSH )
.lpszMenuName = NULL
.lpszClassName = strptr( szAppName )
End With
If( RegisterClass( @wcls ) = FALSE ) Then
MessageBox( null, "Failed to register wcls!", szAppName, MB_ICONERROR )
Exit Function
End If
hWnd = CreateWindowEx( 0, _
szAppName, _
"Pixel 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
Function = wMsg.wParam
End Function
-
- Posts: 2428
- Joined: Jul 19, 2006 19:17
- Location: Sunnyvale, CA
- Contact:
It looks like this for me:
http://freefile.kristopherw.us/uploads/ ... pixels.png
And I do not think that is correct. -(o.O);
I don't know much about WinAPI, but maybe someone such as Mysoft can find the bug. ;-)
FWIW, I am using Vista with no updates.
http://freefile.kristopherw.us/uploads/ ... pixels.png
And I do not think that is correct. -(o.O);
I don't know much about WinAPI, but maybe someone such as Mysoft can find the bug. ;-)
FWIW, I am using Vista with no updates.
Microsoft will not intentionally make changes to basic API functions because it would break too much code.
@tinram,
I suspect that there is something unusual about your Vista system that is causing the “blank columns”. There is a problem in your code that is causing SetPixelV to fail repeatedly. Per the Microsoft documentation:
“The point must be in the clipping region and the visible part of the device surface.”
If you change the code that generates the coordinates to:
Then the generated coordinates will lie within the client area of the window, and the function will fail only if you move the window so some portion of the client area is not visible.
@tinram,
I suspect that there is something unusual about your Vista system that is causing the “blank columns”. There is a problem in your code that is causing SetPixelV to fail repeatedly. Per the Microsoft documentation:
“The point must be in the clipping region and the visible part of the device surface.”
If you change the code that generates the coordinates to:
Code: Select all
xp = int(Rnd * rct.right)
yp = int(Rnd * rct.bottom)
Thanks guys for your responses.
@KristopherWindsor - yes, your screenshot is identical to what I'm getting on Vista.
@MichaelW - thanks - I've amended the code with your changes: the executable's pixel plotting in the window is better, but it still displays the empty pixel bands when running on this Vista.
@phishguy - good point - perhaps graphics cards/drivers are the problem since your Vista is running the window okay, but Kristopher's and mine are not. (My card is a GeForce 8300 GS; Vista is Home Premium without SP1.)
@KristopherWindsor - yes, your screenshot is identical to what I'm getting on Vista.
@MichaelW - thanks - I've amended the code with your changes: the executable's pixel plotting in the window is better, but it still displays the empty pixel bands when running on this Vista.
@phishguy - good point - perhaps graphics cards/drivers are the problem since your Vista is running the window okay, but Kristopher's and mine are not. (My card is a GeForce 8300 GS; Vista is Home Premium without SP1.)
-
- Posts: 2428
- Joined: Jul 19, 2006 19:17
- Location: Sunnyvale, CA
- Contact: