|
nickong wrote:
i am looking for other way to implement this.
Easy - put a scroll bar on the screen and use it's position in your OnPaint. Then Invalidate the screen in your event handler for scroll events.
nickong wrote:
can u post some sample code to implement "UNDO" here,i need some reference. both C++ or C# are welcome, best in VB.NET, thanks a lot.
Not really, sorry. All of my undo/redo code is under NDAs. But the basic idea is either for each draw event to first copy the current image into an array using Clone, or for drawing lines to be encapsulated into a class which you can make an array of.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
thank you anyway, i'll try to do that follow the basic idea.
thank you,
nick kong
|
|
|
|
|
See my other comments, I didn't realise you wanted to undo any line by clicking on it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I did something like this before, without the selection of a line to remove it. I wish I had the code, but I lost it when I had a hard drive crash (back up every week now )
I used GetChildAtPoint for some of the info. I also used an array of bitmaps, however it was for icon info (never did get it to make actual ico files instead of png files), so it was fast and didn't use too much resources. You could probably still pull it off, but might have to do some playing. I would be interested to see if there is a hittest or something for a drawn line...please let me know back. Other wise you would probably want to write the routine to check if it is a hit in its own thread and you would need to give a little distance for ease of click...be hard if it had to be a certain pixel).
Good Luck
|
|
|
|
|
I think what you are looking for is the GraphicsPath object from GDI+. I just recently had to use this and read up on it but I am by no means an expert with it. I did however throw together a quick example in a couple min. to show you how you can use this to draw lines, select them, and then get rid of them. A quick disclaimer first: Being that i did this quick at work, the collection of GraphicsPath objects continously grows... the current implementation never gets rid of the objects, just resets their points to basically have them draw nothing. This should definitely be changed. For additional information, read up on GraphicsPath on MSDN.
<br />
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown<br />
Dim oGP As GraphicsPath<br />
<br />
' Loop through the collection of lines to see if we clicked on one.<br />
For Each oGP In LineCollection<br />
' The following IF returns true if the line was clicked on, the trigonometry is done for you :)<br />
If oGP.IsOutlineVisible(e.X, e.Y, New Pen(Color.Black)) Then<br />
oGP.Reset() ' Should remove the line from the collection or do something different here!<br />
Me.Invalidate()<br />
Exit Sub<br />
End If<br />
Next<br />
<br />
Drawing = True<br />
GP = New GraphicsPath ' Create a new GP object to hold the line. <br />
pt1 = New Point(e.X, e.Y) ' Set the start point of the line.<br />
LineCollection.Add(GP) ' Add this graphics path object to the collection<br />
End Sub<br />
<br />
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp<br />
Drawing = False ' Not drawing a line anymore<br />
End Sub<br />
<br />
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove<br />
If Drawing = True Then<br />
GP.Reset() ' Clear the current graphics path object.<br />
GP.AddLine(pt1.X, pt1.Y, e.X, e.Y) ' Add the line<br />
Me.Invalidate() ' Force paint<br />
End If<br />
<br />
End Sub<br />
You'll have to make sure you declare LineCollection As a New System.Collections.ArrayList somewhere as well as GP as a GraphicsPath and pt1 as a Point.
Hope this helps. Should let you draw lines on the form and then to "erase" them, just click on them.
|
|
|
|
|
Have to tuck this away for the next time I am messing with GDI+. Thanks T-Smooth.
|
|
|
|
|
Just wondering if Recordset still exist in VB.Net or is there a better method now. I am thinking about .Movefirst, MoveNext etc. How can you add a record to a DataSet Fill and can you assign an array to a dataset.fill?
|
|
|
|
|
Recordset is no longer. I don't use datasets to much, but if I remember right you make a new datarow and add it to the dataset with the newrow function.
|
|
|
|
|
How to i create a nice document for printing in vb .net? I would like to take some info from a DB and then print a nice looking document (with header, footer, page numbers, and so on).
How do i do this?
r
johan
|
|
|
|
|
Use Crystal Reports. A version of it comes with Visual Studio .NET (not the academic version.)
Crystal Reports: Getting Started[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have build an application an after building the application i have cahnged a part of the application.
Now i want to update the application.
One solution is that i rebuild the entire project again which is easy. But
what if i have given that application to a client?
Then how would i apply an update to my product. like downloading the patch and applying it to the application, rather then downloading the entire application.
Can any one guide on how to build an application which can be updateable by applying patches.
I've been trying it my self to find a way but so far've been unlucky
|
|
|
|
|
Dear Friends,
Please help me how to do web scraping using MS Inet control in visual basic. Actually I am doing work on a project that require web scraping (Programmatically Put Parameters on a web and Get Result that will be stored in a excel comma separated file.). The website developed in cold fusion having extension (.cmf). So, any body having complete idea with an example about web scraping using vb/vb.net then kindly immediate response me.
Note: Please one thing keep in mind I have also great problem to fully read contents of cold fusion file (.cmf) using Ms Inet OpenUrl Method. Please answer me fully appropriate and satisfied.
Special Thanks.
Shahzad Ahmad
Please only reply on this address.
Email: ShahzadAhmad_Bs@Yahoo.com
|
|
|
|
|
Shahzad Ahmad wrote:
Please only reply on this address.
Email: ShahzadAhmad_Bs@Yahoo.com
Sorry, no one is going to answer you by email. If you ask a question in the forums, the answers stay in the forums for other people to read.
Posting the same question, day after day, will not get you an answer either. If your question wasn't answered the first time, chances are no-one has any appropriate experience with what your asking.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How about if you give it a shot (you're the one being paid, right?) and then ask specific questions about what you're struggling with rather than asking for a "fully appropriate and satisfied" answer.
|
|
|
|
|
Dear all,
How can i create dial-up Connection(means i neec to give the parameters through code) and connect that connect through vb.net
|
|
|
|
|
check out InternetDial function of wininet.dll. I haven't found exact usage, but I am needing to do this also.
|
|
|
|
|
Hi,
i am trying to delete a file
If csvFile.Exists(csvFilePath) Then
csvFile.Delete(csvFilePath)
End If
its giving me error
file used by another process
do u have a code who delete file forcefully and close all process
Please help!
Thanks
Ashu Sharma
|
|
|
|
|
If the file is open by another process, it's impossible to delete it.
Closing all other processes is out of the question, since you have no idea which process has the file open. There is no method to determine which process has it either.
Closing processes willy-nilly will only get your application uninstalled and the first available opportunity. It's just horrible programming practice.
If your application has the file open, well, the solution is obvious...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
To replace/delete files after rebooting you need to create a file named wininit.ini in the Windows directory
Then enter the following for example:
<br />
[Rename]<br />
c:\windows\system\myoldsys.dll=c:\mynewsys.dll<br />
to delete the file you would enter:
NUL=c:\windows\system\myoldsys.dll
So we see that the format is "newname=oldname"
You need to use always the shortfilename for this to work longfilenames do not work at all.
|
|
|
|
|
hi forum
i have a question to ask,
i want to store the folders, its subfolders etc etc.. blah blah in a
database table and i want to display those folders it child etc..
in the form of tree structure. if the user changes the name of the folder
then suitably the values has to be changed in the database also and automatically assign its child, silbling folders or whatever to this new folder name.
how difficult is it? someone please give me some idea
i have strarting trouble
|
|
|
|
|
Each node needs a unique ID and needs to also store it's parent node ID, with NULL or a magic number for the top node. Then the tree is easily built. And the name should NEVER be used as a key, the ID stays the same, and if you change the name, everything else just works.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
thank you very much Mr. Graus for your support
ShreejaRajan
|
|
|
|
|
How to integrate two forms using Tab Control in Vb.NET forms ?
|
|
|
|
|
Turn them into controls, and put one control on each tab.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
In the following code:
-------------------------------------
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click, MenuItem2.Click, MenuItem3.Click
.....
End Sub
--------------------------------------
How to determine which menuItem is clicked?
Thanks.
|
|
|
|