|
There's no property you can change to get the GroupBox lines to draw in a different color. You'll have to create your own GroupBox control, inheriting from the normal GroupBox class, and supply your own drawing code to draw the GroupBox. Considering the effort involved, is the color of that line really worth it?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I seek an internal end of module to a program which is used to block this program during a time of use. Can somebody give some to me?
Thanks
|
|
|
|
|
This doesn't make any sense what-so-ever. You're looking for code to do what?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello,
I tried to search 'the net', but all i can find is C++ code. I don't understand C++, so you know. I need to disable my Secondairy Master/Slave (which are my DVD and CD drive). Could someone give me a hint? Or perhaps a little code, my tagret is to disable and enable my Cd-rom drives with just executing my program.
Much appreciated!
Lennard Fonteijn
You mess with the best, you die like the rest!
-- modified at 10:38 Tuesday 20th June, 2006
|
|
|
|
|
What do you mean by disable them? and why?
Do You want to "Lock the tray's from opening and closing" ?
'--- form code --- form1.vb ------------
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(32, 24)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(96, 24)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Lock"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(32, 64)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(96, 24)
Me.Button2.TabIndex = 1
Me.Button2.Text = "Unlock"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 118)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "CDLock Demo"
Me.ResumeLayout(False)
End Sub
#End Region
'*********************************************************
' IO Demo Locks/Unlocks Optical Disk Drive - VB.Net
'*********************************************************
#Region " API IO Control "
Private Structure OVERLAPPED
Dim Internal As IntPtr
Dim InternalHigh As IntPtr
Dim Offset As Integer
Dim OffsetHigh As Integer
Dim EventHandle As IntPtr
End Structure
Private Structure PREVENT_MEDIA_REMOVAL
Dim PreventMediaRemoval As Boolean
End Structure
<DllImport("kernel32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function CreateFile( _
ByVal lpFileName As String, _
ByVal dwDesiredAccess As Integer, _
ByVal dwShareMode As Integer, _
ByVal lpSecurityAttributes As IntPtr, _
ByVal dwCreationDisposition As Integer, _
ByVal dwFlagsAndAttributes As Integer, _
ByVal hTemplateFile As Integer) As Integer
End Function
<DllImport("kernel32.dll", ExactSpelling:=True, SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function DeviceIoControl( _
ByVal hDevice As Integer, _
ByVal dwIoControlCode As Int32, _
ByVal lpInBuffer As IntPtr, _
ByVal nInBufferSize As Int32, _
ByVal lpOutBuffer As IntPtr, _
ByVal nOutBufferSize As Int32, _
ByRef lpBytesReturned As Int32, _
ByVal lpOverlapped As OVERLAPPED) As Boolean
End Function
Private Declare Function CloseHandle Lib "kernel32" ( _
ByVal hObject As Integer) As Integer
Private Const INVALID_HANDLE_VALUE As Integer = -1
Private Const GENERIC_READ As Integer = &H80000000
Private Const GENERIC_WRITE As Integer = &H40000000
Private Const FILE_SHARE_READ As Integer = &H1
Private Const FILE_SHARE_WRITE As Integer = &H2
Private Const OPEN_EXISTING As Integer = 3
Private Const FILE_ATTRIBUTE_NORMAL As Integer = &H80
Private Const ERROR_ACCESS_DENIED As Integer = 5
Private Const IOCTL_STORAGE_MEDIA_REMOVAL As Integer = &H2D4804
'--------------------------------------------------------------------------
'cref: uses OVERLAPPED structure as per MSDN specifications.
'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/ioctl_storage_media_removal.asp
'--------------------------------------------------------------------------
Private Sub LockOpticalDrive(ByVal sDrive As String, ByVal bLockState As Boolean)
Dim dwRetval As Integer = 0
Dim pmr As PREVENT_MEDIA_REMOVAL
Dim hDevice As Integer
Dim ol As OVERLAPPED
'Get desired lock state
pmr.PreventMediaRemoval = bLockState
'Get a handle to the drive
hDevice = CreateFile("\\.\" & sDrive & ":", GENERIC_READ, FILE_SHARE_READ Or FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, 0)
Debug.WriteLine("WIN32 CreateFile: " & "Error: " & Err.LastDllError & " Handle: " & Handle.ToInt32)
If hDevice = INVALID_HANDLE_VALUE Then
MsgBox("Unable to find optical drive")
Exit Sub
End If
' Marshal Structure
Dim inBufferSize As Integer = Marshal.SizeOf(pmr)
Debug.WriteLine("inBbufferSize: " & inBufferSize)
Dim inBuffer As IntPtr = Marshal.AllocCoTaskMem(inBufferSize)
Marshal.StructureToPtr(pmr, inBuffer, False)
'Lock the drive
If DeviceIoControl(hDevice, IOCTL_STORAGE_MEDIA_REMOVAL, inBuffer, inBufferSize, IntPtr.Zero, 0, dwRetval, ol) = False Then
Debug.WriteLine("WIN32 DeviceIoControl: " & Err.LastDllError & " dwRetval: " & dwRetval)
MsgBox("Error accessing drive")
End If
'Free the memory and close the handle.
Marshal.FreeCoTaskMem(inBuffer)
CloseHandle(hDevice)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Lock the "E" optical drive
LockOpticalDrive("E", True)
MsgBox("Drive is locked")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Unlock the "E" optical drive
LockOpticalDrive("E", False)
MsgBox("Drive is unlocked")
End Sub
End Class
'------------------------------------
progload
|
|
|
|
|
friends,
can explain the utility of e.action at afterselect and after expand?
in the code
TreeView1.SelectedImageIndex = TreeView1.SelectedNode.ImageIndex<br />
TreeView1.SelectedNode = TreeView1.GetNodeAt(e.X, e.Y)
on execution of these lines the control automatically goes to after select.It is ok after form load at left click.aT FORM LOAD THA ACTION IS UNKNOWN AND ALSO AFTER THE FORM LOAD.i AM .pLEASE HELP.
|
|
|
|
|
Sorry mate, i'd love to help, but i dont understand your point from the message. Please retype
You mess with the best, you die like the rest... well... kinda???
|
|
|
|
|
I recently bought a MSDN Visual Studio 2005 Professional Subscription and I am trying to learn VB.NET, specifically how to do use the ADO.NET stuff for database operations.
I have bought a reference book titled “Beginning VB.NET 2003” and I’m trying out this example:
'Import Data and SqlClient namespaces
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Dim objConnection As SqlConnection = New SqlConnection("server=(local);database=pubs;user id=sa;password=")
Dim objDataAdapter As New SqlDataAdapter()
Dim objDataSet As DataSet = New DataSet()
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Set the SelectCommand properties...
objDataAdapter.SelectCommand = New SqlCommand()
objDataAdapter.SelectCommand.Connection = objConnection
objDataAdapter.SelectCommand.CommandText = _
"SELECT au_lname, au_fname, title, price " & _
"FROM authors " & _
"JOIN titleauthor on authors.au_id = titleauthor.au_id " & _
"JOIN titles ON titleauthor.title_id = titles.title_id " & _
"ORDER BY au_lname, au_fname"
objDataAdapter.SelectCommand.CommandType = CommandType.Text
'Open the database connection...
objConnection.Open()
'Fill the DataSet object with data...
objDataAdapter.Fill(objDataSet, "authors")
'Close the database connection
objConnection.Close()
'Set the DataGrid properties to bind it to our data...
grdAuthorTitles.DataSource = objDataSet
grdAuthorTitles.DataMember = "authors"
'Cleanup
objDataAdapter = Nothing
objConnection = Nothing
End Sub
End Class
I’m getting an error on this line:
Dim objConnection As SqlConnection = New SqlConnection("server=(local);database=pubs;user id=sa;password=")
The SqlConnection statement after the New is giving me the error “Type ‘SqlConnection’ is not defined.”
Can anyone tell me why this is happening? The contructor for the data operations are imported at the beginning of the project. I have no idea what is wrong, or how to correct it.
Thank you,
Quecumber256
|
|
|
|
|
The namespace imported is correct so you might want to check whether the project has a reference to System.Data (System.Data.dll). If there is none, just add a reference to it by going to Project > Add Reference (if you are using Visual Studio) and choose System.Data or System.Data.SqlClient.
Or, if it still doesn't work, try typing the fullname of SqlConnection class (System.Data.SqlClient.SqlConnection) instead.
Hope that helps.
"Democracy is two wolves and a sheep voting on what to have for dinner" - Ross
Edbert
Sydney, Australia
|
|
|
|
|
Hi Edbert,
Doesn't the Imports System.Data and Imports System.Data.SqlClient take care of this for you? The code I included in the question is exactly like that in the Beginning VB.NET 2003 referance book. There where no instructions in the 'Try-it-out' to add such a referance.
Thank you,
Quecumber256
|
|
|
|
|
Did you use the VS2003 provided by the book?
It might be that the VS2003 version is an older one, therefore you might want to try System.Data.Sql instead of System.Data.SqlClient.
I'm quite sure it's a namespace problem, so check that you have added the correct references and imported the correct namespace (use the intellisense).
Otherwise, try Resharper[^]. It usually finds the correct class and namespace for you to use.
"Democracy is two wolves and a sheep voting on what to have for dinner" - Ross
Edbert
Sydney, Australia
|
|
|
|
|
Hi. I have a project at the university to do a booking systems. Booking is done by telephone (telesales) and online. Can someone please help me or give me some advice
|
|
|
|
|
|
Hi All,
I want to save multiple .bmp images one by one.
The code is in vb.net.
Now my problem is that when I save the image I get error message as
'The File is being accessed by another process'
Can u plz tell me how to set free the image from that other process (which is not known).
Thanks in advance
Born to code
|
|
|
|
|
ganesh_nagargoje wrote: I get error message as 'The File is being accessed by another process'
are you sure the message isn't this one ?
<font color=red>Please do NOT post programming questions or ads to this forum.</font>
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
ganesh_nagargoje wrote: Can u plz tell me how to set free the image from that other process (which is not known).
You'll need one of these[^].
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
If your OS is WinXP, you should wait for SP4. For the rest of windows OSes, a simple reboot should solve your problems. If you code for Vista, my advice is to wait for the release version, don't spend much time checking weird bugs which can occur in betas.
|
|
|
|
|
Look here[^]
You know you're obsessed with computer graphics when you're outside and you look up at the trees and think, "Wow! That's spectacular resolution!"
Only kings, presidents, editors, and people with tapeworms have the right to use the editorial "we."
|
|
|
|
|
|
You other guys are weak you know, a forum is a forum, if you cant help and only make stupid answer, please drop dead .
Ok, now the bmp saving, could you tell me, whats the exact point of the program, do you select some images somehwere which are copied to BMp in another place?
Be more exact please, else i can't help.
You mess with the best, you die like the rest... well... kinda???
|
|
|
|
|
THe post was moved from the Lounge to the VB.NET forum, where it belongs. Programming questions are strictly forbidden in the Lounge. Violators will be violated, by all kinds of vile Loungers.
Dave Kreskowiak
Microsoft MVP - Visual Basic
-- modified at 11:26 Tuesday 20th June, 2006
|
|
|
|
|
The "other process" is probably your own app. I'm guessing that you loaded the image into a PictureBox using a FromFile method?
When you load an image using the FromFile method, the file is locked and stays open for the life of the Image object. You can find a workaround for this little "feature" here[^] on MSDN.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I have 2 datagrids: order and orderDetail
I also have a dataset with 2 tables (order & orderDetail) and a relation between them
the order-datagrid is bind to the order-table in my dataset.
The orderDetail-datagrid is bind to the relation between the 2 tables.
So when I click on a row in the order-datagrid, the orderDetail-datagrid will automatically display the corresponding detail-records.
When I select a row in the Order-datagrid by using code:
dgOrder.select(rowNumber)
The orderDetail-datagrid does NOT display the detail of the newly selected order, he keeps displaying the detail of the previous selected order.
Does anyone know how i can achieve, that the orderDetail-datagrid is refreshed with the detail of the order that was selected by code.
Any help is much appreciated,
Thanks in advance
John
|
|
|
|
|
Solved:
setting the 'CurrentrowIndex' does the job
|
|
|
|
|
HI to everyone....
I try to make an application, taking some mdb files from a directory and connect them with my rpt files.
I made that and everything is ok till the time that it try to logo into the 65th mdb..........
It shows me an exception "Logon failed" !!!!!!!!!!
I try everything and i think the problem is in the tbl.ApplyLogOnInfo, i think runs only for 64 times...
Does anyone knows something about that and help me?????
Is there anyway to reset it????
giotis
|
|
|
|
|