|
That sounds like what I've seen on Technet/Help....problem is I'm not a programmer & dont know the syntax or where in my vb app it should go(ie form1_load)....how would you script that, given the app name of "CDA"?
This is great OJT....I'll keep digging in Help documents, but your help is great to get me putting the pieces together. Thanks!
|
|
|
|
|
Disclaimer: This code may not be 100% syntax-correct but it should get you started (particularly the call to FindWindowEx, my memory is unsure.)
In declarations:
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function FindWindowEx(ByVal parentHandle As IntPtr, _
ByVal childAfter As IntPtr, _
ByVal lclassName As String, _
ByVal windowTitle As String) As IntPtr
Private Declare Auto Function GetDesktopWindow Lib "user32.dll" () As IntPtr
End Function
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function ShowWindow(ByVal hwnd As IntPtr, ByVal nCmdShow As Int32) As Boolean
End Function
In code, before where the screen shot is taken:
' Get the window's handle
Dim WindowTitle as String = "Notepad"
Dim WindowToMax as IntPtr = FindWindowEx(GetDesktopWindow(), IntPtr.Zero, IntPtr.Zero, "WindowTitle")
' Maximize it
ShowWindow(WindowToMax, 3) ' 3 is for ShowMaximized
I use FindWindowEx to find the window to maximize (the window with "Notepad" as the title). Then pass the window's handle to ShowWindow(). There's a lot of examples out there for FindWindowEx and ShowWindow in case you need more.
|
|
|
|
|
Arrgh...so close...
I got a .Net security error
The type of the first permission that failed was:
System.Security.Permissions.SecurityPermission
The Zone of the assembly that failed was:
MyComputer
Heres my modifications:
<Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function FindWindowEx(ByVal parentHandle As IntPtr, _
ByVal childAfter As IntPtr, _
ByVal lclassName As String, _
ByVal windowTitle As String)
End Function
Declare Auto Function GetDesktopWindow Lib "user32.dll" () As IntPtr
<Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function ShowWindow(ByVal hwnd As IntPtr, ByVal nCmdShow As Int32) As Boolean
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim WindowTitle As String = "QuadraMed CPR - Saint Francis Hospital Ulticare System"
Dim WindowToMax As IntPtr = FindWindowEx(GetDesktopWindow(), IntPtr.Zero, IntPtr.Zero, "WindowTitle")
ShowWindow(WindowToMax, 3) ' 3 is for ShowMaximized
End Sub
|
|
|
|
|
Try this one:
Imports System.Runtime.InteropServices
Public Class Form1
<Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function ShowWindow(ByVal hwnd As IntPtr, ByVal nCmdShow As Int32) As Boolean
End Function
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function FindWindow( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As IntPtr
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim NotepadHwnd As System.IntPtr = FindWindow(Nothing, "Untitled - Notepad")
MsgBox(NotepadHwnd.ToString)
ShowWindow(NotepadHwnd, 3)
End Sub
End Class
FindWindowEx is probably overkill, and I should have mentioned FindWindow instead. The window title "Untitled - Notepad" has to match exactly. If you don't know what the window title will be, you can enumerate all desktop windows and then call GetWindowText for each one until you find the window that you want to maximize.
|
|
|
|
|
Almost there. My security error was due to not having published(could not run from VS CTRL-F5)
It works great on Notepad, but not on the 3rd party app....how do I "enumerate all desktop windows and then call GetWindowText for each one "?
Appreciate your patience & walking me thru this!
|
|
|
|
|
Sure, now this isn't the prettiest code - it's darn ugly, in fact. But it does work. I threw it into a Module but it's probably best suited for a class.
Imports System.Runtime.InteropServices
Module Module1
Public Delegate Function EnumWindowsProc(ByVal hWnd As IntPtr, ByVal lParam As Integer) As Boolean
<DllImport("user32")> Public Function EnumWindows( _
ByVal lpFunc As EnumWindowsProc, ByVal lParam As Integer) As Integer
End Function
Private Declare Auto Function GetWindowText Lib "user32" _
(ByVal hWnd As System.IntPtr, ByVal lpString As System.Text.StringBuilder, _
ByVal nMaxCount As Integer) As Integer
Private Declare Auto Function FindWindowEx Lib "user32" _
(ByVal hWnd1 As IntPtr, ByVal hWnd2 As IntPtr, _
ByVal lpsz1 As String, ByVal lpsz2 As String) As System.IntPtr
<Runtime.InteropServices.DllImport("user32.dll")> _
Private Function ShowWindow(ByVal hwnd As IntPtr, ByVal nCmdShow As Int32) As Boolean
End Function
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Function FindWindow( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As IntPtr
End Function
Public Function EnumWindowCBK(ByVal hWnd As IntPtr, ByVal lparam As Integer) As Boolean
Static WindowText As New System.Text.StringBuilder(100)
Static nRet As Long
nRet = GetWindowText(hWnd, WindowText, WindowText.Capacity)
If nRet <> vbNull Then
If InStr(WindowText.ToString, "Notepad") <> 0 Then
' maximize it
MsgBox(hWnd.ToString)
ShowWindow(hWnd, 3)
End If
End If
EnumWindowCBK = True
End Function
End Module
Then whenever you want to maximize the window, call:
Module1.EnumWindows(New Module1.EnumWindowsProc(AddressOf EnumWindowCBK), 0)
It's pretty self-explanatory. EnumWindows gets all the desktop windows, and in the callback function EnumWindowCBK I compare the window's title with what we are looking for - it's up to you to decide if you only want the window text to match exactly or not. In this one, as long as it contains "Notepad" somewhere in there it will be maximized.
Sorry for not cleaning up that code better.
|
|
|
|
|
Hooooray!
Your help is greatly appreciated. I'm not a programmer, but with your help I accomplished building a screenPrint applet to call in one of our major apps.
I'm sure its not clean. but it does the job....
maximizes the host app,
then takes the snapshot,
puts it in a viewer for printing(with left edge cropped).
|
|
|
|
|
Awesome! Glad I could help. Careful, or you'll become a programmer!
|
|
|
|
|
i hav a table wit one record i write the following code to retieve it and write to a file it works. but when i run as window service it does not write anything to the file. is there a better approach to i should use
Dim con As New SqlConnection("server=PRGLAP11;database = Diamond ;uid=sa;pwd=rr")
Dim con As New SqlConnection(connectionString)
Dim com1 As New SqlCommand(ins, con)
com1.CommandType = CommandType.StoredProcedure
con.Open()
Dim dr1 As SqlDataReader
dr1 = com1.ExecuteReader()
con.Close()
dr1.Read()
s1 = dr1.Item(1)
s2 = dr1.Item(2)
s3 = dr1.Item(3)
Dim f As New StreamWriter("c:\test2.txt")
f.Close()
|
|
|
|
|
Did you check the event viewer on the system where the app is running as a service to see if any errors are being generated when it tries to create and write to a file?
When you set up the service, you must have had to set up a log on account for that service. I am wondering if maybe that log on does not have write permission to the drive or directory where you are writing the file. I don't think that would prevent the service from running, but I would expect it to generate some errors that are likely viewable via the event viewer.
|
|
|
|
|
actually the service is running my aim is to extract the information from database. it seems the reader does not retrn anyting. am using the file as my dubug technic. is ther a better way to debug
|
|
|
|
|
Yes there is a better debug method for windows services. Check out the MSDN article at the following link, that should help...
How-to Debug Windows Service[^]
|
|
|
|
|
thanks i appreciate. will contact u if i hav more issue on that
|
|
|
|
|
i did what i read setting break point on the onstart method and it end sub when i pressed f10. it jumb to the line that instatiate timer if i press f10 again it show error that i acnot debug winservice
Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
'System.Threading.Thread.Sleep(15000)
Try
t = New Timer(2000) 'stop here
't = New Timer(TimeInterval)
AddHandler t.Elapsed, AddressOf TimerFired
With t
.AutoReset = True
.Enabled = True
.Start()
End With
Catch ex As Exception
log.WriteEntry(ex.Message, EventLogEntryType.Information)
End Try
End Sub
|
|
|
|
|
So you were able to attach to the process, move in to debug mode, but then it died on you? I'm not sure but that might be because debugging a service starting from OnStart can be problematic because if you spend too much time in OnStart, your service won't actually start. You might try putting a sleep right before you do your database connection, provided that is not in OnStart, and let OnStart run without any breaks. Then maybe you can get into debug mode before the connection happens and then step through the code from there.
|
|
|
|
|
i put the break point on timer fire . on pressing f11 it jump to dim log line. then to sub new . the yellow point disappear.then the error "cannot start from the command line or debbuger....."
Dim log As New EventLog("Application", ".", "Diamond eMail Solution")
Private Sub TimerFired(ByVal sender As Object, ByVal e As ElapsedEventArgs)
'Working()
'getApplicationData()
ProcessMail()
End Sub
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
|
|
|
|
|
Hiii
I m working on outlook 2003 add ins using vb.net. and i want to inset the particular text at the end of the curent message in reply window not at the bottom of the message.
Ex:
Hiii
Mr XXX
From
M [Insert Text Here]
---------------------------------------------------------------------------------------
From:khatrimitesh@hotmail.com
Sent: Sunday, June 22, 2008 6:00 PM
To: mitesh.khatri
Subject: Outlook Project Specs
Mitesh
Regards
M
I want to insert the text at the <inset text="" here=""> location not at the end of this message in reply window.
Please suggest how i do this.
Thanx
~Khatri Mitesh
|
|
|
|
|
Dear Gents,
I have added a image in picturebox say image1.jpg when form s loaded. In a button click I want to check whether image in a picture box is image1.jpg or some other else.
Pls help me to achieve this
Regards
Azeem
|
|
|
|
|
an imagebox has a property 'initailimage'
my suggestion would be to put the image1.jpg into this property (and never change it)
then compare the imagebox.image to the imagebox.initialimage
I vagly rember doing something like this in the past and it did work so...
|
|
|
|
|
If picturebox1.Image = image1 then
do something...
End If
Just replace [image1] with the location of the image you want to check.
How many bytes of text have I typed in my lifetime??? Man, I wish I kept track...
|
|
|
|
|
First, I am assuming you marked the other two answers (which would have worked) as a bad answer. Don't do this if you do not understand what they are saying, it just agravates other forum dwellers.
Second, you should be able to store unique picture information in the Tag property (as a string), and then compare the unique values of different images when replacing the image. I would suggest the unique value be the filename of the picture.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
Thanks a lot.
Absolultely corrct.
Regards
Azeem
|
|
|
|
|
Hi all,
i have a problem where i have a recordset of about 200 records containing customer names, for each record, i have to open a crystal report passing the recordset data as parameter and then exporting that report to html format (4.0)
main problem is that when i run the program it works fine for few records and then it gives an error
"Unhandled win32 exception occured in vb6.exe[7828] "
and thus terminating the program.
this error appears randomly sometimes after 15 records and other times after 50+ records.
i am attachign the code with this thread please havea look at the code and do suggest me a solution. it looks as if its related to memory management.
thanks in advance.
regards,
atin...
code
Private Sub Command1_Click()
stdt = CDate(strStDt)
seldt = CDate(strSelDt)
'rs is recordset db is connection object
rs.Open str1, db, adOpenDynamic, adLockOptimistic
Set cry = New CRAXDRT.Application
ReDim strCS(1 To rs.RecordCount)
For i = 1 To rs.RecordCount
strCS(i) = rs.Fields(0)
rs.MoveNext
Next i
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
Set rep = cry.OpenReport("DtrList-xbndrstatement.rpt")
For i = 1 To UBound(strCS)
rep.EnableParameterPrompting = True
rep.DiscardSavedData
rep.ParameterFields.GetItemByName("seldate").AddCurrentValue seldt
rep.ParameterFields.GetItemByName("stdate").AddCurrentValue stdt
rep.ParameterFields.GetItemByName("stCus").AddCurrentValue strCS(i)
With rep
.ExportOptions.FormatType = crEFTHTML40 'exporting to html format'
.ExportOptions.DestinationType = crEDTDiskFile
.ExportOptions.HTMLFileName = "C:\" + strCS(i) + ".html"
.Export False
End With
Next i
Set rep = Nothing
cry.CanClose
Set cry = Nothing
End Sub
|
|
|
|
|
Hi,
I am trying to debug a .net 2003 windows service on a remote computer using VS2003.
I am connected to the remote pc by a VPN.
I have installed the msvcmon.exe on the remote and ran it in tcpip mode.
I am able to connect to the remote computer and service process using debug, Processes in VS2003. Using Tcpip.
But I put a breakpoint on a line and the debugging is not being hit.
Is this a futile exercise???
Should I upgrade my service to 2005 and use that debugger??
Or is it something I am missing??
Malcolm
|
|
|
|
|
hi ,
I m developing application which contain information about chemical compound. all formula of chemical compound contains superscript & subscript. I store value in database using sub & sup Tag .but crystal report does not support these tag
how can we change formula to subscript & superscript form in crystal Report as following
NH4Al(SO4)2.12H2O
Any help will be appreciated
Thanks in advance
K.mani
Software Engineer,
C-Tech Environmental Labs PVT Ltd,
Chennai(India)
By
K.mani
|
|
|
|