473,563 Members | 2,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SystemParameter sInfo Failing in VB.net "Slide Open Combo Boxes"

1 New Member
Could not figure out on how to reply to the last article with the same name. When I logged out it asked me to login and when I logged in there was no "post your reply" option, perhaps there is functional bug on this website, anyhow.

I had a similar problem where getting the value was okay but saving the value did not work, so I hope my solution helps, if someone else has a similar issue of understanding how to declare and use api functions.

[FYI: I was designing a user drawn combobox and the "Slide Open Combo Boxes" windows setting was effecting the display of the drop down portion of combo box. I got no text in the header portion and if my DataSource was only a few rows it showed no data at all and the height of the combo was only a few pixels !!?? My workaround was to toggle this windows setting value off then on again in the DropDown and DropDownClosed events respectively:
Expand|Select|Wrap|Line Numbers
  1. <DllImport("user32.dll", EntryPoint:="SystemParametersInfoA", SetLastError:=True, _
  2.                CharSet:=CharSet.Ansi, ExactSpelling:=True, _
  3.                CallingConvention:=CallingConvention.StdCall)> _
  4.     Private Function SystemParametersInfoGet(ByVal uiAction As SPI_INDEX, ByVal uiParam As UInteger, _
  5.                                           ByRef lpenabled As Boolean, ByVal fWinIni As UInteger) As Boolean
  6.     End Function
  7.     <DllImport("user32.dll", EntryPoint:="SystemParametersInfoA", SetLastError:=True, _
  8.                CharSet:=CharSet.Ansi, ExactSpelling:=True, _
  9.                CallingConvention:=CallingConvention.StdCall)> _
  10.     Private Function SystemParametersInfoSet(ByVal uiAction As SPI_INDEX, ByVal uiParam As UInteger, _
  11.                                           ByVal lpenabled As Boolean, ByVal fWinIni As UInteger) As Boolean
  12.     End Function
  13.  
  14.     Public Function SlideOpenComboBoxes(ByVal TurnOn As Boolean) As Boolean
  15.         Dim fResult As Boolean
  16.         Dim spValue As UInteger
  17.         Dim originalMaskOn As Boolean
  18.  
  19.         fResult = SystemParametersInfoGet(SPI_INDEX.SPI_GETCOMBOBOXANIMATION, 0, originalMaskOn, SPFIPersistance_INDEX.SPFI_NONE)
  20.         Dim oWin32Ex As New Win32Exception()
  21.         If fResult Then
  22.             If TurnOn <> originalMaskOn Then
  23.                 fResult = SystemParametersInfoSet(SPI_INDEX.SPI_SETCOMBOBOXANIMATION, 0, TurnOn, SPFIPersistance_INDEX.SPFI_NONE)
  24.                 oWin32Ex = New Win32Exception()
  25.             End If
  26.         End If
  27.         If Not fResult Then
  28.             Throw oWin32Ex
  29.         End If
  30.         Return originalMaskOn
  31.     End Function
  32. End Module
I noticed 2 difference in the code snippets provided from the previous article compared to my solution above:
  1. The first was the order of calling the parameters. I passed the variable I want to get or set into the call to the api as the third parameter. The previous article had Return = SystemParameter sInfo(SPI_SETSC REENSAVEACTIVE, lActiveFlag, 0, 0), so maybe the order is incorrect if I am not mistaken.
  2. The other difference is I have two references to the api declaration, one for getting and the other for setting. The difference is use of ByVal (for setting) versus ByRef (for Getting) for the third parameter.
My solution was purely a trial an error effort I came to after googling and reading enough articles. I wish there was some documentation of the do's and dont's of API calling.

Without giving you my entire code base, if anyone else has experience owner drawing issues where this setting effected your code I would like to hear about your short comings and thus your work arounds and solutions to your issues.
Jul 27 '11 #1
0 4010

Sign in to post your reply or Sign up for a free account.

Similar topics

1
4643
by: Loreen | last post by:
I have been going through user groups and forums for the past 3 hours trying to figure out how to add "all" to my combo boxes. I've got two unbound comboboxes. Once only has one field "FiscalYear" and the other had two "DonationTypeID" and "DonationType". Both comboboxes have Table/Query as the control RowSourceType and I setup the...
1
2237
by: Niranjan | last post by:
I have a relatively straight forward report. The query that populates data for this report is complicated. The report opens without any problem and I can print it as well. However, If I have another form open (has about 12 combo boxes) and then I run the report, it appears on the screen, no problem. When I print the report, I get 'Cant open...
1
2941
by: Jeff_F | last post by:
Hi all. Question in two parts. I'm looking to add two combo boxes. The first will contain regions and the second will contain employee names which correspond to the region selected in the first combo box. What is the most efficent way to go about this type of layout - in terms of code and populating the combo box??? thx.
15
2945
by: sara | last post by:
Hi I'm pretty new to Access here (using Access 2000), and appreciate the help and instruction. I gave myself 2.5 hours to research online and help and try to get this one, and I am not getting it. Simple database: I want to have a user enter Supply Orders (just for tracking purposes) by Item. The user may also enter a new item - "new"...
3
1890
by: Joanne | last post by:
I have searched through previous threads regarding this error. I went back through all my code to make sure I closed and set to nothing all open db's and rs's. However, I still have one computer getting this error. This problem does not occur with any other users - some of whom use the database continuously. The user logs in, then goes...
3
3632
Zwoker
by: Zwoker | last post by:
Hi Everyone, I have a query that uses criteria from combo boxes in the form that runs it. When I had only discrete values in the combo boxes that matched the data that was being queried, the result was great. I was getting only the records that I wanted. As soon as I added "ALL" to the form's combo item lists I ran into trouble. ...
1
5120
by: vincehallam | last post by:
Hi newby here sorry if this sounds bread and butter stuff. Using MS Access 2003 On a Form I want two Combo boxes which are getting their data from a table. The Combo boxes are A "Price 1" & B "If Bank Holiday Price Two". Is it possible to have "Price 1" visible as default but then if I tick a check box to have "If Bank Holiday Price Two" pop...
4
3109
by: mistyblu | last post by:
I wrote an Access97 application using VBA for a company many moons ago and they have approximately 20 users. All has been hunky dory for a long time but suddenly they have a combo box error on 3 of the pc's. The identical application works fine on the other 17 pc's. The O/S is Windows XP Pro service pack 2. There are several combo boxes on...
3
13086
scubak1w1
by: scubak1w1 | last post by:
Hello, Did a search here, manuals and Googled, etc generally, so apologies if I did not find the answer to my issue - that is, I try and 'self help' as mush as I can... I adjusted my postgresql.conf file to set as on 'explain_pretty_print' Now in pgAdmin (1.10.0) when I right-click a database in the 'usual' way, Maintenance, any of the...
20
2959
by: Daniel Yantis | last post by:
Combo Box 1 Displays a query/list with 2 columns: SELECT Classes.CLASS_DESC, Judges.Judge, * FROM Classes; Combo Box 2 Displays a query/list: SELECT Judges.Judge FROM Judges; I want Combo Box 2 to change based on Combo Box 1 answer. Combo Box 2 will still be editable but its default will be based on Combo Box 1. Example: I have...
0
7664
marktang
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...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7638
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...
0
7948
tracyyun
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...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.