Article | 41023266 |
Type | HowTo |
Product | Engine |
Version | 4.0.4.1023 |
Date Added | 10/9/2003 |
Submitted by | Steve Smith |
Keywords |
How to close a form in VB/C#(.NET) with an open vectordraw command?
Visual Basic 6.0
You have to add these API declares in a module
Public
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As
Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As
Long
Public Const WM_CLOSE = &H10
Then add these code in Form_QueryUnload event :
If VDraw.CommandAction.OpenLoops > 0
Then
Cancel =
True
VDraw.CommandAction.Cancel
PostMessage Me.hwnd, WM_CLOSE, 0, 0
End If
VisualC# (.NET)
You have to add these API declares :
[DllImport("user32.dll", CharSet=CharSet.Auto)] public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, int lParam); [DllImport("user32.dll", CharSet=CharSet.Auto)] public static extern IntPtr PostMessage(IntPtr hWnd, int msg, int wParam, int lParam); const int WM_CLOSE = 0x10;
Then in form closing event put the following code:
while (vdraw.CommandAction.OpenLoops>0) { e.Cancel = true; vdraw.CommandAction.Cancel(); PostMessage ( this.Handle, WM_CLOSE, 0, 0 ); }
Don't forget "using System.Runtime.InteropServices;"