|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Screen Resolution ChangesIs there any way my application can be notified if the user changes the
screen resolution while running the application (VB.Net 2003). Thanks. -- Dennis in Houston Dennis,
Use a wmi __InstanceModificationEvent to be notified of the screen resolution changes. This sample uses the wmi Win32_DisplayConfiguration class to be notified of the change. Add a reference to system.management. You will need a listbox on the form to display the display adapter name, height, and width. Imports System.Management Public Class Form1 Dim WithEvents w As ManagementEventWatcher Dim q As WqlEventQuery Delegate Sub LoadList() Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing w.Stop() End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try q = New WqlEventQuery q.QueryString = "SELECT * FROM" & _ " __InstanceModificationEvent WITHIN 1 " & _ "WHERE TargetInstance isa ""Win32_DisplayConfiguration""" w = New ManagementEventWatcher(q) w.Start() Catch ex As Exception Trace.WriteLine(ex.ToString) End Try GetDeviceSettings() End Sub Private Sub GetDeviceSettings() ListBox1.Items.Clear() Dim moReturn As Management.ManagementObjectCollection Dim moSearch As Management.ManagementObjectSearcher Dim mo As Management.ManagementObject moSearch = New Management.ManagementObjectSearcher("Select * from Win32_DisplayConfiguration") moReturn = moSearch.Get For Each mo In moReturn ListBox1.Items.Add(mo("Caption").ToString) ListBox1.Items.Add(String.Format("Height {0}", mo("PelsHeight"))) ListBox1.Items.Add(String.Format("Width {0}", mo("PelsWidth"))) Next End Sub Private Sub w_EventArrived(ByVal sender As Object, ByVal e As System.Management.EventArrivedEventArgs) Handles w.EventArrived For Each p As Process In Process.GetProcesses Trace.WriteLine(p.MainWindowTitle) Next ListBox1.Invoke(New LoadList(AddressOf GetDeviceSettings)) End Sub End Class Ken ----------------- Show quoteHide quote "Dennis" <Den***@discussions.microsoft.com> wrote in message news:8604F36D-BA6D-4DBF-90CC-F61A90D63816@microsoft.com... > Is there any way my application can be notified if the user changes the > screen resolution while running the application (VB.Net 2003). Thanks. > -- > Dennis in Houston "Dennis" <Den***@discussions.microsoft.com> schrieb: Untested: 'SystemEvents.DisplaySettingsChanged'.> Is there any way my application can be notified if the user changes the > screen resolution while running the application (VB.Net 2003). -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Thanks Herfried and Ken. I'll give both approaches a try.
-- Show quoteHide quoteDennis in Houston "Herfried K. Wagner [MVP]" wrote: > "Dennis" <Den***@discussions.microsoft.com> schrieb: > > Is there any way my application can be notified if the user changes the > > screen resolution while running the application (VB.Net 2003). > > Untested: 'SystemEvents.DisplaySettingsChanged'. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> >
parsing an xml string into fields
Convert Script code to VB.Net Simple question: How to find Elapsed time (in seconds) formatting time and date Using the backgroundworker to populate a treeview vb .net deployment Error Starting to debug Reading the application folder.. VSTO 2k5 Question Help!! about the webBrowser! |
|||||||||||||||||||||||