|
I think you don't undetstand what i meant. Consider following code.
1 Dim img As New Bitmap(PictureBox1.Image)
2 Dim col As Integer = d.GetPixel(x, y).ToArgb
Variable col will hold some value that return from GetPixel function. Now I want to extract R value, G value and B value separately from variable col. That's what i want.
|
|
|
|
|
See the Color[^] methods for extraction of individual parts.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
At the risk of repeating myself: Dim Red As Integer = Color.FromArgb(col).R
|
|
|
|
|
Just kidding.
|
|
|
|
|
To be absolutely sure, I also gave an alternative that does not rely on the features of the Color type. See below message.
|
|
|
|
|
Thank you so much. Now i can understand it
|
|
|
|
|
The mathematical alternative is:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
showColorComponents(Color.LightYellow)
showColorComponents(Color.FromArgb(11, 22, 33, 44))
End Sub
Private Sub showColorComponents(ByVal col As Color)
log("col=" & col.ToString & " = " & col.A & "," & col.R & "," & col.G & "," & col.B)
Dim I As Int32 = col.ToArgb()
log("I=0x" & I.ToString("X8"))
Dim B As Int32 = I And 255
Dim G As Int32 = (I >> 8) And 255
Dim R As Int32 = (I >> 16) And 255
Dim A As Int32 = (I >> 24) And 255
log("ARGB=" & A & "," & R & "," & G & "," & B)
End Sub
|
|
|
|
|
I'm kinda stumped on this one. I've been reading for a few hours now and still can't seem to figure out what the problem is. I'm working on a remote desktop tool that consists of a parent mdi form and child forms that contain an AxMSTSCLib control. Everything works great on my machine (Win 7), but when I attempt to run this on a Windows 2003 or XP box, the app crashes when it tries to close the form. At first I thought it was due to me trying to dispose the control, but even removing the dispose step makes no difference. I've included the error message along with some info from the immediate window and a dump analysisy showing the function call causing the access violation. I'm not sure what I have to do to keep this from throwing the error and crashing the app.
An unhandled exception of type 'System.AccessViolationException' occurred in System.Windows.Forms.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Step into: Stepping over non-user code 'System.Windows.Forms.Form.Close'
First-chance exception at 0x59366b49 in RDPConnectionManager.exe: 0xC0000005: Access violation reading location 0x00000000.
mstscax!CMsTscAx::OnCoreApiDisconnected+87
mstscax!CTSWin32CoreApiNotifySink::OnCoreApiDisconnectedUiThreadWorker+19
mstscax!CTSWin32CoreApiNotifySink::OnCoreApiDisconnectedUiThreadWorkerAsyncCallback::Invoke+16
mstscax!CTSMsg::Invoke+44
mstscax!CTSThread::RunQueueEvent+73
mstscax!CTSThread::RunAllQueueEvents+57
mstscax!CTSThread::OnNotifyThreadEventQueue+7
mstscax!CTSThread::OnNotifyThreadMessage+24
mstscax!PAL_System_Win32_ThreadWndProc+1b
user32!InternalCallWinProc+28
user32!UserCallWinProcCheckWow+150
user32!DispatchMessageWorker+306
user32!DispatchMessageW+f
Let me know if you need any additional information on this problem and I appreciate any input on this.
|
|
|
|
|
OK, I figured out the reason for the exception. I was closing/disposing of the form within an eventhandler for a control on that form. So basically, I killed the form and then the event tried to finish running and threw the exception.
This leads me to another question though. How do I close this form outside of this event? The event in question is OnDisconnected event of the AxMsRdpClient4 class. I want to close the form after disconnecting, but it seems like any attempt I make to close the form within that event will result in the exception.
|
|
|
|
|
|
Hi,
I have a DataGridView on form, I set MultiSelect = false.
By default, the DataGridView always has top left cell selected, is it possible that the DataGridView has nothing be selected by default?
Thanks!
|
|
|
|
|
you can undo any selection by calling ClearSelection().
What I do for DGV-based viewers that never want anything selected is add a handler (C# code alert):
private void dgv_SelectionChanged(object sender, EventArgs e) {
dgv.ClearSelection();
}
|
|
|
|
|
Luc,
Working great, Thank you very much.
|
|
|
|
|
How to bound this grid using ADODC Control? As well the help file is given with the mdb file examples. By which I came to know that this supports only MS Access file. But I've Database in Ms Sqlserver 2000. Can Any one help me in this regard. So far I found the grids but in which I can't add combo box except MKGrid.
Reply please
Yaseen
M. YASEEN
Software Engineer
MN Textiles
Karachi
|
|
|
|
|
How about asking the people who made MKGrid.
It's very unlikely anyone who still uses VB6 is ever going to see your question, let alone have any experience with that control.
|
|
|
|
|
<TestCase>
<Sequences>
<Sequence>
<Request>CMD_Connect</Request>
<Responce>POSITIVE</Responce>
</Sequence>
<Sequence>
<Address>400026F8</Address>
<Request>CMD_SHORT_UPLOAD</Request>
<Responce>POSITIVE</Responce>
</Sequence>
<Sequence>
<Address>400026F8</Address>
<Request>CMD_SHORT_UPLOAD</Request>
<Responce>POSITIVE</Responce>
</Sequence>
</Sequences>
<Recursions>
<Recursion>
<Address>400026F8</Address>
<Request>CMD_SHORT_UPLOAD</Request>
<Responce>POSITIVE</Responce>
</Recursion>
<Recursion>
<Address>400026F8</Address>
<Request>CMD_SHORT_UPLOAD</Request>
<Responce>POSITIVE</Responce>
</Recursion>
<Recursion>
<Address>400026F8</Address>
<Request>CMD_SHORT_UPLOAD</Request>
<Responce>POSITIVE</Responce>
</Recursion>
</Recursions>
<Sequences>
<Sequence>
<Request>DAQ_START_STOP_DAQ_LIST</Request>
<Responce>POSITIVE</Responce>
</Sequence>
<Sequence>
<Request>CMD_Disconnect</Request>
<Responce>POSITIVE</Responce>
</Sequence>
<Sequences>
</TestCase>
I have this type of xml. "Sequences" and "Recursions" are the elements occuring multiple times under "Test Case" node.Now I have to read this xml such that I have the knowledge of "Sequences" and "Recursions" nodes that how many "Sequence" nodes and "Recursions" nodes are there and I have to visit these nodes also.
I used the
Dim objXMLDOM As New MSXML2.DOMDocument26
Dim objxmlNode As IXMLDOMNode
Dim objNodes As IXMLDOMNodeList
But it is not clear which method I have to use to achieve the goal.
Please guide me to read the xml.
Thanks in adv..
|
|
|
|
|
When adding new references in visual studio, the 'Specific Version' property defaults to True. Makes sense when you want to compile against specific versions for side by side deployments.
We have several projects that reference assembly .dlls that are just dumped into a common folder. So the latest .dll overrides the previous version. Next time developer goes to compile, the build fails because VS is looking for a specific version of the .dll.
Is there a way to override this default value to false when adding new references? So when adding a new reference by using the Add Reference popup, the default value to Specific Value defaults to false instead of true.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Jon_Boy wrote: Is there a way to override this default value to false when adding new references?
I don't know, but I'd like to suggest using the project-templates. Create a new application, add all the desired references, and export it as a new template. Also helps in getting a decent default for the Assembly.cs file
I are Troll
|
|
|
|
|
Roger that Eddy. Thanks for the suggestion.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Hi all, I have a vb.net application that has a odbc.odbcconnection to a (Solid) database. Within the app, the connection can switch between different databases depending on which they are logged into at a particular time.
Throughout the app the database is queried and written to on a regular basis in lots of different places and so rather than putting try/catch blocks around all of the operations on the database, is there a way of globally detecting a disconnection (due to network failure etc) so I can then tell the user they can't work on the app any more and it needs to close? I thought of possibly having a background thread which constantly checks the connection but I was wondering if there was an easier more straightforward method?
I've got a handler for any unhandled exceptions that occur in the app which writes the error to a text file, but it's a bit late for a disconnection.
any help appreciated,
Chris
|
|
|
|
|
have a look at the state methods in the odbc connection object
if conn.State = System.Data.ConnectionState.Open then
conn.Close()
end if
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
I've seen the state methods and tried this in the applicaions unhandled exception handler event:
If solid.State = ConnectionState.Broken Or solid.State = ConnectionState.Closed Then
Dim tryconnect As Boolean = True
While tryconnect = True And (solid.State = ConnectionState.Broken Or solid.State = ConnectionState.Closed)
If MsgBox("Connection to the database has closed unexpectedly. Retry to connect?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Try
solid.Open()
Catch ex As Exception
End Try
Else
tryconnect = False
Application.Exit()
End If
End While
End If>
However it's too late and the app has exceptioned giving the user the windows error box. any way to disable this?
|
|
|
|
|
You would normally just have one method that returns a Connection object in your data layer. That connection object would check the state of the connection before it queries and the try/catch block around it would also grab exceptions just like you have here. Also, it's not a good idea to leave the Catch block blank. It really should log failure information somewhere or at least show a dialog that the exception happened.
|
|
|
|
|
How about implementing a timer control on the main form which checks the connection to the database periodically ? You could even implement a stoplight (red / green) and design limited functionality into your application where some transactions could be stored locally (xml ?) until the database connection has been resumed.
In an ideal world, you would have built a data access layer where you can centralize your access to the database, implement try-catch blocks, logging, administrative notifications, etc.
Good luck and tell us which way you decided to go.
|
|
|
|
|
Thanks to all....
I've got a timer which runs every second to update a clock so I could put it there, or I could put try/catch around all the datareaders as it's not a huge app.
However, I'm going to have a look into building a data access layer into the application. I'm still fairly new to programming and it's something I'll have to teach myself eventually anyway so I might as well start now whilst the data access in this app is fairly limited!
Thanks again,
Chris
|
|
|
|