Situation 1 (erroneous):
TaskBar changes
Screen.PrimaryS creen.WorkingAr ea still returns the old rectangle
Situation 2 (OK)
TaskBar changes
Form Quits and Reloads
Screen.PrimaryS creen.WorkingAr ea returns the new rectangle
How to correct the 1st situation? 11 7957
Arcer,
What do you mean by "Form Quits & Reloads"?
I only see the WorkingArea change when the application itself quits &
reexecute it, that is when I am only changing the size of the TaskBar.
Or put another way: The WorkingArea is only updated for the DisplayChanged
event & app start. I would expect the WorkingArea to change if the size of
the TaskBar changes. Also I'm getting in consist changes on
DisplayChanged. ..
I'm not seeing anything in the KB about this, if you clarify what you are
seeing I will report it to MS.
Hope this helps
Jay
"Arcer P" <No@Spam.Com> wrote in message
news:OG******** ********@TK2MSF TNGP12.phx.gbl. .. Situation 1 (erroneous): TaskBar changes Screen.PrimaryS creen.WorkingAr ea still returns the old rectangle
Situation 2 (OK) TaskBar changes Form Quits and Reloads Screen.PrimaryS creen.WorkingAr ea returns the new rectangle
How to correct the 1st situation?
Hi Arcer
It seems that you are right and it appears that the .NET Framework is caching the working screen size at application startup so if you change the working area after your application has been loaded (i.e. by increasing the size of the taskbar or adding the office shortcut bar etc.), Screen.PrimaryS creen.WorkingAr ea still returns the original cached size. I would suggest that this behaviour is probably a bug in the framework
A workaround would be to p/invoke the 'SystemParamete rsInfo' Win32 API which will get you the working area in realtime..
\
Private Const SPI_GETWORKAREA As Integer = 4
Private Structure REC
Public Left As Intege
Public Top As Intege
Public Right As Intege
Public Bottom As Intege
End Structur
Private Declare Function SystemParameter sInfo Lib "user32" Alias "SystemParamete rsInfoA"
(ByVal uAction As Integer, ByVal uParam As Integer, ByRef lpvParam As RECT, ByVal fuWinIni As Integer) As Intege
//
\
Dim rectDesktop As REC
If (SystemParamete rsInfo(SPI_GETW ORKAREA, 0, rectDesktop, 0) <> 0) The
Console.WriteLi ne("Desktop Working Width = " & CType(rectDeskt op.Right - rectDesktop.Lef t, String)
Console.WriteLi ne("Desktop Working Height = " & CType(rectDeskt op.Bottom - rectDesktop.Top , String)
End I
//
HTH
Gary
Jay B. Harlow [MVP - Outlook] wrote: Arcer, What do you mean by "Form Quits & Reloads"?
Step by step
1. Create a new solution with a single form
2. Write the Click event as follows:
Private Sub Form1_Click(ByV al sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Click
Me.Text = Screen.PrimaryS creen.WorkingAr ea.ToString
End Sub
3. On the menu Debug click Start
4. Click the form that shows in the screen
and write down the form text (formely named caption)
5. Change the size and/or position of the task bar
6. Click the form again
notice that the form text did not change
7. Close the program
8. Start the program again
9. Click the form again
notice that the caption reflects the new screen working area
Is it clear now?
Actually, don't use the p/invoke method. I just discovered that 'System.Windows .Forms.SystemIn formation.Worki ngArea' works dynamically in the same way as the p/invoke method so use this instead
Gar
Thank you very much for your sample code :)
I was not expecting to give so much trouble
Gary Milton wrote: Hi Arcer,
It seems that you are right and it appears that the .NET Framework is caching the working screen size at application startup so if you change the working area after your application has been loaded (i.e. by increasing the size of the taskbar or adding the office shortcut bar etc.), Screen.PrimaryS creen.WorkingAr ea still returns the original cached size. I would suggest that this behaviour is probably a bug in the framework.
A workaround would be to p/invoke the 'SystemParamete rsInfo' Win32 API which will get you the working area in realtime...
\\ Private Const SPI_GETWORKAREA As Integer = 48
Private Structure RECT Public Left As Integer Public Top As Integer Public Right As Integer Public Bottom As Integer End Structure
Private Declare Function SystemParameter sInfo Lib "user32" Alias "SystemParamete rsInfoA" _ (ByVal uAction As Integer, ByVal uParam As Integer, ByRef lpvParam As RECT, ByVal fuWinIni As Integer) As Integer ///
\\ Dim rectDesktop As RECT
If (SystemParamete rsInfo(SPI_GETW ORKAREA, 0, rectDesktop, 0) <> 0) Then Console.WriteLi ne("Desktop Working Width = " & CType(rectDeskt op.Right - rectDesktop.Lef t, String)) Console.WriteLi ne("Desktop Working Height = " & CType(rectDeskt op.Bottom - rectDesktop.Top , String)) End If ///
HTH, Gary
Gary,
Thanks for the work around!
I'm curious how well it works in a multi-monitor environment, as the
System.Windows. Forms.Screen object represents each monitor attached to your
computer.
Either way I will report something to MS as
System.Windows. Forms.Screen.Pr imaryScreen.Wor kingArea is not working
correctly.
Thanks
Jay
"Gary Milton" <an*******@disc ussions.microso ft.com> wrote in message
news:3E******** *************** ***********@mic rosoft.com... Actually, don't use the p/invoke method. I just discovered that
'System.Windows .Forms.SystemIn formation.Worki ngArea' works dynamically in
the same way as the p/invoke method so use this instead. Gary
Thanks again
I was about writting the same as you did
It seems to be a very strange behaviour
Do you know if VC++ has this behaviour too?
Gary Milton wrote: Actually, don't use the p/invoke method. I just discovered that 'System.Windows .Forms.SystemIn formation.Worki ngArea' works dynamically in the same way as the p/invoke method so use this instead.
Gary
Arcer, 7. Close the program 8. Start the program again
Thanks that is the part I needed, Gary gave a good work around.
I will report something to Microsoft.
Hope this helps
Jay
"Arcer P" <No@Spam.Com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. Jay B. Harlow [MVP - Outlook] wrote: Arcer, What do you mean by "Form Quits & Reloads"? Step by step
1. Create a new solution with a single form
2. Write the Click event as follows:
Private Sub Form1_Click(ByV al sender As Object, ByVal e As System.EventArg s) Handles MyBase.Click
Me.Text = Screen.PrimaryS creen.WorkingAr ea.ToString
End Sub
3. On the menu Debug click Start
4. Click the form that shows in the screen and write down the form text (formely named caption)
5. Change the size and/or position of the task bar
6. Click the form again notice that the form text did not change
7. Close the program
8. Start the program again
9. Click the form again notice that the caption reflects the new screen working area
Is it clear now?
Thanks
I was in a hurry and made an erroneous test
It works fine as well as your new approach
You are really kind
Gary Milton wrote: Actually, don't use the p/invoke method. I just discovered that 'System.Windows .Forms.SystemIn formation.Worki ngArea' works dynamically in the same way as the p/invoke method so use this instead.
Gary
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Me |
last post by:
I am about to roll out a vb.net 2003 app for screens
using 1024x768.
However some users will only have 800x600. Is there
a quick method of scaling down the screens already written
(e.g. SystemMetrics or Anchor points etc....) for these
users ? There are no bitmaps or images in this app, only
textboxes, listviews, forms and buttons.
TIA
|
by: Arcer P |
last post by:
Situation 1 (erroneous):
TaskBar changes
Screen.PrimaryScreen.WorkingArea still returns the old rectangle
Situation 2 (OK)
TaskBar changes
Form Quits and Reloads
Screen.PrimaryScreen.WorkingArea returns the new rectangle
How to correct the 1st situation?
|
by: Chen |
last post by:
I want to know the screen resolution before launch my VB .NET windows form so the form can fit the screen nicely. Is that possible? Thanks.
|
by: Dino Buljubasic |
last post by:
How can I get programmatically screen width of my screen when I start
my application?
Thank you,
Dino
|
by: Bala |
last post by:
Hi,
My current vb code having screen keyword. can anyone tell me what is the
equalent in vb.net?
frm.Top = (Screen.Height - frm.Height) / 2
frm.Left = (Screen.Width - frm.Width) / 2
thanks
bala
| |
by: FabriceG |
last post by:
I'm french,
and I would like find the screen width and height without using the screen
object.
Can you Help me ?
|
by: Bill Nguyen |
last post by:
My VB.Net app requires a minimum monitor resolution of 1024 x 768.
How to get user's screen resolution and set it to the minimum at runtime?
Thanks
Bill
|
by: iwdu15 |
last post by:
hi, is there anyway i can make my windows form to be full screen? thanks
|
by: ManwSloHand |
last post by:
ARGH! I have a c#.net web application. I need to retrieve screen height
and width into a variable. I know this is incredibly stupid but HOW THE
HECK DO I DO IT??!?!?!
A copy to rick1ryan@gmail.com would be much appreciate also.
Thanks in advance.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |