|
if you want to display them in a form try a listview. You can dynamically add items. This link will show you how:
http://abstractvb.com/code.asp?A=968
You can then add each one you want to and set the images etc.
Posted by The ANZAC
|
|
|
|
|
Thanks for replying. I tried displaying the images in a ListView, but to do so I had to add the image I needed into an ImageList. But an ImageList doesn't allow any files except strict image/icons.
Is there any chance that .NET has a class that will view DLL icons automatically?
Thanks again!
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
Not that i know of, perhaps try a new post that asks this question specifically and you may get a better response, you've pretty much reached the extent of my knowledge in this field...lol which obviously isn't much.
Posted by The ANZAC
|
|
|
|
|
I've tried that code before and your right it does save them at a low quality. However, the extraction works just fine and as far as I know it's the only way to get at the icons. You don't actually need to save the icons to view them however. Once the icon has been extracted you can add it to your imagelist and then add a new item to the listview. What I would do is use the code from that example as a base and modify it to suit your needs. I created this example using the 'relevent' code from that project and tweaked it slightly. The end result is a method you can call to popullate a listview with the icons from a given file. Feel free to use it or modify it to suite your needs. I did it quickly so who knows what I missed but it worked great when I tested it. All you need to do is pass to the function the file you want to read and the listview to use for display.
Imports System.IO
Public Class ExtractIcon
Private Declare Function ExtractIconEx Lib "shell32.dll" Alias "ExtractIconExA" _
(ByVal lpszFile As String, _
ByVal nIconIndex As Integer, _
ByRef phiconLarge As Integer, _
ByRef phiconSmall As Integer, _
ByVal nIcons As Integer) As Integer
Private Declare Function DestroyIcon Lib "user32.dll" (ByVal hIcon As Integer) As Integer
Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Integer, ByVal lpszExeFileName As String, ByVal nIconIndex As Integer) As Integer
'calls API to determine how many icons are embedded in the file
Private Shared Function GetNumberOfIcons(ByVal fl As String) As Integer
Return ExtractIconEx(fl, -1, 0, 0, 0)
End Function
'Extracts each icon from the file given, and saves it to the destination directory
Public Shared Sub ExtractIconsFromFile(ByVal file As String, ByVal list As ListView)
Dim info As New IO.FileInfo(file)
Dim numicons As Integer ' number of regular icons in the file
Dim retval As Integer ' return value
Dim hInstance As IntPtr = System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0))
'Make sure we have an image list for our listview
If list.LargeImageList Is Nothing Then
Dim iconImageList As New ImageList
iconImageList.ImageSize = New Size(32, 32)
iconImageList.ColorDepth = ColorDepth.Depth32Bit
list.LargeImageList = iconImageList
End If
list.Items.Clear()
numicons = GetNumberOfIcons(info.FullName)
For i As Integer = 0 To numicons - 1
retval = ExtractIcon(hInstance, info.FullName, i)
If retval > 0 Then
Dim ico As Icon = Icon.FromHandle(New IntPtr(retval))
list.LargeImageList.Images.Add(retval.ToString, ico)
list.Items.Add(retval.ToString, retval.ToString)
End If
DestroyIcon(retval)
Next
End Sub
End Class
-- modified at 1:31 Saturday 3rd March, 2007
|
|
|
|
|
Thanks a lot! It works great.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
Hello coding community,
I have had a request from one of my clients to build a (VB 2005 per client) application for a particular in house task. Before I start coding, I would like to here some feedback comments to see that I ‘m approaching this project in the correct way.
Task Overview:
The client has multiple fixed scanning devices, reading carton barcodes (unique) on particular production lines. The scanning devices output the barcode data via TCP communications at a rate of approximately one barcode a second /per scanning device.
The requirement at stage one, is that the barcode data scanned will be sent to an in house server box, de-coded and written to a SQL table.
My Project Scope Ideas:
1. Based on the scanning devices are communicating via TCP, I should be looking at socket Client/Server application to receive the scanned barcode data.
2. To guarantee that data from all the devices will be sent to my application, should I make the scanning devices connect as a socket client?
3. The scanning devices only have a limited onboard buffer to hold the scanned barcodes. This in mind, I think that I should break the task into two different applications. One application handles the communications and data received. The second application does the barcode de-coding and writing the data to an SQL table.
4. Because of the limited onboard buffer issue, the applications need to be independent of user logins. Therefore, I think maybe making the applications into windows services would make more sense.
Overview of My Ideas:
The “DeviceCommunications” windows service would listen for scanning device connections on a particular TCP port. On receiving any data from a device connection, the service would write the data to disk (I/O file). Writing the data to a disk file, achieves two things, one the data from all devices as stored in a single file object and secondly it makes the process independent of de-coding the barcode and making database connections to write the data to an SQL table.
The “DataImport” windows service would run at periodical times and check to see if barcode data has been written too the file object. If so, then it would check if a database connection possible, then de-code each barcode and write the de-coded data to the SQL table.
Because a service should not interact with the desktop, a third windows application would be required to allow for configuration of the services and maybe some monitoring the services actions.
Sorry this is a bit long winded, I was trying to you some detail info to work with. Please feel free to make any comments you like. I have an open mind on this project, just want to achieve a good result.
Regards Ian
|
|
|
|
|
i want to start a video in a powerpoint slide how can i do?
i tried sending mouse click into the video, however it is not working
mouse_event, sendinput, sendmessage, peekmessage... all of these functions don't work to send click into video
Please write what ever you know to solve my problem
|
|
|
|
|
Hello,
I'd like to be able to create a crystal report containing strings that are contained within textboxes and labels on a from, using the click event of a button.
Is this easily done?
Thanks
|
|
|
|
|
I am having difficulty. I tried to figure how to describe it in one sentence, but couldn't.
We have a supplier who supplies what they call a PC Developer Kit. In VB6.0, it allows you to add a project reference (it is linked to an .exe). This would give you access to several data types that you can use to get information from their equipment via an Ethernet connection. I'm using the following statement in VB6.0:
Dim Robot1 as Robot<br />
Dim ioDIN as ioType<br />
<br />
Set Robot1 = New Robot<br />
Set ioDIN = Robot1.IOTypes(DigInType).Signals.Item(Index:=0)
I'm trying to figure out 1) if it possible to use this in .NET, and 2) if so, how.
I've tried (VB.NET code):
Dim Robot1 as Robot<br />
Dim ioDIN as ioType<br />
<br />
Robot1 = New Robot<br />
ioDIN = Robot1.IOTypes(DigInType).Signals.Item(0)
I get an unhandled COM exception with "Illegal port number" and it is pointing to the 0.
Then I tried (VB.NET code):
Dim Robot1 as Robot<br />
Dim ioDIN as ioType<br />
<br />
Robot1 = New Robot<br />
ioDIN = Robot1.IOTypes(DigInType).Signals.Item(1)
I get the error: Unable to cast COM object of type 'System.__ComObject' to interface type 'Robot.IOType'. Now it is pointing to the 1.
What is going on when you reference an .exe? How does it give you access to new data types? I'm not sure what the (Index:=0) is exactly doing in the VB6.0 code and why it needs to be that way. I did find out that I can make it work the same by changing it to (1). Is there a way to convert the code to something that would work in VB.NET?
Any help with any part of this is appreciated.
Brad
The secret to creativity is knowing how to hide your sources. - Albert Einstein
|
|
|
|
|
What you're doing is right, in terms of accessing the COM objects. The issue lies elsewhere ( the threading model, perhaps ? )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello Folks,
I would like to open an excel and app with visual studio 2005 without using COM. It seems like I should be able do this with the Microsoft.Office.Tools.Excel.
It seems like I should be able to open an excel application like I could with Microsoft Excel 11.0 Object Library. I don't want to use the Microsot Excel Oject Libaray because when I try to use it with Microsoft.Office.Tools classes I get a lot if InvalidCastExceptions like when I try to set a Microsoft.Office.Tools.Excel.Workbook = to an Excel.Workbook.
Is there a Microsoft.Office.Tools.Excel.Workbook method equivalent to Excel.Worbooks.open("c:/myxl.xls")?
It seems strange that we have save and save as in Microsoft.office.Tools.excel.workbook but no open.
Also, I cannot seem to add a reference to microsoft.interop.office how can I add a refrence to this if I need to.
Please help. This is driving me nuts.
|
|
|
|
|
|
Search the arcticles for a Winsock clone written in VB.NET, author Chris Kolkman.
|
|
|
|
|
Hi,
I'm using VB.NET 2005, and would like to color a cell on a DataGridView if an exception has been invoked. I have the following code snippet:
' ############ GET THE NEW 'FROM' DATE ############<br />
<br />
Try<br />
tblRow.Item("From") = Convert.ToDateTime(strNewFromDate)<br />
<br />
Catch ex As Exception<br />
<br />
' Problem with this date field, so leave blank<br />
<br />
' Add 1 to the number of warnings count<br />
intNumberOfWarnings += 1<br />
<br />
' Colour the cell in error<br />
<br />
End Try
Is there a clever bit of code I need to use that will allow me to color this particular cell?
|
|
|
|
|
suppose in combo box i have given 3 feilds .....
and i can validate them accordin to codition...
but i want to also validate when i have selected nthin..
lets take an example...
if in box i selected "A"
then its assigning temp = 10
and nw again if m selectin nthin i.e is blank, then it shud store temp = 0;
can v do combobox1.selected= " "
then temp = 0.
m gettin error...
please tell the exact manner of coding...
|
|
|
|
|
Can you make an effort to explain more clearly your problem?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
look if v have 3 options in combobox say A, B, C
if i select A then in temp variable 10 shud be assigned..
like
if combobox1.selected = "A"
then temp = 10
if combobox1.selected = "B" then
temp = 8
nw if i select nthing means combobox is empty
then temp = 0
tell me its coding..
thanks
|
|
|
|
|
if you're using VB6, try the following:
Select Case cmbLetters.Text
Case "A"
lTemp = 10
Case "b"
lTemp = 8
Case Else
lTemp = 0
End Select
(where cmbLetters is you ComboBox)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Sir/Madam,
I have two records in my database.From the form , I am chosing the id and want that record to get displayed in the crystal report.There are two tables in the database and there is a primary and foreign key relationship between them.Now the problem is , both the records are comming.I have created links between both tables in the reports.Is there any way to create the crystal report dynalically or can i pass the parameter to show the report.
Parameter means that id which has primary and foreign key relationship.
But I don't know the code how to pass the parameters.
and parameters should be passed at both ends (I mean in the crystal reports as well as on the coding side)??
I don't want to generate the window that ask me which id u want to select .
Please help.
Thanks and regards
Pankaj
|
|
|
|
|
Sir/Madam,
I wanted to know in which condition I should write the following line of code.I mean what is the utility of that.
application.Run(new formname)
Thanks and regards
Pankaj
|
|
|
|
|
amaneet wrote: I wanted to know in which condition I should write the following line of code.I mean what is the utility of that.
It runs you windows forms based application. If you don't write that no form will appear.
|
|
|
|
|
Sir/Madam,
I wanted to know the basic difference between implicit and explicit conversion.
Thnaks and regards
Pankaj
|
|
|
|
|
Link :Data Type Conversion[^]
In Visual Basic, data can be converted in two ways: implicitly, which means the conversion is performed automatically, and explicitly, which means you must perform the conversion.
|
|
|
|
|
wht i want to do is
on first click --text in label change
on second click again text change?
how to do this
|
|
|
|
|
You have to do a two states button, either using the text itself to identify the current state or by means of an auxiliary variable.
For instance:
(1) If myButton.Text="ON" Then myButton.Text="OFF" Else myButton.Text="ON"
(2) IF bIsON = True Then
bIsON = False
myButton.Text="OFF"
Else
bIsON = True
myButton.Text="ON"
End If
where,of course, bIsOn must be a variable of the Form (or a Static one inside the event handler).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|