Fullscreen

Illusion

Centurion
Joined
Aug 7, 2003
Messages
105
Location
Uk
Hi,

I was looking for a way to make my form fullscreen.
I have tried a few things and looked on the interweb :) but nothing seems to work, but it looks like it should.

for example:
Code:
    Const HWND_TOPMOST = -1
    Const HWND_NOTOPMOST = -2
    Const SWP_NOSIZE = &H1
    Const SWP_NOMOVE = &H2
    Const SWP_NOACTIVATE = &H10
    Const SWP_SHOWWINDOW = &H40
    Private Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SetWindowPos(Me.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE)
    End Sub

would work if form returned a hWnd and not a handle like it is doing now..

The fullscreen needs to cover the windows start bar and also stay on topmost too.

Any ideas?

Thanks

Illusion
 
Hey,

I tried that one before posting, (sorry I should have said).

I got this message..
A call to PInvoke function 'fullscreen!fullscreen.Form1::SetWindowPos' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

Thanks
 
Try
Visual Basic:
Declare Auto Function SetWindowPos Lib "user32" (ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, _
    ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, _
    ByVal uFlags As UInteger) As Boolean
as your declaration.

Depending on exactly what you are trying to do via this call you might be able to do without the API anyway.
Try the following and see if it suits your needs.
Visual Basic:
Me.TopMost = True
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.Location = New Point(0, 0)
Me.Size = Screen.PrimaryScreen.Bounds.Size
 
If you just want fullscreen, I do it with setting the border style to none and window state to maximized - you can also set TopMost to true. Those three properties should make the form go fullscreen, covering even the taskbar and system tray.

If you want "true" full screen, with mouse capture and all including preventing Alt-Tab from switching, you're likely thinking of DirectX or similar libraries that allow more "total control." That's a lot more work.

If you want the API to work, just change the call to accept an IntPtr and make sure the other params are all "Integer" instead of "Long" - assuming you're using a 32 bit version of Windows. If you've got WinXp for 64 bit then you're on your own :)

For example:
Code:
Private Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As IntPtr, ...

-ner
 
Hi,

I tried the API thing, but it gave the same problem.

Private Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As IntPtr, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SetWindowPos(Me.Handle, IntPtr.Zero, 0, 0, 1024, 768, 64)
End Sub

I will try the other stuff..
I did really want to use full screen and be able to control the key presses.
Other than directx, what way could I do it?

Thanks
 
Illusion,

I'm not being rude, but have you read all the replies that are provided in this thread? It's not clear to me that you have. For example, I said you'd likely have to replace all "Long" with "Integer" yet your sample shows you're still trying "Long."

Also, have you tried PD's example or mine, where you just change the border style and other properties of a form (no API call needed)? Did that work or not work? If it didn't, what was wrong about it or what behavior did you see that didn't work the way you expected?

-nerseus
 
Back
Top