Wrox Programmer Forums
|
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 28th, 2005, 12:56 PM
Authorized User
 
Join Date: May 2005
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default Screen Resolution Problems

Is there anyone here that actualy knows how to change the windows screen resolution because all i get from spenind all day on the web is this:
Private Const CCDEVICENAME = 32
    Private Const CCFORMNAME = 32
    Private Const DM_PELSWIDTH = &H80000
    Private Const DM_PELSHEIGHT = &H100000
    Private Declare Function EnumDisplaySettings Lib "user32" _
    Alias "EnumDisplaySettingsA" _
    (ByVal lpszDeviceName As Long, _
    ByVal iModeNum As Long, _
ByVal lpDevMode As Long) As Boolean

    Private Declare Function ChangeDisplaySettings Lib "user32" _
        Alias "ChangeDisplaySettingsA" _
        (ByVal lpDevMode As any, _
        ByVal dwflags As Long) As Long

    Private Type DEVMODE
        Dim dmDeviceName As String * CCDEVICENAME
        Dim dmSpecVersion As Integer
        Dim dmDriverVersion As Integer
        Dim dmSize As Integer
        Dim dmDriverExtra As Integer
        Dim dmFields As Long
        Dim dmOrientation As Integer
        Dim dmPaperSize As Integer
        Dim dmPaperLength As Integer
        Dim dmPaperWidth As Integer
        Dim dmScale As Integer
        Dim dmCopies As Integer
        Dim dmDefaultSource As Integer
        Dim dmPrintQuality As Integer
        Dim dmColor As Integer
        Dim dmDuplex As Integer
        Dim dmYResolution As Integer
        Dim dmTTOption As Integer
        Dim dmCollate As Integer
        Dim dmFormName As String *CCFORMNAME
        Dim dmUnusedPadding As Integer
        Dim dmBitsPerPel As Integer
        Dim dmPelsWidth As Long
        Dim dmPelsHeight As Long
        Dim dmDisplayFlags As Long
        Dim dmDisplayFrequency As Long
    End Type

    Private Sub ChangeRes(ByVal iWidth As Single, ByVal iHeight As Single)
        Dim blnWorked As Boolean
        Dim i As Long
        Dim DevM As DEVMODE

        i = 0

        Do
            blnWorked = EnumDisplaySettings(0&, i, DevM)
            i = i + 1
        Loop Until (blnWorked = False)

        With DevM
            .dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
            .dmPelsWidth = iWidth
            .dmPelsHeight = iHeight
        End With

        Call ChangeDisplaySettings(DevM, 0)
    End Sub

This DOES NOT work in VB.net

the first declaration where it says as any vb.net does not like. In vb.net you must declare all variables. that is a change from 6.0 Also type is no longer suported. You must change that to structure. One last thing.
Dim dmDeviceName As String * CCDEVICENAME
Dim dmFormName As String *CCFORMNAME
vb.net basicaly spasims over the floor with these lines. the whole * thing messes it up.
Will anyone help or will u keep posting this useless *sensored*
TY

If you help me im fine, otherwise your MINE.
__________________
~~~~~~~~~~~~~~~~~~~~~
I\'m sorry for having a rude signature Peter. I\'m sorry for having a rude signature Peter. I\'m sorry for having a rude signature Peter. I\'m sorry for having a rude signature Peter. I\'m sorry for having a rude signature Peter. I\'m sorry for having a rude signature Peter. I\'m sorry for having a rude signature Peter. I\'m sorry for having a rude signature Peter. I\'m sorry for having a rude signature Peter. I\'m sorry for having a rude signature Peter.
 
Old May 28th, 2005, 08:52 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I doubt a rude message like this would result in you getting any help.

Hal Levy
I am here to help you, not do it for you.
That is, unless you hire me. I am looking for work.
 
Old May 28th, 2005, 09:25 PM
Authorized User
 
Join Date: May 2005
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i am sorry if i came across rude. I hoped for desperate. I wish i could change my screen resolution but i can't (through code). I have seen this code waved around like it is the skeleton key to my problems but it isn't. I was wondering if there is actualy a tested VB.NET version that works. My apologies.

If you help me im fine, otherwise your MINE.
 
Old May 31st, 2005, 12:19 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Code:
    Dim dmDeviceName As String * CCDEVICENAME
is how you declare a fixed-length string.

Help says,
Quote:
quote:String Length Declaration Changes in Visual Basic

Visual Basic .NET updates string length declaration for interoperability with the common language runtime.

Visual Basic 6.0
In Visual Basic 6.0, you can specify the length of a string in its declaration. This causes the string to have a fixed length, as in the following example:

    Dim Name As String * 30

Visual Basic .NET
In Visual Basic .NET, you cannot declare a string to have a fixed length unless you use the VBFixedStringAttribute Class attribute in the declaration. The code in the preceding example causes an error.

You declare a string without a length. When your code assigns a value to the string, the length of the value determines the length of the string, as in the following example:

    Dim Name As String
    ' ...
    Name = "Name is now 30 characters long" ' Length can be changed later.


VBFixedStringAttribute Class

Indicates that a string should be treated as if it were fixed length.

Visual Basic .NET strings are of variable length by default. This attribute is useful when using Visual Basic .NET file input and output functions, such as FileGet and FilePut that require fixed length strings.

Example
Code:
Structure Person
   Public ID As Integer
   Public MonthlySalary As Decimal
   Public LastReviewDate As Long
   <VBFixedString(15)> Public FirstName As String
   <VBFixedString(15)> Public LastName As String
   <VBFixedString(15)> Public Title As String
   <VBFixedString(150)> Public ReviewComments As String
End Structure
Note The VBFixedStringAttribute is informational and cannot be used to convert a variable length string to a fixed string. The purpose of this attribute is to modify how strings in structures and non-local variables are used by methods or API calls that recognize the VBFixedStringAttribute. Keep in mind that this attribute does not change the actual length of the string itself.
(“If you help me im fine, otherwise your MINE” comes across as trying to threaten someone into helping, like a toned down “Help me or I’ll shoot you” . . . )
 
Old May 31st, 2005, 12:24 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Help says:

'As Any' is not supported in 'Declare' statements

The Any data type was used with Declare statements in previous versions of Visual Basic to permit the use of arguments that could contain any type of data. VB.NET supports overloading, however, and so makes the Any data type obsolete.

To correct this error

Declare parameters of the specific type you want to use; for example:
Code:
    Declare Function GetUserName Lib "advapi32.dll" _
              Alias "GetUserNameA" (ByVal lpBuffer As String, _
                                    ByRef nSize As Integer) As Integer
                                    Use the MarshalAsAttribute attribute to specify As Any when Void* is expected by the procedure being called.
Code:
    Declare Sub SetData Lib "..\LIB\UnmgdLib.dll" (ByVal x As Short, _
Code:
         <MarshalAsAttribute(UnmanagedType.AsAny)> ByVal o As Object)
 
Old May 31st, 2005, 06:21 PM
Authorized User
 
Join Date: May 2005
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

lol im sry i guess i picked a wrion.. whats it called footer?
sry again. and ty a ton for adresing my problems in VB.net. Gosh i dell like a donkey.

If you help me im fine, otherwise your MINE.
 
Old May 31st, 2005, 06:45 PM
Authorized User
 
Join Date: May 2005
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the whole marshal thing doesnt appear in the pop-down menu is there somthing i need to import?

~~~~~~~~~~~~~~~~~~~~~
If you help me im fine, otherwise ill shoot you. :)

P.S. With a c a mera.
 
Old May 31st, 2005, 08:49 PM
Authorized User
 
Join Date: May 2005
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

nvm i got it figured out i jsut dont knwo how to activate it now

~~~~~~~~~~~~~~~~~~~~~
If you help me im fine, otherwise ill shoot you. :)

P.S. With a c a mera.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Screen Resolution ajeesh_online C# 1 June 14th, 2006 12:37 AM
screen resolution Adam H-W Classic ASP Basics 3 October 13th, 2004 09:13 PM
screen resolution miguel.ossa C# 2 October 9th, 2004 11:58 PM
screen resolution mistry_bhavin Pro VB.NET 2002/2003 0 March 13th, 2004 02:36 PM
How to detect screen resolution pb_user Classic ASP Basics 1 August 24th, 2003 01:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.