|
Hello!
I am developing an application to display different documents(txt, doc, xls, ppt, pdf files), arrange them on the desktop and scroll through the pages.
I use System.Diagnostics.Process.Start to open the relevant file with the right application. I use then Process.mainWindowHandle to resize, to move and scroll those apps with WinAPI methods.
It works good for documents for which every Process.Start call results in an independent process, e.g. I can open two txt-files in Windows' Notepad and I get two processes displayed in the task manager. I can get the mainWindowHandle of both easily and rearrange them.
But it crashes on mutex apps(right word?). The Microsoft Word Viewer is such a candidate. I open one document foo.doc, the Word Viewer starts a process. Then I start another "instance" of it with a different file bar.doc and it opens the file, but I don't get the right Process object returned, because the first instance(with foo.doc) adds bar.doc to its managed windows.
My code:
Public Overridable Function Start(ByVal x As Double, ByVal y As Double, _
ByVal width As Double, ByVal height As Double) As Boolean
Dim retValue As Boolean = False
Dim fred As ProcessThread
Dim waited As Boolean
_x = x
_y = y
_width = width
_height = height
'Starts the application with the file, ...
_process = Process.Start(_app_path, """" & _file.Path & """")
If Not IsNothing(_process) Then
'...but it crashes as soon as I try to access a member of _process
waited = _process.WaitForInputIdle()
If Not IsNothing(_process.Threads) Then
fred = _process.Threads.Item(0)
retValue = EnumThreadWindows(New IntPtr(fred.Id), _
AddressOf MoveCallback, IntPtr.Zero)
End If
End If
Return retValue
End Function
EnumThreadWindows is a WinAPI call and MoveCallback is a callback for it:
Private Function MoveWindow(ByVal hWnd As IntPtr, ByVal x As Integer, _
ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, _
ByVal bRepaint As Boolean) As Boolean
End Function
<dllimport("user32.dll", setlasterror:="True)"> _
Private Function EnumThreadWindows(ByVal dwThreadId As IntPtr, _
ByVal lpfn As EnumThreadDelegate, ByVal lParam As IntPtr) As Boolean
End Function
Private Function MoveCallback(ByVal hWnd As IntPtr, _
ByVal lParam As IntPtr) As Boolean
Dim screenwidth As Integer = Screen.PrimaryScreen.WorkingArea.Width
Dim screenheight As Integer = Screen.PrimaryScreen.WorkingArea.Height
Return MoveWindow(hWnd, 0, 0, 1, screenwidth / 2, screenheight / 2, True)
End Function
</dllimport("user32.dll",>
Do you know how to access to the last instance of a running process? Am I trying to do something stupid?
Please help me. I am experienced with VB.Net and I have done a lot of maintenance work, but I am completely new to WinAPI calls.
Regards, Thomas
I am on .Net 1.1
|
|
|
|
|
Hi,
I am creating a website which will consist of a dedicated page for each city and town in the country (so a few thousand potentially). The keywords in each page will be the same apart from the city or town name. Rather than create each page manually by hand , is there something in the .NET framework which will help insert text into a HTML file, therefore speeding up this process?
Thanks in advance
Adrian
|
|
|
|
|
BungleBonce wrote: I am creating a website which will consist of a dedicated page for each city and town in the country (so a few thousand potentially).
Are you sure this is the best solution? Have you considered developing a simple content-management system, storing your page content in an external source e.g. database or XML files? You could then develop an ASP.NET website to display the data, dynamically fetching the content for a particular city/town as required.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Thanks Paul.
I could be wrong here, but by having some static pages on a website is more beneficial for Search Engine Optimisation. I still plan to have dynamically generated content on each page, but as far as keywords and title tags etc, these would be static HTML. I've read that search engine indexing does not like pages with lots of querystring parameters in the URL.
The site I'm working on will only be a success if it can rank highly on search engine results, so I am conscious of making the site as Search Engine friendly as possible.
Any thoughts?
Thanks
Adrian
|
|
|
|
|
Search engine optimization isn't a subject I'm particularly familiar with. However a quick Google[^] search threw up some interesting articles. Url rewriting appears to be a recommended technique for optimizing dyamically generated web pages with search engines.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
I want to show the query result in Html table view directly..
with this sql statements we can make html table view for 'select * from tab'..It is working in Oracle Console..How Can I execute it in VB.net
SET markup HTML ON
spool INDEX.html
SELECT * FROM tab;
spool off
SET markup HTML off
|
|
|
|
|
Please don't cross post. Pick one forum that is relevant.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
I wamt the URL of my project to be "http://project1" irrespectives of the pages u visit in the project...Howis it possible...
|
|
|
|
|
In your Global.asax , I believe you need to add the following :-
protected Sub Application_BeginRequest(ByVal sender as Object, ByVal e as System.EventArgs)<br />
<br />
Dim incoming As HttpContext = HttpContext.Current<br />
incoming.RewritePath("http://Project1") <br />
<br />
End Sub
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
It shows an error that the virtual path "http://project1" doesnt exist
|
|
|
|
|
I am using to forms (Transactions Form and ProductList Form)
The transactions form is a parent form and there is a button to show the productlist form which shows all the available products in a gridview control.I am using showdialog method to open the productlist form.Once the productlist form is open then user can not do anything on the parent form unless he close the productlist form which I think is clear from showdialog method.
Now what I want is that when user select any row from the datagridview from productlist form and click ok button then the value of the first column of the selected row should be updated in the parent form's textbox (txtProduct) and the productlist form will be closed.
The datagridview on the productlist form is bound to a datatable.
Any idea how I can pass the value from the child form to parent form?
Thanks in advance
Ejaz
|
|
|
|
|
Someone may suggest modifying the constructor of the forms, or having a method to pass the data, etc. However, Pete O'Halon with slap anyone that suggests that. You should implement the Model-view-controller design pattern.[^] Read up on it. It'll make you a better "developer"
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
This is help for u..
use this stmt in child window javascript
window.returnValue=document.getElementById('<%=hfldConCatStr.ClientID%>').value;
use this in parent window
var retVal=window.showModalDialog('dsfdf.aspx');
|
|
|
|
|
Ejaz Bhai!
try this, Its simple to implement....
in Parent Form use this:
<br />
dim myVal as integer<br />
Public Property SetVal() As Integer<br />
Get<br />
Return myVal <br />
End Get<br />
Set(ByVal value As Integer)<br />
myVal = value<br />
End Set<br />
End Property<br />
in child form:
dim parentObj as [parentForm]
parentObj.SetVal = [Any Integer Valu]
now close child form and use variable 'myVal' in parent form as output from child form.
colgateas900197
|
|
|
|
|
I normally make data and view objects and every view can access the data so it can easily be shown and changed. The data object is globally and unique. If data gets changed you got to trigger an update, in your case check whether the dialog returns with OK => Reload from data object.
Greetings from Germany
|
|
|
|
|
Hello there,
I m really stuck on one thing i have searched almost every where on the internet but so far no solution so thats why i m positing my problem here.
I have to develop a program that will copy or upload an excel file to a ftp server, this part is completed but the problem is that my client is behind proxy, so basically have to send through proxy. There is class ftpwebrequest but it work for framework 2 and above and i have use framework 1.1.
If anyone know a solution or link, i ll be grateful.
Thanks in advance.
|
|
|
|
|
Hi friends..
I am running a login form in Vb.net.I get stack overflow exception.(in Public Sub New()..).wat could be the reason and how to solve it..?
Someone help in this regard as early as possible..
Thanks & Regards,
Balaguru
|
|
|
|
|
Resursion maybe? Difficult to tell without seeing the source code.
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Hi,
the most common way to get a stack overflow is by calling a property (get or set)
that by mistake references itself, rather than the object data it is supposed to access.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
modified on Tuesday, January 29, 2008 11:51:02 AM
|
|
|
|
|
In my VB.net application I want to make sure that only one instance of application is running at a time on a client computer. Furthermore I want to perform following tasks:
1. My application should accept a command line argument (Customer Id).
2. Pass this argument to already running instance of the application.
3. Search and load customer data from database and display the respected form in the existing instance.
I have managed to restrict multiple instance by using Process object and easily accepted command line arguments by using My.Application.CommandLineArgs collection.
Public Sub Main()
Dim tempProcess As Process
tempProcess = checkInstance() ' A function which validates current process
If tempProcess Is Nothing Then
Application.Run(New frmWelcome)
Else
Dim hwnd As Int32
hwnd = tempProcess.MainWindowHandle.ToInt32
Try
If hwnd > 0 Then
If IsWindowVisible(hwnd) = False Then
ShowWindowAsync(hwnd, ShowWindowConstants.SW_MAXIMIZE)
End If
SwitchToThisWindow(hwnd, True)
SetForegroundWindow(hwnd)
SetActiveWindow(hwnd)
LoadContact() 'A function which extracts command line argument and call a function from existing running instance.
Application.Exit()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
End Sub
When I call a function from existing instance I get an error 'Unable to create window handle'.
Basically I am not an experienced VB.Net programmer, I will appreciate if someone have a look into it and help me out. I will be very thankful if someone pass me an example.
Many thanks
Nas
|
|
|
|
|
Isn't this a copy of a previous post[^]? And were possible solutions not given in this thread[^]>
Perhaps you need to consider an alternative approach to resolving your issue?
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Yes it was the copy of my previous post. In my last thread I have been asked to search on MSMQ but during search I found out .Net Remoting is also a possible solution. My development level is not upto standard that I could decide what technology should be used and how exactly to tailor it to meet the requirement. I just need initial guidance.
Many thanks
|
|
|
|
|
I think, from what you have said previously, that Remoting is NOT what you require as you are only interested in the application already running on the local PC, therefore MSMQ is most likely to be the simplest solution.
There are some very good kick start guides to MSMQ on the web.
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Just an after-throught :-
To check that the program is the first instance, try this code :-
'Check to see if already running<br />
Dim currentProcess As Process = Process.GetCurrentProcess()<br />
Dim allProcesses() As Process = Process.GetProcessesByName(currentProcess.ProcessName)<br />
<br />
If allProcesses.Length > 1 Then<br />
'already running<br />
Else<br />
'not already running<br />
End If
You could also pass the necessary parameter via a file. For instance write an file somewhere, containing the necessary parameters and use a FileSystemWatcher to monitor the file for changes.
Depands how slick you want it, but the simplest options are usually the best.
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Many thanks Steve, I am looking into MSMQ and your idea of writing a file seems solving the problem.
Nas
|
|
|
|