|
I want to import a VB 6.0 interface in my VC++ 6.0 program for my image thinning project. How to do so and how to link the interface objects with the coding? Can anybody provide me the source code or howto?
My VB form consists of a menu toolbar, command button,a picture box and a text box. I want to open a 50x50 TIFF image file using the menu item File->Open File and displays the image in the picture box. How to get the file name from the interface and load the image onto the interface?
Then I need to click the command button to convert the image to binary image(0 for white and 1 for black).(I have the coding for binary conversion but I don't know how to link them with the command button and accessing the image in the picture box.
Later, i need to display the binary image that I saved in a binary file in the text box in the interface. How to read and write a file through the interface? How to display the content of the file being read?
thank you very much
-- modified at 22:16 Monday 5th September, 2005
|
|
|
|
|
The way to do this is to write your C++ project using COM or managed C++ ( depending on what VB version you're using as much as anything ), and then call the C++ code from your VB UI. VB6 apps have been written like that for years - VB is good for hacking to gether a basic UI, and C++ is good at doing actual work.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thank you for replying. It's a relief to know that VB 6.0 have the capabilities. Actually, I'm a newbie in this programming. Would you kindly guide me throught the whole process?
Currently, I'm coding my C++ program using VC++ 6.0 and my program consists of 2 files: main.cpp and lib.h. Can you please give me some easy examples or sample source code on how to call the C++ code(main.cpp and lib.h)from the VB 6.0 interface? Eg.the Hello World application?
BTW, what is COM or managed C++?;)
TQ
|
|
|
|
|
ladyscarlet99 wrote:
It's a relief to know that VB 6.0 have the capabilities.
OK, this is the first you specified VB6. That limits your options, but does not close them.
ladyscarlet99 wrote:
Currently, I'm coding my C++ program using VC++ 6.0 and my program consists of 2 files: main.cpp and lib.h.
OK, that sounds like a pretty basic console app, it doesn't even use standard headers. What's lib.h ? Why isn't there a main.h ? In any case, it's useless to you, although any code you wrote can be ported easy enough.
ladyscarlet99 wrote:
BTW, what is COM or managed C++?
VB6 is a dead language. As of 2002, Microsoft released VB.NET, which along with C# ( a new language at that time ) target a new runtime called the Common Language Runtime. If you had VS2002, 2003 or 2005, you could write C++ to target this runtime, and it would be really easy to call from VB.NET. This is called Managed C++.
COM is a lot more complex, but basically if you create an ATL project in VC++ ( I assume VC6 ? ), then you'll be creating a dll which can be called from VB6. COM is a huge subject, truthfully, I had three cracks at it before I got it enough to start using it. But in hindsight, it's not as complex as it seemed, but it is very different from a normal C++ app ( although, it IS a C++ app, and you can use any C++ you can use elsewhere, it's just working out how the framework sits together ). This[^] is the book that finally got it all together for me, I recommend it 100%. COM is just too hard to learn without a good book, all the more if you're more skilled in VB than c++.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
how can i Synchronise time using domainupdown control?time will change if domainupdown buttons are clicked.
Thanks for guidance.
|
|
|
|
|
What is a "domainupdown" control and what does it have to do with time?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yeah, I couldn't work out what was going on here.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yeah, that one made me go "domainupwhatdownwhowherewubbitcontrol"? It had me scratching my head so much, it made my bald spot bigger...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi All:
I would like to share data between two Windows forms in this manner:
- Form 1 browses for the name of a text file, stores the name in a string variable (strTextFile), and calls Form 2 with the Form2.Show() command
- Form 2 has one button to display this text file in a text window called txtDocument.Text using My.Computer.FileSystem.ReadAllText(strTextFile), and two others to do Printer Setup and Print, respectively
My question is: how do I pass the name of the text file from Form 1 to Form 2? I am new to VB.NET, so please bear with me.
Thanks.
DERECK R. PRINCE
President
Roraima Technologies, Inc.
"Customizing Technology for ALL Your Business Needs!"
Saint Louis, Missouri, USA
Phone: 1-314-569-9035
|
|
|
|
|
roraima wrote:
My question is: how do I pass the name of the text file from Form 1 to Form 2? I am new to VB.NET, so please bear with me.
The most obvious way, if Form2 can do nothing without this string, is for Form2 to take a string in it's constructor, so you can't create a Form2 instance without passing this string in. Otherwise, you can make the string a property on Form2, and pass it in before calling Show().
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Whoa!!! Thanks for that, Christian, but I am afraid you are a little over my head with that reply! How about a code sample to illustrate what you mean?
And sorry for the bother; I am new at this.
DERECK R. PRINCE
President
Roraima Technologies, Inc.
"Customizing Technology for ALL Your Business Needs!"
Saint Louis, Missouri, USA
Phone: 1-314-569-9035
|
|
|
|
|
OK - I'll try. I really don't use VB.NET, I kind of think it sucks
Public Class Class1
' A private variable to store the string
Private _path As String
' This is apparently how you add a constructor to VB.NET
Public Sub New(ByVal path As String)
Me._path = path
' You probably don't need to store the string, you could just read the file, and store it's contents.
End Sub
Private Sub New()
End Sub
End Class
That's from a project I just whipped up - the constructor is the method that is called when you create a new object. So when you create a new Class1, in this instance, you need to pass it a string. However, the default constructor ( which takes no arguments and does nothing ) is still available, so I define it to be private ( which means no-one can call it, forcing the one that takes the string to be called ). Once you have the string, you can use it to read the file whenever you like. I am sort of anticipating that question, the link below is to an article on reading text files in VB.NET.
http://www.freevbcode.com/ShowCode.asp?ID=4492[^]
The other way is to have a property, like this:
Public WriteOnly Property Path()
Set(ByVal Value)
_path = Value
' You would also read the text file here, probably
End Set
End Property
Now, you can do myForm.Path = "thepath" before calling the Show method.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks, Christian. I'll go try this and see how I go.
DERECK R. PRINCE
President
Roraima Technologies, Inc.
"Customizing Technology for ALL Your Business Needs!"
Saint Louis, Missouri, USA
Phone: 1-314-569-9035
|
|
|
|
|
Hello!
I have another, perhaps more simpler solution to this question of sharing data between two forms...
First declare a public (global) variable in form 2......
Public Str as String <---
now create an object of form 2 in form 1
Like......
Dim Frm2 as new Form2
Frm2.Str.Text=strTextFile.Text
Frm2.Show()
now the value of strTextFile would be in str and you can access it in you function....
_mubashir
|
|
|
|
|
You have another way to accomplish what you are asking for
As a Form it´s a class itself you can create a property (a method) that GETS o RETURNS any variable you need... for example
<br />
'In this case, the form is called Calculator, this is "form2"<br />
Public Class Calculator<br />
Inherits System.Windows.Forms.Form<br />
<br />
Dim _myTextBox As TextBox<br />
<br />
Public Property GetSetTextBox() As TextBox<br />
Get<br />
Return Me._myTextBox<br />
End Get<br />
Set(ByVal Value As TextBox)<br />
Me._myTextBox = Value<br />
End Set<br />
End Property<br />
<br />
'... the rest of the code<br />
And From form1 (the form who calls the second one)
<br />
Dim Form2 as New Form2<br />
Form2.GetSetTextBox = TextBox1 'Any textbox in the form<br />
In this way you can return a variable or a reference to a full control, have fun
PD: Sorry about my english... is not very good
|
|
|
|
|
My suggestion is to have a shared variable between the 2 forms. That way, if you modify the variable from one form, it keeps the value of the variable when you access it from form2.
So for example:
you can specify a variable str in form1 this way
Public Class Form1
Public shared str as string
...
end class
you can access the variable form either form1 or form2.
to modify it form form1, simply use this way
str = txtDocument.text
to access or modify from form2, use this way
form1.str = "Another Text"
or you can also use it in you textbox.
My.Computer.FileSystem.ReadAllText(Form1.str)
Hope this helps
Good luck
|
|
|
|
|
Hi All:
Thank you all for your patience in assisting me with this little project. The Property reply did the trick, and I am happily continuing on my VB programming way! You guys are the best!
DERECK R. PRINCE
President
Roraima Technologies, Inc.
"Customizing Technology for ALL Your Business Needs!"
Saint Louis, Missouri, USA
Phone: 1-314-569-9035
|
|
|
|
|
How to make Intelligent datagrid like yahoo messenger address tab. When we type any word first letter like
In Datagrid Column name is Name it has different name like
Muhammad Waqas Butt
Muhammad Sheraz Butt
Saad Butt
Aarij Butt
So when we type M then it show and select the record and then type u it show only record which are starting from M and second word u.
Any Idea? In C#.Net or VB.Net
|Muhamad Waqas Butt|
waqasb4all@yahoo.com
www.sktech.freewebspace.com
|
|
|
|
|
If you would have a textbox for each column where you enter the string which should be searched for, i would suggest you to use the textchanged event of that textboxes. you could go through each row of the dataset which is stores the information and check if the specific column contains the string which you're searching for and if it does, copy that row to a second dataset which is binded to the datagrid. although it would work, its a bad idea, since you would have to use two datagrids or something like this to store the original informations, and the ones which should be shown. you also would have to go through the whole table everytime someone writes something. thats not a problem if you're using a small datagrid, but if it gets larger, you will get performance problems...
just some suggestions because nobody answered yet, no good ones though :/
good luck,
mik
|
|
|
|
|
I am building a VB.Net Windows application. I would like to allow the user to click a button which will open their default mail client, insert the subject, body, and emaill addresses, and then attach one or more files. The user would then be able to change any of the information and send their their email client.
I've seen several posts that suggest using the "mailto:" command with ShellExecute seems to be the easiest wayto go, however this does not seem to support attachments. I've also seen several posts that suggest using MAPI to accomplish this, but those all seem to be VB6 (It doesn't seem to be available out of the box with VB.net).
There is also functionality that I could use for Outlook specifically, however I want to keep this fairly generic so that other email clients could be used as well.
I would greatly appreciate any suggestions.
|
|
|
|
|
I'm trying to figure out how to select an an item in in a listview at runtime
e.g. searching a listview (in detail view) for a specific item and highlighting it
I've tried:
listview.items(i).selected = true
where i is the index of the item i want to select - the item is added to the listviewselecteditems collection, but it does not highlight. Do I need to refresh the control after selecting it, or is some extra handling in the paint event needed?
Dave
|
|
|
|
|
Ha!
Just managed to answer my own question -
remember to add:
listview.items(i).selected = true
listview.select()
many thanks to Jason Heine for his article...
My new motto: think twice, speak once
Dave
|
|
|
|
|
Hi
I tried to get some printer-informations by using a wmi-query. It works fine until a printer goes offline. It takes very long to get those informations then.
What do i want it to do?
- It should be much faster to get the printer-informations (about 3 secs, no matter whether a printer is offline or not)
OR
- It should run the application.doevents() command at least every second. (to provide a progressbar which is worth to be called a PROGRESSbar
What did i already try to do?
- Optimize the WMI-Query (which was a bit successful at least)
- Set a seperate Timer which runs the application.doevents() command (for the possibility of a progressbar, which shows that the computer doesn't hang around)
The Query-optimization increased the speed by 1-2 seconds. but it still took too long to get the printer-informations.
The timer freezes if the specific line of code is executed (if all printers are online its about 3secs, if only one of the printers is offline, it takes up to 15 secs and more), so that's not the solution, too.
All together: very unsuccessful
I will show you some example code, so you may rebuild the problem, if you're interested in
Declaration/Definition of variables:
<br />
Private Printer As System.Management.ManagementObject<br />
Private PrinterSelect As New Management.SelectQuery("SELECT Name, PrinterStatus, DriverName, PortName, Comment, Local, Network, Default FROM Win32_Printer")<br />
Private PrinterSummary As New Management.ManagementObjectSearcher(PrinterSelect)<br />
Private PrinterCollection As Management.ManagementObjectCollection<br />
executing code:
<br />
PrinterCollection = PrinterSummary.Get()<br />
'Application.DoEvents()<br />
For Each Printer In PrinterCollection<br />
{...}<br />
Next Printer<br />
PrinterCollection = Nothing<br />
everytime the third line of executing code ("For Each Printer in PrinterCollection") being executed, the computer starts to hang.
please tell me, if you need more informations about the problem.
i would be thankful and pleased for every constructive response
so far,
mik
|
|
|
|
|
|
Great. It works fine. Now i'm able to make the progressbar be a real progressbar which shows continously progress thanks a lot, wouldn't have get that by myself.
here's some example code how it could look like:
declaretion/definition:
Private Printer As System.Management.ManagementObject
Private PrinterSelect As New Management.SelectQuery("SELECT Name, PrinterStatus, DriverName, PortName, Comment, Local, Network, Default FROM Win32_Printer")
Private PrinterSummary As New Management.ManagementObjectSearcher(PrinterSelect)
Private PrinterCollection As Management.ManagementObjectCollection
Private observer As New Management.ManagementOperationObserver
Private completionHandler As New WMICompletionHandler
executing code:
PrinterCollection = Nothing
PrinterSummary.Get(observer)
PrinterCollection = PrinterSummary.Get()
While Not (completionHandler.IsComplete)
Application.DoEvents()
System.Threading.Thread.Sleep(500)
End While
For Each Printer In PrinterCollection
{...}
next printer
... it redraws the progressbar while executing the wmi query, too.
you need to add the completionhandler class, shown on that msdn page.
thanks again
|
|
|
|
|