|
i agreed with him and want to add some more clarification in these comments that if other application is custome application and you have the source available then you can raise an event for the selection you have made.
Hope you got the idea.
Be a part of solution, rather then be a part of problem
|
|
|
|
|
Nope.
it should work every where.
thanks everybody.
A.E.K
|
|
|
|
|
A.E.K wrote: Nope.
it should work every where.
thanks everybody.
That can not be easily done, and you shouldn't need to do something like that either for a typical application. Perhaps you need to reconsider your application design?
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
I have a datagridview control and all i'm wondering is if there's a way I can select all the contents (and the columns) and store in a variable
|
|
|
|
|
try this
Dim arr(dgv1.RowCount * dgv1.ColumnCount - 1) As DataGridViewCell
dgv1.SelectAll()
dgv1.SelectedCells.CopyTo(arr, 0)
A.E.K
|
|
|
|
|
that put it in the variable arr right? Since it's in an array, how would I output that into a textbox or something similar
|
|
|
|
|
use the Value proeprty of DataGridViewCell .
A.E.K
|
|
|
|
|
Is there any way to make a .net webpage, and in the server script to grab the URL and save the content to actual HTML file?
|
|
|
|
|
Simple answer: yes.
In the code behind you will need to utilize a component (or write one) that makes the http request to the server running the .net webform and cache the response.
The simplest mechanism would be to open a socket to port 80 (unless you're running https) of the server, send the GET or POST request and cache the response. You'll need to strip off the HTTP headers.
eg. send:
<br />
GET /some/dotnet/file.aspx HTTP/1.1
check the reponse contains:
HTTP/1.1 200 OK
in the first line.
To strip off the HTTP headers in the response, look for the first empty line. The HTML content should be after that.
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
Here is a function that lets you do that:
Public Function GetWebPageResult(ByVal webPG As String) As String<br />
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(webPG), HttpWebRequest)<br />
<br />
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)<br />
<br />
Dim receiveStream As Stream = myHttpWebResponse.GetResponseStream()<br />
<br />
Dim encode As System.Text.Encoding = System.Text.Encoding.GetEncoding("utf-8")<br />
<br />
Dim readStream As New StreamReader(receiveStream, encode)<br />
GetWebPageResult = readStream.ReadToEnd() ' Use this 'readStream' where ever you want.<br />
<br />
End Function
Just call this function and pass the webpage URL to it. It will grab the html content of the page and return it as a string as the result of the function.
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
Hi,
IMO you should Close both the WebResponse and the Stream inside your function.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc Pattyn wrote: IMO you should Close both the WebResponse and the Stream inside your function.
LOL... oops.... my bad.
Yeah, make sure to close both those.
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
I'd forgotten about that class, cheers. Been working on winforms too long!
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
Hi Digi, thatnks for the reply.
The function is awesome. it works like charm ^^
BTW, i just find out another solution, to share with you guys here =D
I used webclient class, there is a readopen() method to achieve this.
here is a sample class which i get from msdn.
Public Class Test
Public Shared Sub Main(args() As String)
If args Is Nothing OrElse args.Length = 0 Then
Throw New ApplicationException("Specify the URI of the resource to retrieve.")
End If
Dim client As New WebClient()
' Add a user agent header in case the
' requested URI contains a query.
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)")
Dim data As Stream = client.OpenRead(args(0))
Dim reader As New StreamReader(data)
Dim s As String = reader.ReadToEnd()
Console.WriteLine(s)
data.Close()
reader.Close()
End Sub 'Main
End Class 'Test
|
|
|
|
|
How do I get my app to display a console window?
(As in the little black screen)
_______________________________________________________________________
http://www.readytogiveup.com/[ ^]
"you can't forget something you never knew..." M. Du Toit
|
|
|
|
|
I think there is a function GetConsoleWindow but I'm not 100%.
_____________________________________________
Flea Market! It's just like...it's just like...A MINI-MALL!
|
|
|
|
|
evilnoodle wrote: How do I get my app to display a console window?
Just use:
Process.Start("cmd.exe")
Or if you want to associate it with a named process:
<br />
Dim ps1 As New System.Diagnostics.Process<br />
ps1.StartInfo.WindowStyle = ProcessWindowStyle.Normal<br />
ps1.StartInfo.CreateNoWindow = False<br />
ps1.StartInfo.UseShellExecute = False<br />
ps1.StartInfo.FileName = "cmd.exe"<br />
ps1.Start()<br />
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
In managed code , i send a message to native application :
Dim s As String = "text that i want to send"<br />
Dim GC As GCHandle = GCHandle.Alloc(s)<br />
SendMessage( hwnd , MsgId , wParam , GC )<br />
GC.Free()
In native code , i want to display a message box with text got from above message :
LRESULT WndProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam )<br />
{<br />
MessageBox(hWnd, (LPTSTR)lParam, L"Caption", MB_OKCANCEL | MB_ICONQUESTION | MB_APPLMODAL);<br />
}
But i can not get text with : (LPTSTR)lParam
Please help me to know why this code doesn't work , and how to do it ?
Thank you
|
|
|
|
|
Hi,
within a single process you need to obtain a GCHandle with GCHandleType.Pinned
so the GC can not move the object anymore; then you get the pointer through
GCHandle.AddrOfPinnedObject, and that will be your lParam.
passing strings to another process does not work that way, since the pointer
only means something to the process that owns the string. More code is needed
to allocate, then write, memory in the other process.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thank you , i will try to write "more code"
|
|
|
|
|
Hi, you may want to have a look at my TrayIconBuster article; it has an LP_Process
class that deals with this (it is in C#, same things can be done in VB.NET).
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thank you again
|
|
|
|
|
Hi,
I want to make an encryptation to a string but the result to be places in a textbox.
I tried the cryptostream class but it work only with stream.
thanks
|
|
|
|
|
You should be able to write out the stream to a byte array and then convert the byte array to a string.
Here are some methods I have used, sorry they are in C# They should be easy to re-write in vb.net
public static String MemoryStreamToString(MemoryStream p_ms)
{
return MemoryStreamToString(p_ms, Encoding.Default);
}
public static String MemoryStreamToString(MemoryStream p_ms, Encoding p_encoding)
{
return ByteArrayToString(p_ms.GetBuffer(), p_encoding);
}
public static MemoryStream StringToMemoryStream(String p_string)
{
return StringToMemoryStream(p_string, Encoding.Default);
}
public static MemoryStream StringToMemoryStream(String p_string, Encoding p_encoding)
{
return new MemoryStream(StringToByteArray(p_string, p_encoding));
}
public static Byte[] StringToByteArray(string p_str)
{
return StringToByteArray(p_str, Encoding.Default);
}
public static Byte[] StringToByteArray(string p_str, Encoding p_encoding)
{
return p_encoding.GetBytes(p_str);
}
public static string ByteArrayToString(byte[] p_byteArray)
{
return ByteArrayToString(p_byteArray, Encoding.Default);
}
public static string ByteArrayToString(byte[] p_byteArray, Encoding p_encoding)
{
int numberOfBytes = p_byteArray.Length;
return p_encoding.GetString(p_byteArray, 0, numberOfBytes);
}
Hope that helps.
Ben
|
|
|
|
|
Hello friends.
Please tell me what the job of function (InstrReverse) and function (Instr)with examples.
Thank you so much.
|
|
|
|