A few questions Hello, I've got a few questions. I'm a complete newbie to Visual Basic anyway, so if someone could help me would be great
How can I get data from clipboard to a textbox
Hoe do I get data from a register value to a textbox
Does with VB2005 express edition created applications require .NET to be on the computer
Can I start a console application (for example pause.exe from system32) in a with Visual Basic created console app (if so, how )
How do I start applications from a harddisk (for example C:\WINDOWS\explorer.exe)
(How) Can I kill a process Thanks already Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

Why To Not Use Threading.Sleep in Your Application First of all, I hope that everyone who is interested joins in this conversation especially SJ, Carsten, Spotty, Andreas and Nobugz.
Experienced developers here often see new developers experiencing difficulty after calling Threading.Sleep and more experienced developers take issue with its use but rarely is there ever a comprehensive explanation for that. I thought I¡¯d start a thread on this with background as to why we say these things. First of all some background information is needed.
In Windows operating systems, when one runs a process, they are starting a process. A process is a contextual environment for a program and it will allow a program to call the things it needs to run. These aspects of a process are kept fairly transparent to a developer but a process has properties external and internal to it. Externally, a process needs to send and receive messages so that controls (including forms) can behave as expected. Internally, transparent to basic developers there are message pumps for dispatching these messages to a users code and controls. A basic property that is expected of a process is that it be able to send and receive these messages which enable Windows to work. Threading.Sleep disables that ability. Often we see upset users who have strange problems who have just called Sleep. ¡°Sleep¡± disables a process ability to respond to anything internally or externally for the duration of Sleep call. Fundamentally then, a basic principle of a windows environment is that it is event driven and sleep disables the ability to process any and all events. Symptoms will be controls not working and forms not updating.
Often the new developer wants to wait on something and they call sleep and because the basic properties of a process have been altered, the new user see unexpected results.
Here is a design often seen here:
Private Sub PD()
While Not Condition ¡® User Loop
¡®Process Data ¡®Process Data Sleep
If SomeCondition then Condition = true
End while
There is a strong desire on the part of the beginner to want to use sleep to manage basic design flaws which disables a programs ability to respond to internal messages and events. Beyond the process put into sleep states inability to respond to low Level GUI messages, the process also cannot respond to timers.
In other Operating systems there are states analogous to Sleep which is not as severe. A process can wake up to handle asynchronous execution so you might see designs analogous to this:
Subroutine Main()
Hibernate
End Sub
ASynchronousHandler1
End Sub
ASynchronousHandler2
End Sub
Such a program is immediately put to sleep and when there is the delivery of an asynchronous event, it¡¯s processed and the process goes back to sleep. The event could be a timer expiration or I/O completion etc. This architecture is useful for a program that handles something and then goes back to sleep. In other words, it¡¯s the basic design for a server. There is no analogous state in Dot Net and hence other techniques are used. This discussion would not be meaningful without offering models for the proper way code deal with issues like these:
Class Whatever
Protected Structure Wood
Public Arg1 as integer Public Arg2 as Integer
End Structure
Private Wood1 as Wood
Protected friend withevents tmr as new System.Windows.Forms.Timer
Form1_load ( ByVal sender As Object , ByVal e As System.EventArgs) _ Handles Form1.load
Tmr.stop tmr.interval = 250 ¡® one quarter of second interval
¡® Your load code
End Sub
Private Sub ProcessData(ArgA, Argb, ArgC)
Wood1 = new wood
Wood1.Arg1 = ArgA ¡® pack up data to process (Context) Wood1.Arg2 = ArgB
Tmr.Start
End Sub
Private Sub Tmr_Tick ( ByVal sender As Object , ByVal e As System.EventArgs) _ Handles Tmr.Tic
Tmr.stop
¡®Unpack the data and process it
¡® From the data determine if we are finished
If Finshed then CompletionRoutine(wood1) else Tmr.Start
Return
End Sub
¡®
Private Sub CompletionRoutine(Wood1 as Wood)
¡®resume whatever you need to do
End Sub
End Class
This way the process never goes to sleep and remains responsive to users and data. With a little added complexity much is gained. I¡¯ve written over one hundred thousands lines of Dot net and have only used Sleep once. It was in a toolbar which moved itself. The effect I wanted was a gliding effect so I¡¯d move the toolbar a couple of pixels and sleep for a few milliseconds, schieving exactly the effect I wanted. But here is what often turns up in this forum:
Private Subroutine Foo()
WebBrowser.Nagivate(¡°www.foo.com¡±) While Not WebBrowser.DocumentComplete
Sleep (50)
End While
¡®Continue processing
End Sub
This is REALLY BAD code. What if the URL is not there or it times out This process will never wakeup and sit like the rock of Gibraltar on your desktop until you kill it with Task Manager. Here, the user should have used an event:
Private Subroutine Foo()
WebBrowser.Nagivate(¡°www.foo.com¡±)
End Sub
Private Sub WebBrowser_NavigationComplete ( ByVal sender As Object , _ ByVal e As System.NavigationEventArgs) _ Handles WbBrowser.NaVigationComplete
¡®Process the data and continue
End Sub
I¡¯ve come to see calling Threading.Sleep is having strayed into a fundamental design error, the possibility that a developer does not understand event handlers or they have missed a control or a component's events. Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

HasMorePages Hell Hi everybody... (me again with printing questions...)
I have a printdocument, that uses a very complex group of queries and calculations. so, exit the printpage event, to print a second page, are near to impossible, since that approarch needs to make again all the calculations and queries for the new page. Exists another way to do that (a second page) without exiting the event
Thanks Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

How to make the registry settings effective without restarting the system I have developed a program to disable the USB Read and Write access with the help of registry. But every change requires a Restart which is not feasible in my case. Is there any feature or process, which resolve this issue, that is, to make the modification in registry effective without restarting the system. The solution is required in VB.NET. Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

Error in compilation(#using <mscorlib.dll>) Hey All - I have a small problem. i try to compile a code and which gives me the foll error Error 1 fatal error C1190: managed targeted code requires a '/clr' option what could be the possible reason #using <mscorlib.dll> error seems to come at this line #using <System.dll> using namespace System; using namespace System::Text; using namespace System::IO; using namespace System::Net; using namespace System::Net::Sockets; using namespace System::Collections; can any 1 suggest me a sollution Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

Printing question ... print on angle? How can I print a line of text on an angle ... say at a 45 or 90 degree angle or any angle for that matter
Is this possible in VB express Thanks... Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

Accessing the sound card I am making a program that opens another program when a sound is being played. I need to know how to access the sound card, without using any other programs except VB Express 2005. I want it to notice a sound is playing, then open another program. Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

Printing Hi,
How would i "capture" the print event and get information like the user that told it to print, pages in the document etc.
thanks Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

I don't know where to start! please help me out! Hello World!
Yes, I know that just by saying that you all know now that i'm an Amateur (and some of you probably want to hurt me because I said that), the thing is that i've read an unlimited number of tutorials on how to quickly pick-up MS Visual Studio, and it's just too confusing because there are so-many different programs involved.
A little about myself, I studied my first year in university in computer scoences, and all we learned was C++, and I wasn't the sharpest nail in the toolbox I must say. So I can't get too far with programming unless I really try and i'm being babysat through it.
Now I didn't come on the forums to write a novel so i'll go to the point: I'm a manager for a Computer Access Centre (a place where anyone can access computers). And I need to keep stats such as Who comes in for how long, and what for, and what age and so-forth. So I know I need to deal with Databases (and I know my way around Access, is that a good thing ) And with those statistics, I need to create a monthly report which involves graphics (Excel) and things like how many new members did we have this month, and for how long where certain users on the computers and such.
But there are so-many different programs within MS Visual Studio that I don't even know where to start! What I was hoping for is to create .exe program that could keep track pf those things and use MS Office to represent to stats (so that everything would be done automatically).
So I wrote all that to ask a simple question that could have multiple answers: Where should I begin Is there a program/template that allready exists for this kind of stuff Is there a web site that I could go on that could really help me in my situation. Which is better: C++ or C#
arrgh... sorry for being like this, I just don't kow what to do anymore.
Thanks in advance, Sgt Phototech (yeah, i'm rather a multimedia guy, not a programmer...) Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

CType Trouble I am trying to make a small amount of code save me from having to manually write everything out.
What I have is this so far
Dim Box As CheckBox = CType (sender, CheckBox)
Dim W As Integer = 1
For W = 1 To W = 7
If CType ( Me .Controls( "rC" & Box.Name.Substring(W)), CheckBox).Checked = True Then
CType ( Me .Controls( "rW" & Box.Name.Substring(W)), CheckBox).Checked = False
ElseIf CType ( Me .Controls( "rW" & Box.Name.Substring(W)), CheckBox).Checked = True Then
CType ( Me .Controls( "rC" & Box.Name.Substring(W)), CheckBox).Checked = False
End If
Next W
I want it to check if rW1 is checked, and if it is uncheck rC1, and the other way around.
Right now it just seems to ignore the code, and as you can see I want to use a FOR NEXT to check every check box whenever one is clicked.
If this is possible, then I would also like some help with this other code.
Dim HR As TextBox = CType (sender, TextBox)
If CType ( Me .Controls( "rC" & Box.Name.Substring(W)), CheckBox).Checked = Not Box.Checked Or CType ( Me .Controls( "rW" & Box.Name.Substring(W)), CheckBox).Checked = Not Box.Checked Then
CType ( Me .Controls( "hr" & HR.Name.Substring(W)), TextBox).Enabled = False
Else
CType ( Me .Controls( "hr" & HR.Name.Substring(W)), TextBox).Enabled = True
End If
I want it to disable a textbox named hr1 to hr7 if a checkbox is checked, so hr1 would be disabled it rC1 was checked, this would also go in the FOR NEXT above.
Right now it says it cant convert HR from checkbox to textbox so I am doing something wrong
Thanks for any help Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

VISUAL STUDIO hello, i am a student and am keen in learning visual studio, can someone please tell me which edition of visual studio to start with and what is the best way to learn the coding. Thank you very much. Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

iTunes causing Loader Lock For some reason, when I have iTunes running, and I run a program I'm working on, it stops and gives me the error "LoaderLock was detected" with the details being "Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang." When I try it again with iTunes closed, it works just fine, with no error messages of any kind. Since this program is going to be working with iTunes, I need it to not do this. Does anyone have any idea what's going on Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

VB form dies when lost focus Hi,
I am using VB 2005 Express and have written an application to syncronize a network folder to a local folder. The copy is fairly sizeable so it is being run from a BackgroundWorker thread. I have written a 'While' loop to flash a label on the form that says 'Please wait...' to the user so they know that all is well and not to do anything stupid like end task. This works fine, but as soon as I click on another window and the focus is lost from Form1.vb to (for example) MS Outlook, the form stops what it was doing and eventually displays as (Not Responding). The code I have is:
Code in button1:
BackgroundWorker1.RunWorkerAsync()
while BackgroundWorker1.isBusy
label1.visible = true
refresh()
system.threading.thread.sleep(500)
label1.visible = false
refresh()
system.threading.thread.sleep(500)
end while
Code in BackgroundWorker1:
dim SourceDir, DestDir as string
SourceDir = "X:\AcademyClientProducts\ACP"
DestDir = "C:\Program Files\AcademyClientProducts\ACP"
My.Computer.FileSystem.CopyDirectory(SourceDir, DestDir)
I dont understand why this would happen, any help is greately appreciated. Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

no visual studio template found I just installed the recently released Visual C# 2005 Express. When i tried to create a new project. I got this error message "no visual studio template found". I went to the "event viewer" in "Administrative Tools" to see the log. I found the message : "The Visual Studio template information is out of date. Regenerate the templates by running 'VWDExpress /installvstemplates' or reinstalling Visual Studio. Note: corrective action requires Administrator privileges. " I reinstalled the VC# but the problem is still there. Anyone met this problem before Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

D What on earth are 'Pumping Wait Primitives'? (CSV related) Hi, The following code takes a csv file from disk (65,536 values, no spaces, no text delimters, all on one line), and converts the values into a byte array. Private Sub csv2Byte(ByVal csvFilename As String) Using csvReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(csvFilename) csvReader.TextFieldType = FileIO.FieldType.Delimited csvReader.SetDelimiters(",") Dim csvFile As String() Dim n As Integer Dim csvValue As String Dim myBytes() As Byte Dim hexValues() As String Dim index As Integer = -1 While Not csvReader.EndOfData Try csvFile = csvReader.ReadFields() For Each csvValue In csvFile index += 1 n = Convert.ToInt32(csvValue) 'Convert 'n' to a BYTE and add it into the array myBytes() 'at index position pointed to by variable 'index' myBytes(index) = CByte(n) hexValues(index) = Hex(n) MsgBox("As text = " & csvValue & "; and as an integer = " & n.ToString) Next Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException MsgBox("Line " & ex.Message & "is not valid and will be skipped.") End Try End While End Using End Sub End Class However, during debugging and after a pause the following error message pops up: The CLR has been unable to transition from COM context 0x1a1418 to COM context 0x1a1588 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations. Can anyone decypher this error message, and more importantly, suggest what may be causing it. The code appears reasonable. Thanks Wibs Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

App doesn't run on Windows Server 2003 I'm using Visual C++ Express 2005 and I'm trying to build an app that uses a third party DLL. I also have the associated lib file, so I've listed it as a dependency under Linker/Input. My app works fine on Windows XP (both on my dev PC and on other machines without Visual Studio installed), but I need this to work on a Windows Server 2003 machine (with SP1).
When I try to run my app on Windows Server 2003, I get an error that says "The application failed to initialize properly (0xc0000005)." I ran depends.exe and all the required DLLs are found. This error doesn't occur unless I reference one of the functions in the third party DLL - I built a couple versions - one that calls functions from the DLL and one that doesn't.
I've written my own test DLL to see if I get the same error when referencing it, but it works fine.
Any ideas what could be wrong My build is in release mode, and I've run vcredist_x86.exe on the target machine. I thought perhaps the third party DLL that I'm using is corrupt, but it works on XP.
Thanks Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

Compress Folder Simply i want to Compress Folder to a zip file.
I know how to Compress Files and have some codes do it very will.
In the class.vb
Imports System.IO
Imports System.IO.Compression
Public Class ZipUtil
Public Sub CompressFile( ByVal sourceFile As String , ByVal destinationFile As String )
' make sure the source file is there
If File.Exists(sourceFile) = False Then
Throw New FileNotFoundException
End If
' Create the streams and byte arrays needed
Dim buffer As Byte () = Nothing
Dim sourceStream As FileStream = Nothing
Dim destinationStream As FileStream = Nothing
Dim compressedStream As GZipStream = Nothing
Try
' Read the bytes from the source file into a byte array
sourceStream = New FileStream(sourceFile, FileMode.Open, FileAccess.Read, FileShare.Read)
' Read the source stream values into the buffer
buffer = New Byte (sourceStream.Length) {}
Dim checkCounter As Integer = sourceStream.Read(buffer, 0, buffer.Length)
' Open the FileStream to write to
destinationStream = New FileStream(destinationFile, FileMode.OpenOrCreate, FileAccess.Write)
' Create a compression stream pointing to the destiantion stream
compressedStream = New GZipStream(destinationStream, CompressionMode.Compress, True )
'Now write the compressed data to the destination file
compressedStream.Write(buffer, 0, buffer.Length)
Catch ex As ApplicationException
Finally
' Make sure we allways close all streams
If Not (sourceStream Is Nothing ) Then
sourceStream.Close()
End If
If Not (compressedStream Is Nothing ) Then
compressedStream.Close()
End If
If Not (destinationStream Is Nothing ) Then
destinationStream.Close()
End If
End Try
End Sub
Public Sub DecompressFile( ByVal sourceFile As String , ByVal destinationFile As String )
' make sure the source file is there
If File.Exists(sourceFile) = False Then
Throw New FileNotFoundException
End If
' Create the streams and byte arrays needed
Dim sourceStream As FileStream = Nothing
Dim destinationStream As FileStream = Nothing
Dim decompressedStream As GZipStream = Nothing
Dim quartetBuffer As Byte () = Nothing
Try
' Read in the compressed source stream
sourceStream = New FileStream(sourceFile, FileMode.Open)
' Create a compression stream pointing to the destiantion stream
decompressedStream = New GZipStream(sourceStream, CompressionMode.Decompress, True )
' Read the footer to determine the length of the destiantion file
quartetBuffer = New Byte (4) {}
Dim position As Integer = CType (sourceStream.Length, Integer ) - 4
sourceStream.Position = position
sourceStream.Read(quartetBuffer, 0, 4)
sourceStream.Position = 0
Dim checkLength As Integer = BitConverter.ToInt32(quartetBuffer, 0)
Dim buffer(checkLength + 100) As Byte
Dim offset As Integer = 0
Dim total As Integer = 0
' Read the compressed data into the buffer
While True
Dim bytesRead As Integer = decompressedStream.Read(buffer, offset, 100)
If bytesRead = 0 Then
Exit While
End If
offset += bytesRead
total += bytesRead
End While
' Now write everything to the destination file
destinationStream = New FileStream(destinationFile, FileMode.Create)
destinationStream.Write(buffer, 0, total)
' and flush everyhting to clean out the buffer
destinationStream.Flush()
Catch ex As ApplicationException
Finally
' Make sure we allways close all streams
If Not (sourceStream Is Nothing ) Then
sourceStream.Close()
End If
If Not (decompressedStream Is Nothing ) Then
decompressedStream.Close()
End If
If Not (destinationStream Is Nothing ) Then
destinationStream.Close()
End If
End Try
End Sub
End Class
And in the form1
Public Class Form1
Public Sub New ()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
m_zipUtil = New ZipUtil()
End Sub
To Compress File :
Try
m_zipUtil.CompressFile( "C:\test.txt" , "C:\test.zip" )
Catch ex As Exception
End Try
To Decompress File :
Try
m_zipUtil.CompressFile ( "C:\test.zip" , "C:\test.txt" )
Catch ex As Exception
End Try
But what about Folders How I can Compress and Decompress It.
Thank you Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

initial data not saving Hey to all,
I've build an inventory program using a MDF file, The inventory information is inputed into textboxes on a windows form with a bindingNaviagator. When I start the program with a blank datafile; the input form come up, I type my 1st item in, I go to save or add new item and the 1st item is not saved. In order to get the 1st item to save I must first click on add new item. My question, is there a way to load the initial form so it is ready to save to the file when I click on save or add new item.
Here is the code I'm using to Initially load the form.
Private Sub Form1_Load( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase .Load
Me .InventoryTableAdapter.Fill( Me .InventoryDataSet.Inventory)
End Sub
Thank, IW Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

Handling of spread sheet using C Hi ,
I am working on a project were i have to read from excel sheet and update it.
Can anyone guide me how to go about this .
Here i am using C language ,platform VC++ express edition.
Thanks in advance , Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

SQL Query Hi,
I'm having a problem with a litlle lookup SQL, i'm trying to return the cost of an item from an Equipment table on the basis of a partcode.
Please see the code
Code Snippet
Dim SQLtext, a As String a = Me.PurchaseDetailsTableAdapter.Connection.ConnectionString.Clone() Dim myCon As New SqlClient.SqlConnection(a) SQLtext = "SET @CostPrice=(SELECT CostPrice FROM EquipmentID WHERE ( EquipmentID=@EquipmentID ))"
Dim myCom As New SqlClient.SqlCommand(SQLtext, myCon)
Dim EquipmenID = "PA-01-01" Dim i As Integer = 0
myCom.Parameters.Add(New SqlClient.SqlParameter("@EquipmentID", SqlDbType.VarChar)).Value = EquipmentID i = myCom.Parameters.Add(New SqlClient.SqlParameter("@CostPrice", SqlDbType.Money)).Direction = ParameterDirection.Output
myCon.Open() myCom.ExecuteNonQuery() myCon.Close() MessageBox.Show(i)
However, when i run it i get this error message: -
"The parameterized query '(@EquipmentID varchar(8),@CostPrice money)SET @CostPrice=(SELECT' expects the parameter '@CostPrice' , which was not supplied."
Why do i need to supply a value for something i want the value returned on
What am i doing wrong
Thanks Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

Why Is It So Difficult To Save and Load Form Text Boxes? I would appreciate any help someone could give me.
I have searched this forum endlessly trying to find a way to save 60 or so text boxes on form1 to a file and then later read the information back into the same text boxes.
It seems like I have tried every bit of sample code that I can find and nothing works. I have 5 books on VBE and VB5.
I am a complete novice at this so please be gentle.
Thanks in advance for any ideas/help.
Glenn Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

Help !!! make Ftp Browser to Upload and Download files from a server I would build an FTp Browser. I want to upload and download files from my own server. How can i do it I'm a beginner....Please Help me...
Grtzz,
Noob2PsP
http://www.Noob2PsP.Co.Nr Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

Registering Visual Studio C# express When I try to register this product, I keep getting the message "The registration key you entered is not valid. Please enter the registration key exactly as it is appears on the registration website or copy and paste it into the registration key field."
I am copying it from the website and it still does not work.
The key that was given me was 0CLLDFMBJNVLRB. Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

about filesystemwatcher Hi,
Can filesystemwatcher monitor on a specific table only in a database becoz i want to prompt the user if there's a new updated or new item in my database and and choose if he/she want to refresh the datagridview.
Regards Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

Error Message when running program I am using the study guides for Visual Basic Express. Can someone tell me what the problem is in the following line of code. I copied it exactly from the lesson and I ge the message that an angle figure is expected.
<br /><span space= "preserve" >...</span><br /> The error message comes after the first forward slash. Thanks. Ray Holt Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

vs 2005 intellisense problem I had to uninstall .net framework 2.0. I have the framework 1.1 installed already. After uninstalling 2.0 the VS 2005 is not able to create an xml file xml schema. Even if I create a c# file the intellessense does not work. It editor behave as note pad. Does anybody know how to fix this problem
Thanks - Amit Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

button click event handler Hi,
I working on a webform where I have a button for the user to click and everytime I click the button, the system will run the page load code. In C# windows application, it's not like this.. you click on the button and the system will run only the button event handler code... is it possible to prevent the system to run the page load code in the webform application
I'm using ASP.NET 2.0 and C#
CHeers
Claudia Tag: Visual Basic Express Edition How to add 16x16 icon to ImageList Visual Studio Express Editions

Blackwood

I'm having trouble setting up icons to be displayed in a TreeView. The default size for TreeView icons is 16x16, and I have a set of .ico files that 16x16 (according to their properties as shown in Windows Explorer, verified by opening in Paint).

In the Designer, I add a ImageList to my form, and set it's ImageSize property to 16x16 and ColorDepth to 32Bit. Still in the Designer, I use Choose Images to add icons to the imagelist. Even though the icons are 16x16, and the ImageList is set to 16x16, the Size and PhysicalDimension properties (both of which are readonly) of the images are set to 32x32. When I use these images at runtime as icons in my TreeView, they are distorted, presumably from having been streched to 32x32 and then shrunk to 16x16.

Re: Visual Basic Express Edition How to add 16x16 icon to ImageList

Blackwood

It's hard to describe the distortion. One example is the open folder icon (the 5th icon in Shell32.dll). I extracted it to a .ico file and in the designer, added it to my ImageList (the ImageList's ImageSize property is set to 16x16). When I use the image as an icon for a TreeNode, the left edge of the folder is missing, and the right edge is fuzzy.

Another example is the icon for .xml files. In my system, this is a blue globe enclosed by "<" and ">" with two horizontal lines underneath. When I use the designer to add this to my ImageList, and assign the image to a TreeNode, the two horizontal lines merge to form one thick line.

I have found that if I add these icons to the ImageList at runtime, they look OK as long as I create the icon as 16x16:

Code Snippet

New Icon(myPath &"\openfolder.ico", New Size(16, 16))

before adding it to the ImageList. If I don't set the size:

Code Snippet

New Icon(myPath &"\openfolder.ico")

I see the distorted version.

The problem seems to be that I can't find a way to add the 16x16 version of the icon to the ImageList at design time. I find that even though the ImageSize property of the ImageList is set to 16x16, after I add the icon, the image's PhysicalDimension Property is set to 32x32.

Re: Visual Basic Express Edition How to add 16x16 icon to ImageList

Feng Chen - MSFT

Hi Blackwood,

I write a program, but I didn't come across the problem like yours. And I'd like to know how exactly do you extract that 5th icon The 5th icon of shell32.dll actually has several sizes: 16x16, 32x32, 48x48 and each of them has 4bit, 8bit and 32bit versions. Which version you are talking about

Re: Visual Basic Express Edition How to add 16x16 icon to ImageList

nobugz

I think I can reproduce your problem. When I use MicroAngelo (an icon editor utility) to extract icon #5 from shell32.dll, save it to disk, then add the icon to a 16x16 ImageList, I see a poorly interpolated version of the icon. When I edit the icon and remove all formats except 16x16x256 colors, I get a nice sharp looking version of the icon.

Looks like ImageList isn't smart enough to select the icon that best matches the ImageList's ImageSize and ColorDepth property. It never was a particularly smart control. This doesn't quite match your scenario but the outcome is the same. Seeing a PhysicalDimension of 32x32 hints that something went wrong when you extracted the icon. I see 16x16 on the edited icon but 32x32 on the un-edited icon.

Re: Visual Basic Express Edition How to add 16x16 icon to ImageList

Blackwood

I used a program called GetIcons to extract all the icons from Shell32.dll. It appears that the extracted icon (in the .ico file) contains at least a 16x16 and a 32x32 icon. I assumed that adding the icon at design time to a 16x16 imagelist would cause the 16x16 version of the icon to be selected, but apparently that is not the case.