How To Properly Open A Image Using Bitmap Class And Dispose It Properly
Jun 22, 2010
I am looking for a code snippet which opens a image, creates a clone of this bitmap in memory disposes this opened image so that all handles are closed.
Usually we can open a bitmap using this[code...]
the following code however keeps the Image File locked until the application is running, any suggestions how to dispose it properly. (So that no handle is left open )
Things i already tried: use dispose method of bitmap <= doesnt work (need to write implementation)
Using Block also doesnt work.
View 2 Replies
ADVERTISEMENT
Jul 7, 2011
I have prided myself in having a pretty clean code however in the game I am making I have a player view (showscreen) and a host view, which is a copy of the player view (on a smaller screen). This way the host can see what's going on.The problem is that the graphic doesn't dispose properly and Garbage Collector gets it, though I have noticed it will crash if GC doesn't get it in time. The larger the showscreen window the more junk gets put into memory, which sucks.I thought I had everything correctly disposed below but still doesn't get the job done.
[code]...
View 9 Replies
Aug 9, 2010
I am creating a class that represents a vehicle of some kind, called "Transporter". The number of wheels the vehicle has is variable, and is stored in a property. I want the wheels themselves to have their own properties, individually. How do I properly set up a class that is nested within another class? Right now I have two separate classes, where one of the vehicles' properties is a collection(of WheelModule). I just want an outsider opinion, as I have never done this before.
VB.net
Private ModuleCountVal As Integer
<Description("Number of Wheel Modules")> _
Property ModuleCount() As Integer
[code].....
View 16 Replies
Feb 23, 2012
I found a class that saves column order and column width for a list view but i cant get it to work properly.
Public Class cListviewHelper
Private Declare Function ListViewiColumnOrder Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, ByRef lParam As Integer) As Integer[code].....
It saves the right number of columns but not in the order they are.It always saves them like this in the registry "0,1,2,3,4,5,6"
View 8 Replies
May 5, 2009
I am trying to use the Command Line Arguments during the Form_Load event to load the file a user might have selected in windows explorer.
I have set some file associations during setup, so that any ".script" files will be associated with my application. However, my application can also open other (text based) files (it's a text editor), and I would like the user to be able to use "Open With..." and select my application to open the files in my application directly.
I have to use the Command line arguments for this, which will hold the filename(s) of the selected files, correct?
So I did this:
vb.net
For Each arg As String In Environment.GetCommandLineArgs()
If IO.File.Exists(arg) Then
OpenFile(arg)
End If
Next
Now, when I open a ".script" file, my application opens and the correct file is loaded. However, in addition, the EXE file is also loaded for some reason! It has opened two files, <Applicationname>.EXE and the file I wanted to open. Because the EXE file is obviously not just a text file, it just displays some random characters, but I don't want it to open that of course...
Also, if I run the application in the debugger (visual studio), it opens the <ApplicationName>.vshost.exe file... So I thought, I can check for the extension of the argument, and only open it if it is a ".script" file. BUT I don't want that! I also want the user to be able to select any file and choose Open With... and select my application. That won't work if I check for the file extension...
View 4 Replies
Oct 23, 2006
I am able to save images from a picturebox in the .png format properly, but not using .jpg or .gif formats. What I get is a black image only with .jpg and .gif. The picturebox has a white background with text and lines on it which I generate via VB coding.
View 13 Replies
Nov 20, 2011
Basically my script doesn't properly close Word, and it still remains open. Then when I try to run the script again it says its Read-only as its opened..What I need it to do is - put the TextBox1 info onto the DOC - and print it. I don't want it to save, as it's a template. I've tried saving it somewhere else as a "temp" to get rid of this read only but it still doesn't work.Another issue also is that it's trying to close the document before the printing dialog disappears, so I've had to put a timer
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim pName As String[code]....
View 8 Replies
Jan 1, 2010
I have a form which won't open properly under certain circumstances if a particular Button is set to visible = false. Under the same circumstances if the Button is set to visiblbe = true the form does open properly or if the line of code at a certain place where it is set to either visible = true or visible = false is commented out or not there then the form opens properly. If any one of the 5 phases on my form are turned on then the problem doesn't ever occur but if none of the phases are on then the problem does occur. I just found a fix for the situation but I still am not clear about what exactly is going on.
[Code]...
View 14 Replies
Oct 14, 2011
When i scan a image from my scanner it's scan properly if the file exist with same name programme show error it's any way to replace this name and save the properly.
View 11 Replies
Jun 14, 2009
I have an app that loads a jpg into a picyure box, then updates exif data in exifworks classThe problem is that when I save the image(from image used for picture box) or class (to save exif data) then try to delete, sometimes I get success, others it won't allow delet I have gone to the trouble of using gc.collect, do events, put the delete in a timer & wait for the delete before continuing & still get the problem
View 7 Replies
Dec 30, 2009
why i can open my .exe project and when i send to my friend when he press on the exe it shows this the application failed to initialize properly (0x0000135) you dont know why ? ...
View 2 Replies
Dec 23, 2010
I have
Dim bv As New Specialized.BitVector32(25)
Dim sb As String = "0b" 'I resisted the urge to use a stringbuilder
For i As Integer = 31 To 0 Step -1
[Code]....
I only wanted to use BitVector32 for bit flags and I wanted the output to be
0b00000000000000000000000000011001
How do I set this up properly?
View 2 Replies
Apr 8, 2010
In the project�s btnReadNumber click event handler, replace the code in the try section of the try/catch block � the two if statements and the unconditionally executed code � with one if-else statement that performs the same tasks. Use the And operator to write the if-statement�s condition.What I don't understand is how am I supposed to use the 'And' operator so that when I insert a number between 32-16384 in the text box it'll allow it to go through and at the same time not allow any numbers lower than 32(lower_bound) and higher than 16384(upper_bound) to go through.I've use the 'Or' operator and that was simple, but with 'And' I'm not understanding it.Remember it has to be with the 'AND' operator. I bold the area where my problem is at. It's obviously not the right answer, but that's where I was stumped.
Dim sum As Integer = 0
Const upper_bound As Integer = 16384
Const lower_bound As Integer = 32
[code]....
View 4 Replies
Feb 15, 2012
Value not saving properly [code]...
View 4 Replies
Mar 14, 2011
In my word processor I have an 'Open' option on a menu strip. Here is the code for it:
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
With ofdFile
.Title = "Select a file to open"[code]....
For some reason when I press the 'Open' item and open the ofdFile dialog box .txt files do not appear even when I have the 'Text Files' filter selected However, when I use the 'All Files' filter they appear. And the 'HTML Files filter is also working properly.Why are the .txt files not appearing when I use the Text Files filter?
View 4 Replies
Oct 18, 2011
I don't even know where to begin describing this. I have a project, that uses settings, for some paths, settings that I retrieve with the My.Settings. function.In my laptop, when I change the .exe.config file, the settings are updated accordingly, but when I try that on the production server, it just shows the default value used while compiling.
I tried changing the solution configurations to debug and other custom configs with no effect.Tried to use the same folder copied and pasted without version control, still the same result.Tried a co-workers laptop, by using the last svn revision, it works there too. But on neither of the servers works.
View 1 Replies
Aug 25, 2010
I have some basic code to fill items in an ArrayList as follows:
Dim intSteps As ArrayList = New ArrayList()
elect Case Session("type")
Case 1
[code]....
View 2 Replies
Mar 3, 2011
I have the following code in an Asp.Net user control:
Me.pnlAddComment.Visible = MyBase.Associate.IsAgent()
Me.lblRating.Visible = Me.pnlAddComment.Visible
Me.Rating1.Visible = Me.pnlAddComment.Visible
Now when I run this code, the value of MyBase.Associate.IsAgent() is true. Yet at no point is Me.pnlAddComment.Visible evaluating to true. When I output the results as Response.Write statements, it shows IsAgent = True, pnlAddComment.Visible = False. When I run it in debug mode, placing the line break on the second line above to allow the set to occur: I put the mouse over IsAgent and it displays "True"; I put the mouse over pnlAddComment.Visible and it displays "False".
A Co-worker suggested that it's possible that it's Panel.Visible black box code in the getter that allows the assignment to occur but returns false because some parent object is set (at that point in the code execution) to False. I've reviewed the parent objects and at no time do any of them appear to be set to not visible.
If this were a reference type I might be convinced that some other process is modifying the reference between this assignment and when it is actually used (at Render), but this is happening right at this line of code.What would cause this boolean assignment to behave this way without throwing an exception?
Solution:The answer turned out to be a parent object in the control hierarchy located outside of the user control itself. Since nothing was explicitly set to false, and I agreed with @Shadow Wizard, @Damien_The_Unbeliever and @CodeMonkey1 that it had to be some outside control influencing the panel at that point, I decided to put a recursive while loop to test the parent of each user control in the hierarchy at that point:
Dim o as Object = Me.pnlAddComment.Parent
While o IsNot Nothing
Me.lblMessage.Text &= "<br />" & o.ID & ": " & o.Visible.ToString()
o = o.Parent
End While
Then I just ran this on the server and the output came back with the full visibility of each control in the chain. What ended up occurring is that this control was contained within a view control within a MultiView. This view control is expected to be visible as it is supposed to be the ActiveView for this particular call, but at the point in the life cycle when my code is run, the view has not been identified as the active view. Since it's not officially active, the view is implicitly false, and all child controls return a value of false when Visible is queried.
The rest of the assignments behave as expected from that point. The lblRating control is set to false (permanently) because at that moment the proper visibility setting for pnlAddComment is false. The lesson I've learned here is not to make control visibilities dependent on each other in this fashion when there is an alternative (and just as simple) method.
View 3 Replies
Sep 19, 2009
I have a windows forms Application using DCOM to connect to another server in order to retrieve data from a database. The program works perfectly fine on my develeopment box both inside of and outside of the idea.However it throws an exception on my test box: System.Exception.... TYPE_E_CANTLOADLIBRARY. The error happens when accessing a property of on the the public DCOM classes. The property holds an instance of one of the private classes for the DCOM. I've compared the registries and all the relevant entries seem to be the same. When I compared the dumps I noticed that System.Config and System.XML werent loaded on the test machine, even though they are installed and appear to be in the GAC.
[Code]...
View 6 Replies
Apr 17, 2012
I cannot figure out why my calculation is not working. I am doing for 1 to 12 and it gives me 12 inputs but counts my entries as 13? What am I missing. If I change it to 0 to 11 same thing. I am not sure what the issue is, but I cannot see it, and am not sure where to look.I need to end up with 12 cycles through and intEntries to be 12.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'initialize accumulator
Dim decEntries As Decimal[code].......
View 1 Replies
Sep 15, 2010
I have a VB.Net 2008/Access 2007 app that I can�t get to display data in an organized way on a listview. The listview displays the data in the order that the data was entered in the products table. In the SQL statement that loads the listview I put ORDER BY SupplierTbl.CompanyName but it doesn't do it. The listview shows the data in the order that the records were entered in the database. So then I was going to settle for if I can get the listview sorted by clicking on the column header.If I can get that to work then that would be acceptable. So I then implemented the sort routine. The sort works and it doesn't.If you click on a column header then all the rows show the information nicely. The database has an OLE object column for storing images. Customer wants images stored in the database not file paths. When you click the listview the image displays in a picturebox.
The proper images display when the listview is clicked when I use the SQL statement below without the ORDER BY. But when I click on a column header and reorder the display it's no good. If you click on a row in the listview the wrong image is being displayed. It displays them in the order as they were in before the sort. All the other columns look good and are behaving except for the Image column. So that then makes me wonder if my original problem with the ORDER BY is directly related with the OLE object column. Is there something about this data type that I need to know to manipulate it in SQL? My reaction is that maybe since this column is resource heavy it goes by different rules. Can someone please tell me what I need to do to make the end result have some order? This is the SQL statement without the ORDER BY:
command.CommandText = "SELECT ProductTbl.ProductID, ProductTbl.PartNumber, " & _
" ProductTbl.AltPartNumber, ProductTbl.Description, ProductTbl.SupplierID, " & _
" SupplierTbl.SupplierID, SupplierTbl.CompanyName, ProductTbl.Category, " & _
[code]....
View 2 Replies
May 29, 2010
I have a timer program. Initially, the font for the time is the correct size, and when I click "start", the time is the right size too(I had set the initial size to 26 in the properties menu). When I click "break", once the time is up, it displays "Break Over!!" to fit the label(because I changed the font size). Then when I click "start" again, the font has shrunken, even though I set it back to the original size of 26. Why is the font size for the timer not back to it's original size when I click "start" after I have clicked "break"?[code]...
View 2 Replies
Dec 26, 2011
I'm joining several files and would like to encrypt them with AES. As a test I'm joining the exact same file twice, but I'm never able to properly decrypt the second file.
Steps to reproduce:
Make sure you have a file "C:Original.pdf" or change the filepath.
1) Click Button1 to encrypt the file. This will create an encrypted file named "Encrypted.bin"
2) Click Button2 to decrypt the file. This will create a decrypted file named "Decrypted.pdf"
Both "Original.pdf" and "Decrypted.pdf" are 100% the same.
3) Uncomment the code between the hash character lines.
4) Repeat the first two steps.
"Original.pdf" and "Decrypted.pdf" are now not the same.
vb.net
Private enc As New Encrypt
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Encrypt
enc.EncryptDecrypt("C:Original.pdf", "C:Encrypted.bin", True)
[Code] .....
View 1 Replies
Feb 22, 2009
I'm in need of a simple Regular Expression that will match all strings that start with the string "textures/". The problem probably is when to end the match.
Here is an example of the type of file I need to parse:
[Code]...
I have attached an example file (it's from a game, and it's a free game, so I don't think this is not allowed?). When opening that with Notepad I see loads of spaces and a few strange characters. When opening it with Wordpad, I see mostly strange characters (but the "textures/..." strings I need are still there). When reading it with VB (IO.File.ReadAllText or using a StreamReader) I cannot get it to show more than a few random characters, and the "textures/..." strings are no longer there...
View 12 Replies
May 8, 2012
After days of labouring, debugging and researching, im on the 3rd to last line and im stuck. This isnt the full code, but the relevant parts.
Dim dbProvider As String
Dim dbSource As String
Dim con As New OleDb.OleDbConnection
[Code].....
I understand this means my table doesnt have a primary key, but i have set one.
View 1 Replies
Nov 1, 2009
dim testpanel as new panel
dim test as CType(testpanel, Control))
msgbox(typename(test)) ' it gives me "panel"
'i dun get it, how can typename of test give me Panel when i explicitly call it to be converted to a Control type?
View 9 Replies
Jul 4, 2011
So I opened 2 forms, Form2.vb and Form3.vbNow I put this:
Private Sub Form1_PreviewKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles Me.PreviewKeyDown
If e.KeyCode = Keys.F8 Then
[code].....
View 8 Replies
Nov 25, 2010
i will just use Environment.Exit(code) to exit an application. (usually through a button click) , but i would like to know is it the proper way to exit , ie, releasing memory etc etc...
View 3 Replies
Oct 8, 2011
Using VB.Net[code]...
When textbox1.focus() at that time i clicked Control + Enter key, the formid=55 is showing instead of formid=54.
View 1 Replies
Mar 30, 2010
I have a windows form with listboxes, buttons and a checkbox. It works fine at home but when I take it to school it doesn't display properly. I have been given full privileges and the .NET framework V3.5 is installed. I have all my buttons/checkboxes on the right hand side but they don't display like they aren't even there (there is no extra blank form space either). The form sized wasn't locked
View 3 Replies