473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to call EnumDisplaySettings from VB.Net

I want to call EnumDisplaySettings from a VB.Net project. Is there simply
no way to do this?

Mark
Nov 20 '05 #1
3 4942
* "Mark Snyder" <sn*****@otc.edu> scripsit:
I want to call EnumDisplaySettings from a VB.Net project. Is there simply
no way to do this?


You may want to translate this C# sample:

<http://groups.google.com/groups?selm=OBye0ZvXCHA.2416%40tkmsftngp09>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Thanks for the reply, but...

Using a C# or C++ example of how to use EnumDisplaySettings would be
great, but the translation is exactly what I'm having the trouble with.

First problem: You can't do fixed-length fields in VB.Nt to declare the
DEVMODE Structure, so I put a couple of fields in there to act as filler
to take up the right amount of bytes.

Next problem: Then I get the next error, which is how do you pass VB's
Structure data type to a Win32 API function call without getting the
exception to the effect of "there is no object instance".

I'd like to figure out how to do this within VB.Net if anyone knows how
to do this.

Thanks,
Mark
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3
On 2004-01-26, Mark Snyder <ma*******@msn.com> wrote:
Thanks for the reply, but...

Using a C# or C++ example of how to use EnumDisplaySettings would be
great, but the translation is exactly what I'm having the trouble with.

First problem: You can't do fixed-length fields in VB.Nt to declare the
DEVMODE Structure, so I put a couple of fields in there to act as filler
to take up the right amount of bytes.

Next problem: Then I get the next error, which is how do you pass VB's
Structure data type to a Win32 API function call without getting the
exception to the effect of "there is no object instance".

I'd like to figure out how to do this within VB.Net if anyone knows how
to do this.

Thanks,
Mark
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


' VB translation...

Public Const SA_SIZE As Integer = 32

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _
Structure DEVMODE
Public iSpecVersion As Short
Public iDriverVersion As Short
Public iSize As Short
Public iDriverExtra As Short
Public iFields As Integer
Public iOrientation As Short
Public iPaperSize As Short
Public iPaperLength As Short
Public iPaperWidth As Short
Public iScale As Short
Public iCopies As Short
Public iDefaultSource As Short
Public iPrintQuality As Short
Public iColor As Short
Public iDuplex As Short
Public iYRes As Short
Public iTTOption As Short
public iCollate As Short

// marsahalling attr...
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=SA_SIZE)> _
Public lpszFormName As String

Public iLogPixels As Short
Public iBitsPerPixel As Integer
Public lPelsWidth As Integer
Public lPelsHeight As Integer
Public lDisplayFlags As Integer
Public lDisplayFreq As Integer
Public lICMMethod As Integer
Public lICMIntent As Integer
Public lMediaType As Integer
Public lDitherType As Integer
Public lReserved1 As Integer
Public lReserved2 AS Integer
Public lPanWidth As Integer
Public lPanHeight As Integer

End Structure

Class LibWrapper
Public Declare Auto Function EnumDisplaySettings Lib "user32" _
(ByVal lpszDeviceName As String, _
ByVal lModeNum As Integer, _
ByRef lpdm As DEVMODE) As Boolean

Public Declare Auto Function ChangeDisplaySettings Lib "user32" _
(ByRef lpdm DEVMODE, ByVal iFlags As Integer) As Integer

End Class
Public Sub Main()
Dim dm As New DEVMODE()
Dim lMode As Integer = -1

dm.iSize = CType(Marshal.SizeOf(dm), Short)

Dim b As Boolean = LibWrapper.EnumDisplaySettings( _
Nothing, _
lMode, _
dm)
End Sub

Barring typo's should work...

--
Tom Shelton [MVP]
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Hubert Baumeister | last post by:
Fifth International Conference on eXtreme Programming and Agile Processes in Software Engineering XP2004 June 6-10, 2004, Garmisch-Partenkirchen, Germany http://www.xp2004.org/
6
by: zengou | last post by:
MSDN: BOOL EnumDisplaySettings( LPCTSTR lpszDeviceName, // display device DWORD iModeNum, // graphics mode LPDEVMODE lpDevMode // graphics mode settings ); typedef struct...
13
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
4
by: John | last post by:
Hi all, This really is quite an urgent matter. I have a page with multiple, dynamically-loaded user controls and when a user clicks on a button, the whole form is submitted. Now at this stage...
13
by: mitchellpal | last post by:
i am really having a hard time trying to differentiate the two..........i mean.....anyone got a better idea how each occurs?
13
by: shsingh | last post by:
I have a class A containing some map as data variables. I creat an object of class A on heap by allocatiing memory by using "malloc". This will return me the required memory but the object is not...
3
by: cberthu | last post by:
Hi all, Is it possible to have two connects in the same rexx script to different DB's? I have to get data form on DB (with specifics selects and filter out some values with RExx) and save the...
9
by: CryptiqueGuy | last post by:
Consider the variadic function with the following prototype: int foo(int num,...); Here 'num' specifies the number of arguments, and assume that all the arguments that should be passed to this...
12
by: Rahul | last post by:
Hi Everyone, I have the following code and i'm able to invoke the destructor explicitly but not the constructor. and i get a compile time error when i invoke the constructor, why is this so? ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.