|
You can find out more about the technique here[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Dave,
I had actually already looked at this, but i was not able to make it work properly.
Also that example seems overly complex, using channels and what not.
My main problem was that i ran into the same problem as i do now, which is when im trying to get the information via the WM_COPYDATA message i get an exception about memory address.
|
|
|
|
|
Ok i can see i had made some mistakes in my code. the structure passed has to be a certain type. I've changed this to
'VB6
Private Type COPYDATASTRUCT
dwData As Long ' ID for this msg
cbData As Long ' number of bytes
lpData As Long ' address of data
End Type
'VB.Net
<System.Runtime.InteropServices.StructLayoutSystem.Runtime.InteropServices.LayoutKind.Sequential)> _
Private Structure COPYDATASTRUCT
Public dwData As IntPtr
Public cbData As Integer
Public lpData As Integer
End Structure
My code when sending the message from VB6 is now:
Dim s As String
s = "hello"
Dim cds As COPYDATASTRUCT
cds.dwData = 1
cds.cbData = LenB(s)
cds.lpData = StrPtr(s)
Call SendMessage(hwndTarget, WM_COPYDATA, 0, cds)
and my code when handling the message in .NET is still abit uncertain
i can get some of the string but i also get some garbage along with it.
Dim cds As COPYDATASTRUCT = New COPYDATASTRUCT()
cds = Marshal.PtrToStructure(m.LParam, cds.GetType())
Dim s As String = Marshal.PtrToStringUni(cds.lpData, cds.cbData)
when running this code s becomes:
"hello聎鏆矔鎅矔"
anyone know why?
-- modified at 4:47 Monday 28th August, 2006
|
|
|
|
|
hmmm
If i divide the value
cds.cbData
by 2, i get the string i want each time.
I dont know why exactly, and would really love an explanation.
|
|
|
|
|
VB6 stores all of it's strings in Unicode format (2 bytes per char), otherwise known as BSTR. When the string is marshalled to Managed Code, it's converted to a normal single byte format.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I have a pretty advanced search page with a datagrid under all kinds of search criterias...
Now I was thinking of putting each section of the search criterias in tree nodes; making a tree with only one level, so that users can hide/show panels and the grid itself by clicking a + to expand and - to hide (a panel)
So it would be something like:
+ filters
+ text search
+ advanced search
+ select fields to show
- [grid]
...
...
Now I don't know if it's even possible to put so large parts of html code in tree nodes...
So I'm asking here if anyone has a better idea? Or if it's even possible?
Please give your opinion.. (or tips on how to make such a tree)
-- modified at 9:10 Thursday 24th August, 2006
|
|
|
|
|
Anyone?
|
|
|
|
|
Can anyone tell me the syntax for displaying a image in the rich text box with some text.
i am using vb.net 2003 windows application
Thanks
Manish
|
|
|
|
|
hello!!
when i drag the crystalreport viewer in my vb.net application it gets the following error
the.net aseembly "crystalDecisions.windows.form" could not be found
how can i resolve this problem????
|
|
|
|
|
Hello everyone.. how do you launch a MSWORD document in VB.NET, by code? Like if i want to open VB.doc. When I use the shell command, and then specify its path.. it will juz say 'File Not Found!'. It only launches executables.. I can't actually open the MSWORD file..
Can anyone help me out with this? Thanks in advance..
|
|
|
|
|
Process.Start(pathToDocFile)
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
Iam doing a project related to access control system.In this i have a click event where i have to launch an external application(for example application name FPM.exe).This is in the server in the network.My project is in the client machine.Now i have to launch this exe file on a click event, and when we close this fpm application we should be back in our project.How can i do this.If i can use shell command, then can anyone give me the exact syntax.?
Is it necessary to specify the path of this FPM.exe.is it possible for a coding which will search and find in the network for this file(rather than specifying the path) and launch that in my project.
Iam using vb.net (win based)
Hoping a help.
Thanks regards,
chepps
|
|
|
|
|
Funny, two questions iwth the same answer
Process.Start(filePath)
chepps wrote: Is it necessary to specify the path of this FPM.exe
Of course. Otherwise a typo would result in code that searched the entire hard drive
chepps wrote: is it possible for a coding which will search and find in the network for this file
You would have to write the code to do that seperately.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thank you Christian Graus
Regards,
Chepps
|
|
|
|
|
I am using VS2003, VB.NET, Windows2000+.
Is it possible?
Thank you.
|
|
|
|
|
If you're talking about limiting the usage of the CPU by your app, then globally no, it isn't possible. But, you can change the Priority[^] of any threads your app launches simply by giving it a new ThreadPriorty value.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I have an application using .NET framework 1.1
Is it ask user to install if they don't have install .NET framework?
Please tell me if there is the way, Thank you.
|
|
|
|
|
Your installer should simply have it as a dependency. What installer do you use ? If they just copy an exe, it just plain won't run, there's nothing you can do about that.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I am fairly new to VB and I am stuck. I am not sure this is the best way to do this but what I am attempting to do is this.
I have a text file that has a lot of lines. I have the text file loaded into a variable "TextFileContent" and also the text properities of a text box "TextBox1" (Which is not visible). I am trying to search for a line in the variable "TextFileContent" and/or textbox "TextBox1" properities and change it to what the user has entered into another textbox "TextBox2". I need to search line by line and cannot figure out how to do this in a textbox or a variable or if it is even possible.
In that text file the first line is "StartLocation: Home".
The 2nd line is "EndLocation: Beach".
In "TextBox2" they will see the lines above ^ in the " ".
When they click the button "Change" I want it to grab the first line in "TextBox2" and search "TextBox1" or the variable "TextFileContent" and to change the line from what it is in "TextBox1" or the variable "TextFileContent"
to the line in "TextBox2". Then loop to the next line and repeat until it reaches the last line.
I am trying to do this in VB.
Any help is appreaciated.
Thanks.
-- modified at 5:34 Thursday 24th August, 2006
|
|
|
|
|
Use the replace function in VB. It will replace all occurances of a string within a string.
Example:
test = "This is a test"
testing = Replace(test, "is", "is not")
testing now equals: "This is not a test"
Mike Lasseter
|
|
|
|
|
Maybe I need to explain with better details.
I have a text document with about 200 lines.
for example here are some of the lines.
First Name: John
Last Name: Doe
State: CA
City: Hollywood
First Name: Jane
Last Name: Doe
State: GA
City: Atlanta
Now I have a load button and when I click the button this a open file dialog opens up and I select the file. Then it loops through and grabs the first and last names and puts them into a a drop down box. Then I select a certain person it it loop through until it finds that person and then will fill in the rest of the fields.
Like if I select John Doe in the drop down it will fill in the State textbox and the rest I have for that person. What I want to be able to do is if I click a save button it will search for the person and then reweite the line under neath that person.
From what I understand I should load the entire text file into a variable then search the variable line by line and change the text in the variable then write the entire variable back to the text document. I have no idea how to search the variable line by line so I tried to do thin in a hidden textbox and cant figure out how to search the textbox line by line.
I know how to do everything except search a variable ot textbox line by line. I know how to search a text file line by line and I am pretty sure it doesnt work the same for a textbox or variable.
If this makes no sense or you dont understand plase let me know.
|
|
|
|
|
I think I would do this a little different. Instead of using a variable I would create a People class that contained (first, last, state, city). I would parse the file into an array or collection of People. Doing this allows you to search through the list of people very easily.
Hope this helps.
Mike Lasseter
|
|
|
|
|
I'm not at very skilled VB programmer and quite new to Visual Studio 2005. I'm trying from an ordinary batch-script on windows to call a VB program, which - depending on the parameters - should set one environment variable.
I have managed to create the program, and I can see either through registry or through "Environment Variables" in "System properties", that my variable is created and set in either the user or machine environment. But in the command shell (cmd.exe) window I still have no access to the new environment variable.
I imagine the problem is that when launching the cmd.exe you take a kind of snapshot of the environment and works with this "copy".
But how can I refresh the environment so the variable is visible and the new value also?
Rgds.
Preben
|
|
|
|
|
Your looking for the Environment class and it's SetEnvironmentVariable method. Make sure that you pass EnvironmentVariableTarget.Machine for the third parameter and the system should get updated with the new variable. You can then launch a new CMD prompt to check if it worked.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Dave.
Thanks for your reply, but it is exactly what I did. And it is true that you can see, and access the variable, when a new cmd.exe is spawned from as ex. "Run" in the start menu.
But if you call your program from the current cmd.exe shell, you can not see, nor access the variable from this shell, since it seems that you are in some kind of "static" environment, which is not renewed when the program is run.
Rgds,
Preben
|
|
|
|