|
Do one thing. make registration form as first load form of the project. When you will come second time. on the load of Registration you will have the code that if it is already a registered version then
also define one object in global say
dim frmReg as object
me.hide
frmreg=me
dim frm as new frmLogon
frm.show()
on closing the main application ... you need to close
frmreg.dispose()
and your problem is solved.
Rizwan Bashir
|
|
|
|
|
Why not start your app with a Main sub instead of a form, where you could see how many logon accounts are created in your database. If the count equals zero the show the registration form. This would also mean if someone deleted all the logon accounts, the registration form would show again allowing a new admin account to be setup etc.
Steve Jowett
|
|
|
|
|
What you said i understood, what i dont know it's the code...could you give me an example?
|
|
|
|
|
What are you using to store your user information? e.g. Text File, Registry, Access Database etc.
Steve Jowett
|
|
|
|
|
I'm saving the information of the registration form in a database.
|
|
|
|
|
When mouse over the datagridview , I could get the X,Y value .
How to get the row index ?
Thanks a lot.
|
|
|
|
|
Change the HoverEvent property of the grid to true and get the item index
that will be row index for grid
Private Sub NhsListViewGrid1_HoverEvent(ByVal source As Object, ByVal e As GlacialComponents.Controls.HoverEventArgs) Handles NhsListViewGrid1.HoverEvent
MsgBox(e.ItemIndex())
End Sub
milan
|
|
|
|
|
Someone can help me with the code to drag a label on a form. I need it to the user change the label position in the form.
Thanks...
nmpsantos
|
|
|
|
|
|
Are you looking for a label control that is movable on the form, by the user, at runtime??
I'm in the middle of writing an article on that now... Can you wait about a day?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I posted this[^] article last night. See if it describes what you're looking for.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
what r the accounts dealing in hotel management
|
|
|
|
|
Ask your team's Certified Public Accountant.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
i am facing problem with date format,i have sql server database table in that, one column is date.the that date format is mm/dd/yy.so when i write the xml using vb.net Tool that time it displayed as date yy/mm/dd.but i want mm/dd/yy format could u plz any one help me on this topic.
Charan04
-- modified at 5:40 Monday 10th July, 2006
|
|
|
|
|
datetime.now.tostring("MM/dd/yyyy")
|
|
|
|
|
Thanks for that one ,But i want mm/dd/yyy this format when write xml that time they will print like yy/dd/mm.in my datebase format is(table)mm/dd/yy.plz give answer.
charan04
|
|
|
|
|
I'm attempting to export emails the user has selected in outlook. I wrote this as a vb macro inside of Outlook, but get a message stating do you want to allow the process and then there is a drop down for 1 or 10 minutes to allow. Does anyone know how I can get around this and always allow.
|
|
|
|
|
I have been searching alot and still having lots of error to write coding for DataGrid_DragDrop. I need help urgently
Public Sub TreeView_ItemDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Handles TreeView.ItemDrag<br />
m_tnSource = CType(e.Item, TreeNode)<br />
DoDragDrop(e.Item, DragDropEffects.Move)<br />
End Sub<br />
<br />
Private Sub DataGrid_DragEnter(ByVal Sender As Object, ByVal e As DragEventArgs) Handles DataGrid.DragEnter<br />
If e.Data.GetDataPresent(DataFormats.Text) Then<br />
e.Effect = DragDropEffects.Copy<br />
Else<br />
e.Effect = DragDropEffects.None<br />
End If<br />
End Sub
-- modified at 4:02 Monday 10th July, 2006
|
|
|
|
|
Hi,
I've got some code thats unamanged/managed and have some callback handlers in it, linking some old .dll stuff.
I've searched for a while and I've read a bit on garbage collection and delegates and I've tried my best to apply the examples to my code, but to no avail. I still get either the following error message
"A callback was made on a garbage collected delegate of type 'WindowsApplication1!WindowsApplication1.MyConnectHandler::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called."
or, no error message (and the call back excutes successfully) but it then trashes the other bits of code from working properly that are run from the same .dll
This is the code, I've cut out the surplus bits, it has no errors or warnings...... just doesn't work
In this sample basically the user would select a comport from a drop down box and click connect. I know it actually connects as I can see status from the device its connecting to. However when the device tries to send the message back, it does one of the above errors.
Would greatly appreciate any help as I'm trying to implement this .dll to move away from an unstable module we are being forced to use at the moment.
Michael
imports System.Text
Public Delegate Sub MyConnectHandler(ByVal result As Integer)
Public Class Form1
Inherits System.Windows.Forms.Form
' Declare some variables
Public Declare Auto Sub register_connect_handler Lib "CBM.DLL" Alias "_register_connect_handler" (ByVal FPtr As MyConnectHandler)
Dim MyConnectPtr As MyConnectHandler = AddressOf Connect_Handler
Public Sub Connect_Handler(ByVal result As Integer)
If result = 0 Then
Me.StatusBar1.Text = "Fail"
Call close_com_port()
ElseIf result = 1 Then
Me.StatusBar1.Text = "Fail type 2"
Call close_com_port()
ElseIf result = 2 Then
' success so enable trackbar and inform user
connected = 1
Me.TrackBar1.Enabled = True
Me.StatusBar1.Text = "Connected"
End If
End Sub
' Initialise fields and vars
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i, j As Int16
' Launch the connect handler
register_connect_handler(MyConnectPtr)
' Stop it from dying
GC.KeepAlive(MyConnectPtr)
End Sub
' Connect/disconnect as required
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Dim [ascii] As Encoding = Encoding.ASCII
Dim Port As Byte() = [ascii].GetBytes(Me.ComboBox1.Text)
Dim x As Integer
If connected = 0 Then
' connecting, inform user
Me.StatusBar1.Text = "Connecting ..."
' Open the selected comport (DLL call)
x = open_com_port(Port)
' check result of call for success
If x = 0 Then
' failure, inform user
Me.StatusBar1.Text = "Connect failed"
End If
Else
' disconnecting
connected = 0
' close the com port (DLL call)
Call close_com_port()
' inform the user
Me.StatusBar1.Text = "Disconnected"
Me.TrackBar1.Enabled = False
End If
End Sub
End Class
|
|
|
|
|
hi to all and best of luck. )I'm stuck-up here with the problem .. I could manage to pass string to another process/application using WM_COPYDATA but it takes v. long to pass a structure.
i wish if you can give me any code that allows passing "structure" between 2 applications
------------this is class one - sending message
Imports System.Runtime.InteropServices
Public Class clsIPC
Inherits System.Windows.Forms.NativeWindow Implements IDisposable
Private Const GLOBAL_IDENTITY_ONE = "GLOBAL_IDENTITY_ONE"
Private Const GLOBAL_IDENTITY_TWO = "GLOBAL_IDENTITY_TWO"
Private Const MESSAGE_FOR_ONE = "MESSAGE_ONE"
Private Const MESSAGE_FOR_TWO = "MESSAGE_TWO"
Private Const WM_COPYDATA As Integer = &H4A
#Region "API Declaration"
<structlayout(layoutkind.sequential)> _
Private Structure CopyData
Public dwData As IntPtr
Public cbData As Integer
Public lpData As IntPtr
End Structure
Private Declare Auto Function SendMessage Lib "user32" _
(ByVal hWnd As IntPtr, _
ByVal Msg As Integer, _
ByVal wParam As IntPtr, _
ByRef lParam As CopyData) As Boolean
Private Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" _
(ByVal lpString As String) As IntPtr
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As IntPtr, ByVal wMsg As IntPtr, ByVal wParam As Integer, _
ByVal lParam As Integer) As IntPtr
#End Region
#Region "process for messanging to application GLOBAL_IDENTITY_TWO"
'get handle of globlal application named GLOBAL_IDENTITY_TWO
Public ReadOnly Property GET_HANDLE_TWO() As IntPtr
Get
Return FindWindow(vbNullString, GLOBAL_IDENTITY_TWO)
End Get
End Property
Structure PT
Dim x As Object
Dim y As Char
Dim xy As String
End Structure
Dim MyVariable As New PT
Public Function sendMessageToTwo()
Dim data As CopyData
Dim message As String = "this is to be sent"
Dim hwndTarget As IntPtr
Dim MessageId As IntPtr
hwndTarget = Me.GET_HANDLE_TWO
MessageId = ONE_TO_TWO_MESSAGEID()
MyVariable.x = message
MyVariable.y = "c"
MyVariable.xy = "String is here"
System.GC.KeepAlive(MyVariable)
data.lpData = Marshal.AllocHGlobal(Marshal.SizeOf(MyVariable))
data.cbData = Marshal.SizeOf(MyVariable)
Dim MyPointer As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(MyVariable))
Marshal.StructureToPtr(MyVariable, data.lpData, True)
SendMessage(hwndTarget, WM_COPYDATA, Me.Handle, data)
MsgBox("WM_COPYDATA")
Exit Function
If Not System.IntPtr.Zero.Equals(hwndTarget) Then
Call PostMessage(hwndTarget, MessageId, 0, 0)
MsgBox("Message sent")
Else
MsgBox("Unable to send Message ! probably GLOBAL_IDENTITY_TWO Not found")
End If
End Function
Public ReadOnly Property ONE_TO_TWO_MESSAGEID() As IntPtr
Get
Static objONE_TO_TWO_MESSAGEID As IntPtr
If IntPtr.Zero.Equals(ONE_TO_TWO_MESSAGEID) Then
objONE_TO_TWO_MESSAGEID = RegisterWindowMessage(MESSAGE_FOR_TWO)
End If
Return objONE_TO_TWO_MESSAGEID
End Get
End Property
#End Region
Region "dispose method and new()/constructor"
Public Sub Dispose() Implements IDisposable.Dispose
If Not Me.Handle.Equals(IntPtr.Zero) Then
Me.ReleaseHandle()
End If
End Sub
Public Sub New()
Dim Params As CreateParams = New CreateParams
Params.Caption = GLOBAL_IDENTITY_ONE
Me.CreateHandle(Params)
End Sub
#End Region
End Class
--------------------------------------xxxxxxxxxxxxxxxxxxxxxxxxxx----------------------------------
----this is class two-listening to message-----------
Imports System.Runtime.InteropServices
Public Class clsIPC
Inherits System.Windows.Forms.NativeWindow Implements IDisposable
Private Const GLOBAL_IDENTITY_ONE = "GLOBAL_IDENTITY_ONE"
Private Const GLOBAL_IDENTITY_TWO = "GLOBAL_IDENTITY_TWO"
Private Const MESSAGE_FOR_ONE = "MESSAGE_ONE"
Private Const MESSAGE_FOR_TWO = "MESSAGE_TWO"
Private Const WM_COPYDATA As Integer = &H4A
Private Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" _
(ByVal lpString As String) As IntPtr
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As IntPtr, ByVal wParam As Integer,ByVal lParam As Integer) As IntPtr
<structlayout(layoutkind.sequential)> _
Private Structure CopyData
Public dwData As IntPtr
Public cbData As Integer
Public lpData As IntPtr
End Structure
Structure PT
Dim x As Object '<<<----- whenever i use object as member of a structure i get an exception An unhandled exception
'of type 'System.ExecutionEngineException' occurred in mscorlib.dll if i use string as a
'member there is no error
Dim y As Integer
Dim xy As Integer
End Structure
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case WM_COPYDATA
Dim data As CopyData
Dim message As String
Dim MyPoint As New PT
data = CType(m.GetLParam(GetType(CopyData)), CopyData)
MyPoint = Marshal.PtrToStructure(data.lpData, GetType(PT)) <<<---- @ this point i'm getting the error [debug]
'MyPoint = Marshal.PtrToStructure(CType(m.GetLParam(GetType(CopyData)), CopyData).lpData, GetType(PT))
MsgBox(CType(MyPoint.x, String))
Case TWO_TO_ONE_MESSAGEID().ToInt32
MessageBox.Show("GOT A MESSAGE FROM ONE--- CALLING METHOD A", "VBNETMessaging")
Call A()
End Select
MyBase.WndProc(m)
End Sub
Private Sub A()
MsgBox("Message from Method A")
End Sub
Public ReadOnly Property TWO_TO_ONE_MESSAGEID() As IntPtr
Get
Static objTWO_TO_ONE_MESSAGEID As IntPtr
If IntPtr.Zero.Equals(objTWO_TO_ONE_MESSAGEID) Then
objTWO_TO_ONE_MESSAGEID = RegisterWindowMessage(MESSAGE_FOR_TWO)
End If
Return objTWO_TO_ONE_MESSAGEID
End Get
End Property
#Region "dispose method and new()/constructor"
Public Sub Dispose() Implements IDisposable.Dispose
If Not Me.Handle.Equals(IntPtr.Zero) Then
Me.ReleaseHandle()
End If
End Sub
Public Sub New()
Dim Params As CreateParams = New CreateParams
Params.Caption = GLOBAL_IDENTITY_TWO
Me.CreateHandle(Params)
End Sub
#End Region
End Class
--------------------------------------xxxxxxxxxxxxxxxxxxxxxxxxxx----------------------------------
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|
|
Can I ask why you're try to pass data the hard way, instead of using .NET Remoting?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
actually the request is sent by an AddIN to the application-software.
what i have to do is to pass an object from addins to software-app.
If you can solve this then good even if you can solve in remoting well i've got no probs.
-thanks
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|
|
If you're writing both the software and the add-in's, Remoting is the best way to go!
If I'm sounding like I'm guessing what your trying to do, it's because I am. You haven't povided any detail about what your ultimate goal with this code is, besides transferring a pointer through a Window message. Why are you doing this? How does this little piece fit into the "grand scheme" of things?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
i'm not using remoting coz i've a little time to accomplish this task. well, actully i dont know remoting.
Now about my "Grand Scheme", using this if any-how i can pass the object of the office-application to another application-sw, the work is done. One more thing, I have succesfully sent the structure to the "other end", but whenever Object comes in the picture an error occurs:-
An unhandled exception of type 'System.ExecutionEngineException' occurred in
mscorlib.dll
Now thats the problem. Well I'll do try with remoting but it'll take some time, which i dont have now.
-thanks buddy
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|
|
I don't have a lot of time right now, so I can't put a project together to test what your doing. All I can suggest at this time is you might want to take a look at this: The Quick and Dirty Guide to .NET Remoting[^]
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|