Vista and the Win API

Windows specific questions.
tinram
Posts: 89
Joined: Nov 30, 2006 13:35
Location: UK

Vista and the Win API

Post by tinram »

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
phishguy
Posts: 1201
Joined: May 05, 2006 16:12
Location: West Richland, Wa

Post by phishguy »

HTTP1.1 STATUS 403 Remote Access to this object forbidden This file cannot be directly accessed from a remote site, but must be linked through the Brinkster Member's site.
Can't access the screen shot.
maddogg6
Posts: 824
Joined: Dec 07, 2005 22:58
Contact:

Post by maddogg6 »

I got this error:
The image “http://www21.brinkster.com/copysense/images/maurer.gif” cannot be displayed, because it contains errors.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Post by D.J.Peters »

Image
Last edited by D.J.Peters on Oct 03, 2017 6:02, edited 1 time in total.
LukeL
Posts: 118
Joined: Mar 14, 2006 17:26

Post by LukeL »

That's alright I'm sure for $700 windows 2008 will be bug free!!! :P
tinram
Posts: 89
Joined: Nov 30, 2006 13:35
Location: UK

Post by tinram »

Thanks Joshy for fixing/rehosting the image - it had intermittent access.
KristopherWindsor
Posts: 2428
Joined: Jul 19, 2006 19:17
Location: Sunnyvale, CA
Contact:

Post by KristopherWindsor »

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. ;-)
tinram
Posts: 89
Joined: Nov 30, 2006 13:35
Location: UK

Post by tinram »

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.

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
phishguy
Posts: 1201
Joined: May 05, 2006 16:12
Location: West Richland, Wa

Post by phishguy »

I tested it on a PC at work that has Vista and it ran fine. There were no blank areas. Perhaps there is an updated driver for your video card available.
KristopherWindsor
Posts: 2428
Joined: Jul 19, 2006 19:17
Location: Sunnyvale, CA
Contact:

Post by KristopherWindsor »

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.
phishguy
Posts: 1201
Joined: May 05, 2006 16:12
Location: West Richland, Wa

Post by phishguy »

That's odd. I wonder why I didn't have a problem. It looked the same whether it was run on Win2k or Vista. No blank areas appeared for me. Maybe I was on a different version of Vista.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Post by MichaelW »

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:

Code: Select all

xp = int(Rnd * rct.right)
yp = int(Rnd * rct.bottom)
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
Posts: 89
Joined: Nov 30, 2006 13:35
Location: UK

Post by tinram »

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.)
phishguy
Posts: 1201
Joined: May 05, 2006 16:12
Location: West Richland, Wa

Post by phishguy »

It might not be rellevant, but I tested on Windows Vista Business edition with all the latest updates and the graphics card is a NVidia Geforce 7300 GS. So, maybe it wasn't a fair comparison test.
KristopherWindsor
Posts: 2428
Joined: Jul 19, 2006 19:17
Location: Sunnyvale, CA
Contact:

Post by KristopherWindsor »

It looks like it might be something fixed in SP1, then.
BTW, I am using a laptop with an integrated card in the 5000 or 6000 series. ;-)
Post Reply