|
I think you want to print multiple ids with employee image. So You sould get the paths of Image and id's in array.
and at the time of printing get the picture by using path and print it.
If you can think then I Can.
|
|
|
|
|
I can retrieve the picture in a picture control on a form. How do I get this image on a piece of paper? I can get the other information I need to print on the paper. I would like to print the ID card with picture using crystal reports, but I you know how to control the employee picture to a piece of paper using vb6.0, vb.net 2008, or Crystal Reports 8.5 developer I would really like to see the code.
Thanks
|
|
|
|
|
Hi, dear all,
I have a simple project that I want to create a setup file for it.
I followed the instruction as the following link:
Visual Studio Windows Application Setup Project[^]
But it is very strange that after I add a exe file and uninstall.dat files to Application Folder, then
when I create shortcut in User's Program Menu, set the WorkingFolder property to Application Folder, when I click Target property and try to browse the exe file in Application Folder, it only allow me to select folder instead of the exe file.
What's wrong?
Thanks!
|
|
|
|
|
Its Like That
SOFTDEV
Luck in life always exists in the form of an abstract class that cannot be instantiated directly and needs to be inherited by hard work and dedication.
|
|
|
|
|
Hi
Can any one explain to me please how to create a setup which installs the application and the required files like .net support and sql .ldf and mdf files on the specified locations.
If the operating system is XP Professional or any earlier version that supports sql 2000/05.
Regards
modified on Friday, July 2, 2010 3:26 AM
|
|
|
|
|
In a 20 step nutshell :
1) Click 'File' -> 'Add' -> 'New Project'.
2) Goto 'Other Project Types' and 'Setup and Development'.
3) Choose 'Setup Project'.
4) In the 'Solution Explorer' rightclick on your setup project.
5) Choose 'Properties'.
6) Click 'Prerequisites...' button.
7) Choose your prerequisites (e.g. .NET Framework, Windows Installer).
8) Press 'OK', press 'Apply'.
9) Rightclick on 'Application Folder' in the left File System window.
10) Choose 'Add' -> 'Project Output'
11) When done, rightclick in the Right File System window.
12) Choose 'Add' and whatever you want to add to the application directory
during installation.
13) Rightclick on 'Project output from ....'
14) Select 'Create shorcut to Primary output from ...'
15) Rightclick on 'Shorcut to Primary output from...'
16) Choose 'Rename'
17) Name it after your application.
18) Select it and drag it to the left to 'User's Program Menu'.
19) (Build solution) Build your setup project.
20) In the setup project directory you'll find the .exe and .msi file to
install your application.
|
|
|
|
|
Hi
Please can you explain how can i set timer control on a splash screen i set its property enabled = true and interval = 5000 but still its not working what shall i do here
Can any one help?
|
|
|
|
|
Hi
Please can you explain how can i set timer control on a splash screen i set its property enabled = true and interval = 5000 but still its not working what shall i do here
Can any one help?
|
|
|
|
|
- i am using sockets ...
- whenever i try to send text i get the following error...
System.InvalidOperationException: The operation is not allowed on non-connected sockets.
at InTheHand.Net.Sockets.BluetoothClient.GetStream()
- the code is the following...
Dim stream As System.IO.Stream = Nothing
Try
stream = client.GetStream()
stream.Write(Buffer, 0, BufferLen)
Catch e As Exception
MsgBox("Error sending" & e.ToString)
Finally
If (Not stream Is Nothing) Then
stream.Close()
End If
End Try
- please help me out here... thanks...
J A Nasir K
|
|
|
|
|
Because you don't have a connection opened yet?? Since you haven't provided any of the connection code, it's impossible to say what the problem is.
|
|
|
|
|
Hi,
I create a DataGridView control and add three column to it at runtime, I try different ways but the button text is always empty, did I miss something or did something wrong? The codes as following:
Dim ColumnBrowse As New DataGridViewButtonColumn()
ColumnBrowse.HeaderText = "Browse File"
ColumnBrowse.Name = "btnBrowse"
ColumnBrowse.Text = "Browse"
ColumnBrowse.UseColumnTextForButtonValue = True
ColumnBrowse.FlatStyle = FlatStyle.Standard
ColumnBrowse.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
DataGridView1.Columns.Add(ColumnBrowse)
Thanks
|
|
|
|
|
Hi,
Ok now the button text is shown now, but very strange, the last button cell always has no text displayed, why?
|
|
|
|
|
You'll have to add (bind) some data to the DataGridView for the buttontext to show. The buttontext in the last row is not shown, because this row has no data in it.
|
|
|
|
|
|
Multi threading and garbage collected problem using RegisterShellHook and SetWindowLong API.
The purpose of this to notify when a Removable Drive is Inserted AND Removed.
Most of the time it works properly but when I shake the form it causes an error.
This is the code of my class:
Public Class Shell_Hook_Pointer
Public Shadows Delegate Function WndProc(ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Declare Function RegisterShellHook Lib "Shell32" Alias "#181" (ByVal hwnd As Integer, ByVal nAction As Integer) As Integer
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Integer, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Integer, ByVal nIndex As Integer, ByVal dwNewLong As WndProc) As Integer
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Integer, ByVal nIndex As Integer) As Integer
Private Const GWL_WNDPROC As Short = (-4)
Private Const RSH_DEREGISTER As Short = 0
Public Enum SheelHookTypes
RSH_REGISTER = 1
RSH_REGISTER_PROGMAN = 2
RSH_REGISTER_TASKMAN = 3
End Enum
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Integer, ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private OldProc As Integer
Private uRegMsg As Integer
Private hWnd As Integer, ParentWindowHadler As Form
Public Const wMsg_REMOVABLE_DEVICE = 537
Public Const wParam_REMOVABLE_DEVICE_INSERTED = 32768
Public Const wParam_REMOVABLE_DEVICE_REMOVED = 32772
''' <summary>
''' Envent argumetns
''' </summary>
''' <remarks></remarks>
Class ShellHookEventArgs
Inherits System.EventArgs
Public Enum REMOVABLE_DEVICE
NONE = 0
INSERTED = 1
REMOVED = 2
End Enum
Public hWnd, wMsg, wParam, lParam As Integer
Public REMOVABLE_DEVICE_INFO As REMOVABLE_DEVICE
Public TempMsg As String
Public SheelHookTypes = SheelHookTypes
End Class
Public Function WndProcedure(ByVal hWnd As Integer, ByVal wMsg As Integer, _
ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Dim e As New ShellHookEventArgs
e.hWnd = hWnd
e.wMsg = wMsg
e.wParam = wParam
e.lParam = lParam
e.REMOVABLE_DEVICE_INFO = ShellHookEventArgs.REMOVABLE_DEVICE.NONE
Dim BWorker As System.ComponentModel.BackgroundWorker
If wMsg = wMsg_REMOVABLE_DEVICE Then
If wParam = 32768 Then
e.REMOVABLE_DEVICE_INFO = ShellHookEventArgs.REMOVABLE_DEVICE.INSERTED
ElseIf wParam = 32772 Then
e.REMOVABLE_DEVICE_INFO = ShellHookEventArgs.REMOVABLE_DEVICE.REMOVED 'Debug.Print("Device REMOVED")
End If
'e.TempMsg = "Inside RMD"
If e.REMOVABLE_DEVICE_INFO <> ShellHookEventArgs.REMOVABLE_DEVICE.NONE Then
BWorker = New System.ComponentModel.BackgroundWorker
AddHandler BWorker.DoWork, AddressOf Removable_Device_Trigger
BWorker.RunWorkerAsync(e)
End If
'RaiseEvent Removable_Device(Me, e)
Else 'e.TempMsg = "Out of RMD"
Return CallWindowProc(OldProc, hWnd, wMsg, wParam, lParam)
End If
End Function
'Passing to Parent object Start---------------------------------------------------
Public Event Removable_Device(ByVal sender As Object, ByVal e As ShellHookEventArgs)
Delegate Sub Removable_Device_DLG(ByVal sender As Object, ByVal e As ShellHookEventArgs)
Sub Removable_Device_SUB(ByVal sender As Object, ByVal e As ShellHookEventArgs)
Try
RaiseEvent Removable_Device(sender, e)
Catch ex As Exception
Stop
End Try
End Sub
Private Sub Removable_Device_Trigger(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
Dim re As New ShellHookEventArgs
re = CType(e.Argument, ShellHookEventArgs)
Dim safedelegate As New Removable_Device_DLG(AddressOf Removable_Device_SUB)
ParentWindowHadler.Invoke(safedelegate, Me, re)
End Sub
'Passing to Parent object End
'-------------------------------------------------------------------------
Function SetShell_Hook(Optional ByVal HookType As SheelHookTypes = SheelHookTypes.RSH_REGISTER_PROGMAN) As Boolean
If OldProc <> 0 Then Return False
Dim Temp As New System.Windows.Forms.Form
Temp.Visible = False
hWnd = Temp.Handle
Call RegisterShellHook(hWnd, HookType)
OldProc = GetWindowLong(hWnd, GWL_WNDPROC)
SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WndProcedure)
Return True
End Function
Public Sub RemoveShell_Hook()
If OldProc = 0 Then Exit Sub
Call RegisterShellHook(hWnd, RSH_DEREGISTER)
OldProc = SetWindowLong(hWnd, GWL_WNDPROC, OldProc)
OldProc = 0
End Sub
Protected Overrides Sub Finalize()
RemoveShell_Hook()
MyBase.Finalize()
End Sub
Public Sub New(ByVal ParentForm As Form)
ParentWindowHadler = ParentForm
End Sub
End Class I call this from my form:
Dim WithEvents SHP As Shell_Hook_Pointer
Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click
SHP = New Shell_Hook_Pointer(Me)
Button1.Enabled = Not SHP.SetShell_Hook()
End Sub
Receive event here:
Private Sub SHP_Removable_Device(ByVal sender As Object, ByVal e As Shell_Hook_Pointer.ShellHookEventArgs) Handles SHP.Removable_Device
TextBox1.AppendText("hwnd=" & e.hWnd & " wmsg=" & e.wMsg & " wparam=" & e.wParam & " lparam=" & e.lParam & " REMOVABLE_DEVICE_INFO=" & e.REMOVABLE_DEVICE_INFO & vbNewLine)
Me.Text = e.TempMsg & " " & e.REMOVABLE_DEVICE_INFO
End Sub --------------------------------------------------------------------------------------
Following errors occurred while I move (shake) the form:
Debugging Mode Error:
A callback was made on a garbage collected delegate of type 'Shell_Hook!Shell_Hook.Shell_Hook_Pointer+WndProc::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.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Runtime errors (Run the .exe file):
See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Form.DefWndProc(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmNcButtonDown(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Shell_Hook
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///H:/Desktop/Shell_Hook/Shell_Hook/bin/Release/Shell_Hook.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.1433 (REDBITS.050727-1400)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
Is there any solution of this problem?
|
|
|
|
|
Hi,
I don't think multi-threading is involved; however shaking your Form will create new objects, possibly causing the GC to run and remove a delegate that is still in use as you have stored it in unmanaged memory (SetWindowLong) so the CG cannot work out it is still in use. This is not the right way to handle this.
I do have similar functionality implemented in C#, without using any shell hooks: Windows will always broadcast Windows messages whenever a device gets added or removed, there is no need to subscribe to anything; all it takes is overriding WndProc and checking for such messages.
This is the heart of the matter (the constant values are 0x0219, 0x8000, 0x8004):
protected override void WndProc(ref Message m) {
if (m.Msg==LPWIN_Constants.WM_DEVICECHANGE) {
int wParam=(int)m.WParam;
int lParam=(int)m.LParam;
if (xpanel!=null) {
if (wParam==LPWIN_Constants.DBT_DEVICEARRIVAL) xpanel.DeviceAdded();
else if (wParam==LPWIN_Constants.DBT_DEVICEREMOVECOMPLETE) xpanel.DeviceRemoved();
}
}
}
|
|
|
|
|
"I do have similar functionality implemented in C#, without using any shell hooks" Yeah you are right. I used shell hooks to monitor processes or forms. Here is my simplyfied code:
Public Class HOOK_RMV_DEVICE
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Integer, _
ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Integer, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Integer, ByVal nIndex As Integer, ByVal dwNewLong As WndProc) As Integer
Private Shadows Delegate Function WndProc(ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Const GWL_WNDPROC = -4
Private IsHooked As Boolean, lpPrevWndProc As Integer, WindowHandler As Integer
'
Private Const wMsg_REMOVABLE_DEVICE = 537
Private Const wParam_REMOVABLE_DEVICE_INSERTED = 32768
Private Const wParam_REMOVABLE_DEVICE_REMOVED = 32772
Public Function Hook() As Boolean
If IsHooked Then
Return False
Else
lpPrevWndProc = SetWindowLong(WindowHandler, GWL_WNDPROC, AddressOf WindowProc)
IsHooked = True
Return True
End If
End Function
Public Sub Unhook()
Dim temp As Long
temp = SetWindowLong(WindowHandler, GWL_WNDPROC, lpPrevWndProc)
IsHooked = False
End Sub
Function WindowProc(ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Dim e As New ShellHookEventArgs
e.hWnd = hWnd
e.wMsg = wMsg
e.wParam = wParam
e.lParam = lParam
e.REMOVABLE_DEVICE_INFO = ShellHookEventArgs.REMOVABLE_DEVICE.NONE
If wMsg = wMsg_REMOVABLE_DEVICE Then
If wParam = wParam_REMOVABLE_DEVICE_INSERTED Then
e.REMOVABLE_DEVICE_INFO = ShellHookEventArgs.REMOVABLE_DEVICE.INSERTED
RaiseEvent Removable_Device(Me, e)
ElseIf wParam = wParam_REMOVABLE_DEVICE_REMOVED Then
e.REMOVABLE_DEVICE_INFO = ShellHookEventArgs.REMOVABLE_DEVICE.REMOVED
RaiseEvent Removable_Device(Me, e)
End If
Else
'e.TempMsg = "hwnd=" & hWnd & ", wmsg=" & wMsg & ", wparam= " & wParam & ", lparam=" & lParam
'RaiseEvent Removable_Device(Me, e)
End If
WindowProc = CallWindowProc(lpPrevWndProc, hWnd, wMsg, wParam, lParam)
End Function
Public Event Removable_Device(ByVal sender As Object, ByVal e As ShellHookEventArgs)
Class ShellHookEventArgs
Inherits System.EventArgs
Public Enum REMOVABLE_DEVICE
NONE = 0
INSERTED = 1
REMOVED = 2
End Enum
Public hWnd, wMsg, wParam, lParam As Integer
Public REMOVABLE_DEVICE_INFO As REMOVABLE_DEVICE
Friend TempMsg As String
End Class
Public Sub New(ByVal WindowHandler As Integer)
Me.WindowHandler = WindowHandler
End Sub
Public Sub New()
Dim tmp As New Form
WindowHandler = tmp.Handle
End Sub
End Class This Codes also create that same error. Can you plz give some solution more than you gave before? I'm not a good programmer and very week in C#. I need something details.
|
|
|
|
|
The code I gave earlier is all there is to it. You should remove your P/Invoke stuff, the SetWindowLong calls, etc. However, you are missing the Overrides keyword that makes your windowproc replace the default one for your Form. Look at the documentation for Overrides, and search some examples. I don't have any VB code around right now.
|
|
|
|
|
Thanks I got it I forget add this line:
MyBase.WndProc(m)
It gives all my solution.
|
|
|
|
|
you're welcome.
|
|
|
|
|
hi friends.
i am writting a share and unshare program and i use this code for share a folder
Private Sub Sharing()
Try
Dim managementClass As New ManagementClass("Win32_Share")
Dim inParams As ManagementBaseObject = managementClass.GetMethodParameters("Create")
inParams("Description") = fname
inParams("Name") = fname
inParams("Path") = fpath
inParams("Type") = &H0
Dim outParams As ManagementBaseObject = managementClass.InvokeMethod("Create", inParams, Nothing)
If Convert.ToUInt32(outParams.Properties("ReturnValue").Value) <> 0 Then
chkShare.Checked = True
End If '
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
this works successfully but now i dont know how i can unshare a folder... help me please
M.Alizadeh
|
|
|
|
|
You already know how to call the Create method on the Win32_Share class, so what's so hard about calling its Delete method?
All you do is a WMI search for Win32_Share object with the Name you want, then call its Delete method.
You may want to consult the documentation on Win32_Share[^]for more.
|
|
|
|
|
thanks for your answer
i searched many articles but i dont know how use Delete Method of the Win32_Share Class
when i use this cose:
Dim dir As String = fpath
Directory.CreateDirectory(dir)
'Create a ManagementClass Object
Dim managementClass As New ManagementClass("Win32_Share")
' Create ManagementBaseObjects for in and out parameters
Dim inParams As ManagementBaseObject = managementClass.GetMethodParameters("Delete")
Dim outParams As ManagementBaseObject
' Set the input parameters
inParams("Description") = fname
inParams("Name") = fname
inParams("Path") = dir
inParams("Type") = &H0
' Invoke the method on the ManagementClass object
outParams = managementClass.InvokeMethod("Create", inParams, Nothing)
'Confirm that the operation is successful
If CUInt(outParams.Properties("ReturnValue").Value) <> 0 Then
Throw New Exception("Unable to share the directory.")
End If
MessageBox.Show("Folder share deleted")
in this line: "inParams("Description") = fname" it has a error:Object reference not set to an instance of an object.
fname is not null and has value
M.Alizadeh
|
|
|
|
|
mehrnoosh wrote: i searched many articles but i dont know how use Delete Method of the Win32_Share Class
Try the documentation on MSDN. It's always a good place to start.
Win32-Share[^] and Delete method[^]
Alan.
|
|
|
|
|
You didn't bother reading the documentation in the link I gave you in my last post, did you?
There are no parameters to pass to the Delete method, so why are you calling GetMethodParameters?? What are you trying to set parameters?? Why are you still calling InvokeMethod on the Create method??
I already told you you need to SEARCH for a Win32_Share object with the NAME you want. You then call the Delete method on that instance.
mehrnoosh wrote: in this line: "inParams("Description") = fname" it has a error:Object reference not set to an instance of an object.
Of course it errors! Why would you set a Description on an object you're trying to delete?!
It's obvious that you don't have any idea what a single line of this code does or how it relates to the idea of creating a Share let alone deleting one. Having said that, I have to ask if you know how to do a WMI search for an object?
|
|
|
|
|