|
Presmably this will transfer the focus to the clicked window, this is fine in some instances but in others where I want to position the cursor brfore sending text this will be a problem. Can you think of a way of returning the focus to my app. after positioning the cursor.
Thanks,
|
|
|
|
|
The control will be still with your application , just after sending the click command , write
Me.Activate()(i don't recommend its use)
this will activate your form , but if you have to enter any text in a different application the focus must be on the other application , not on your .
To make it more clear let us consider an example, if i have application "A" running it has a text box where we need to enter user name (without using a keyboard & mouse) , i will first position my mouse location on the text box (using the code i sent earlier) and we would send a mouse click (using the same code) just below the Mouse click code(now the focus is on other form (application "A")) we will write the code to send keystrokes (focus is on another form but your code will be executed , till your function ends), this keystroke would be sent to the form in focus (that is the form of application "A").
Also if you want to send keystrokes, you must use the Win32 API Called "keybd_event" defined in user32.dll , the same way we used mouse_event in previous reply.
does this make sense for you
-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com
|
|
|
|
|
Thanks Bharat,
That's very clear.
I tend to use sendkeys.send rather than "keybd_event" it that OK?
Steve
|
|
|
|
|
I've come across another problem now.
I often use the forms topmost property, setting it to true, It has allways worked fine but now on this form it does not remain topmost. This happpens before any of the API's are called. Even just loading the form and moving away from that form causes it to be hidden. Any Ideas.
Thanks,
Steve
|
|
|
|
|
Don't wory, I just closed VS ran it again, reloaded the project and it works fine.
Wierd!
Steve
|
|
|
|
|
How can I create a DataTable from a System.Collections.Generic.List please?
(I am a VB newbie )
|
|
|
|
|
One way you can do this is using Reflection[^], but why do you want to do this?
|
|
|
|
|
My existing application (company application) returns data as a Generic.List. But, I need to filter the data displayed in a DataGridView. So, I need to use a DataView (which I can filter on) which gets it's data from the intended DataTable.The DataGridView then has its DataSource as the DataView.
if that makes any sense at all (hopefuly I'm on the right track)
Anyway, many thanks for the Reflection pointer. I'll start researching that right now.
|
|
|
|
|
Yes, it makes sense, but I think it would be much easier if you use System.ComponentModel.BindingList<t>[^] since that collection can used as a datasource in binding. Put the data from the List<t> to BindingList<t>.
Then what comes to filtering, you could most likely use LINQ to Objects[^]. This way you would save all the trouble of using reflection.
|
|
|
|
|
As I am new to VB I'll have to hammer the VS help and Google get this straight in noodle.
Many thanks for your pointers.
|
|
|
|
|
You're welcome
|
|
|
|
|
I am using MS Access 2007 on a Vista system.
I want to programatically manipulate Vista file properties details of .jpg files (Tags, Comments, etc) with a VBA script in Access 2007.
DSOFile.dll shows Summary fields but not the new Detail fields Vista uses. Any idea how I might be able to do this?
|
|
|
|
|
Hi !
I have two comboboxes in VB.NET. One is to display State from state table and another is used to display districts from district table. When i select a partiular state districts corresponding to that state only needs to be displayed.The problem is at the time of databinding combobox control what query i need to place in the Query builder of TableAdapter Configuration Wizard so that if i select a particular state districts corresponding to that state only needs to be displayed. I tried with creating SQL Dataadapters and datasets manually but it doesn't work out. Also i tried various types of SQL Server joins in Query Builder of TableAdapter Configuration Wizard but it doesn't work out. So pls help me regarding this problem.
modified on Saturday, January 31, 2009 2:34 AM
|
|
|
|
|
This is so trivial, it's hard to know where to start. You grab the id of the item selected in the first column and use it to select the data you need to show in the second column. I don't see how you can mess that up, you're going to need to post some code, etc, so we can try to work out what you're screwing up.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I have placed my Code below. Everything works fine except that the Excel application is running at the backgroung even after quitting the Excel using code also setting the Excel object to Nothing. But the Excel application terminates on closing the application.
When I click the button for the first time, the excel application appears in the task manager, but is not closing. But when I click the button for the second time a second Excel application instance appears in the task manager, but it closes immediately when I set the Excel object to "Nothing".
Anybody, pls suggest me how to close the excel instance which is created for the first time.
Private Sub ExportExcel_Click()
Dim objExcel As Excel.Application
Dim objWorkbook As Excel.Workbook
Dim objwksSheet As Excel.Worksheet
Dim Msg, style, Title, Response
style = vbYesNoCancel + vbQuestion + vbDefaultButton2 ' Define buttons.
Msg = "Before Exporting the Tags to Excel, all the unsaved Excel Files must be closed. Are you sure you want to Continue?"
Title = "PV Trend" ' Define title.
Response = MsgBox(Msg, style, Title)
If Response = vbNo Or Response = vbCancel Then ' User chose No.
Exit Sub
End If
Dim i As Long
Dim n As Long
Dim gridChart As ChartObject
Dim tagdataChart As Chart
Dim curentChart As Object
If SelTagsCnt <= 0 Then
MsgBox "No Tags are there to export"
Exit Sub
End If
'***************************************************************
' create new hidden instance of Excel and open its workbooks collection
If DebugMode = True Then
xlsfilename = "c:\testExcel.xls"
Else
xlsfilename = glbSysPath & "esim\Model\" & ModelName & _
"\Instructor\PVTREND" & ModelName & ".xls"
End If
' Set objExcel = New Excel.Application
' objExcel.Workbooks.Open xlsfilename
' objExcel.Worksheets("Sheet1").Activate
' objExcel.DisplayAlerts = False
' With objExcel
' .ActiveWorkbook.Save FileName:= _
' xlsfilename, _
' FileFormat:=xlNormal, Password:="", _
' WriteResPassword:="", ReadOnlyRecommended:=False, _
' CreateBackup:=False
'
' .ActiveWindow.Close
' End With
'*******************************************************************
On Error Resume Next
'Call EmpMSFgrid_load
'Set objExcel = GetObject(, "Excel.Application")
Set objExcel = New Excel.Application
' If Err.Number Then
' Err.Clear
' Set objExcel = CreateObject("Excel.Application")
' If Err.Number Then
' MsgBox "Unable to open Excel Application."
' End If
' End If
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add
objExcel.Worksheets("sheet1").Activate
xlAPP.Worksheets("Sheet1").Range (strRangeXVal)
' Merging the First 3 Rows
With objWorkbook.Sheets("Sheet1")
For i = 1 To 3
.Range(.Cells(i, 1), .Cells(i, 50)).Select
Selection.Merge
Next i
End With
' Add Heading "PROSIMULATOR HISTORICAL PV TREND PLOT" in the First Row of the Excel File
objWorkbook.ActiveSheet.Cells(1, 1).Font.Bold = True
objWorkbook.ActiveSheet.Cells(1, 1).Font.Size = 18
objWorkbook.ActiveSheet.Cells(1, 1).Font.Color = RGB(0, 0, 255)
objWorkbook.ActiveSheet.Cells(1, 1).Value = " PROSIMULATOR HISTORICAL PV TREND PLOT"
objWorkbook.ActiveSheet.Cells(1, 1).Interior.Color = RGB(255, 128, 0) 'RGB(185, 185, 185)
' Format 2nd Row
objWorkbook.ActiveSheet.Cells(2, 1).Font.Bold = True
objWorkbook.ActiveSheet.Cells(2, 1).Font.Size = 11
objWorkbook.ActiveSheet.Cells(2, 1).Font.Color = RGB(41, 11, 164)
objWorkbook.ActiveSheet.Cells(2, 1).Value = "Model Name:" & ModelName
'objWorkbook.ActiveSheet.Cells(2, 1).Interior.Color = RGB(137, 200, 237)
objWorkbook.SaveCopyAs xlsfilename
' .ActiveWorkbook.SaveAs FileName:= _
' xlsfilename
objWorkbook.Close savechanges:=False
objWorkbook.Close
'Set objWorkbook = Nothing
objExcel.Visible = False
objExcel.ActiveWindow.Close
objExcel.Quit
objExcel.Application.Quit
' End With
Dim sTitle As String
Dim iHwnd As Integer
Dim ihTask As Integer
Dim iReturn As Integer
sTitle = "EXCEL"
iHwnd = FindWindow(0&, sTitle)
iReturn = PostMessage(objExcel.hWnd, WM_QUIT, 0, 0)
Set objWorkbook = Nothing
Set objExcel = Nothing
Set curentChart = Nothing
Set tagdataChart = Nothing
Set gridChart = Nothing
End Sub
|
|
|
|
|
Excel won't quit because your code still has references to object you were using in Excel. You have to explicitly set EVERY object you create in the Excel object model to Nothing, THEN call Quit, otherwise, you'll get the behavior you're seeing.
|
|
|
|
|
i have installed Visual Studio 2005.net and a writing a student management system,however, i need to create a help file,but i have got no clue....where do i begin to create one..
|
|
|
|
|
You can find a pretty tutorial here[^].
|
|
|
|
|
How to make my application shareware
|
|
|
|
|
Give it away
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
|
Hi all,
I'm currently working on an application that opens media files with respect to their file extensions. Images are opened with Microsoft image viewer, video is opened with VLC and mp3 is supposed to be played with windows media player/VLC. So far opening images works fine but when I try to open video or music files i get the error that the opened application is unable to play the file.I'm positive that It has something to do with the spaces on the file location e.g. c:\Program Files\Windows Media Player\something.mp3. Question is how do I make it that the location doesn't incur any spaces or is there another way to open the files in their respective application aside from what I've been doing. I'm using vb6 by the way. Below are the codes I use for my task:
Images
Shell "rundll32.exe C:\WINDOWS\System32\shimgvw.dll,ImageView_Fullscreen " & txtscreenshot.Text & "", vbMaximizedFocus
Video
Shell ("C:\Program Files\VideoLAN\VLC\vlc.exe " & txtscreenshot.Text & ""), vbNormalFocus
Music
Shell "C:\Program Files\Windows Media Player\wmplayer.exe " & txtscreenshot.Text & "", vbNormalFocus
Many thanks for all your replies!
|
|
|
|
|
Shell "C:\Program Files\Windows Media Player\wmplayer.exe '" & txtscreenshot.Text & "'", vbNormalFocus
Notice the extra quotes around "txtscreenshot.Text"
tatchung wrote: I'm using vb6
..why? VB.NET is a free download, check out Visual Basic.NET Express
I are troll
|
|
|
|
|
Hi! Thanks for the reply
Eddy Vluggen wrote: Notice the extra quotes around "txtscreenshot.Text" Smile
Yeah I've tried removing that quote but it still doesn't open. So in static "txtscreenshot.Text" generates path names like "C:\Documents and Settings\Computer1\Desktop\New\something.mp3". Shell command recognizes "C:\Documents" as 1 file "and" as another and so on. How can I make it recognize the path name as it is?
Eddy Vluggen wrote: ..why? VB.NET is a free download, check out Visual Basic.NET Express Smile
I know...that's a great deal of my problem
Aim small, miss small
|
|
|
|
|
tatchung wrote: I know...that's a great deal of my problem
What does this mean ? VB6 was always crap, and it's been unsupported for a long time. In VB.NET, you drag a WMP control onto your form and tell it what to play, easy.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|