Opening a form exactly where I want it
Opening a form exactly where I want it
Opening a form exactly where I want it
Opening a form exactly where I want it
Opening a form exactly where I want it
Opening a form exactly where I want it Opening a form exactly where I want it Opening a form exactly where I want it Opening a form exactly where I want it Opening a form exactly where I want it Opening a form exactly where I want it Opening a form exactly where I want it Opening a form exactly where I want it
Opening a form exactly where I want it Opening a form exactly where I want it
Opening a form exactly where I want it
Go Back  Xtreme Visual Basic Talk > > > Opening a form exactly where I want it


Reply
 
Thread Tools Display Modes
  #1  
Old 01-22-2011, 05:20 PM
MalkyTheDude's Avatar
MalkyTheDude MalkyTheDude is offline
Freshman
 
Join Date: Oct 2010
Location: Philippines
Posts: 26
Default Opening a form exactly where I want it


Hello everyone!


Is there any way to make a form appear exactly where I want it when I click into a form? and is there a way for me to increment the value inside that form? for example, when I click to the north of the form, another form will pop up that will read "Form number 1" and then when I click on the original form another form will popup that will read "Form number 2".

I'm really stumped with this, I have a logic formed tho:
1.) get the coordinates when a mouse clicks into a variable
2.) open the form with the coordinates
3.) that form's variable will get +1 (increment)

....I, I don't know how to do achieve any of this. Thus I turn to thee, O masters of Visual Basic. Thanks in advance!!
__________________
"Nothing Ventured, Nothing Gained!"
Reply With Quote
  #2  
Old 01-23-2011, 06:22 AM
snarfblam's Avatar
snarfblamOpening a form exactly where I want it snarfblam is offline
Senior Contributor

Forum Leader
* Expert *
 
Join Date: Apr 2005
Location: USA
Posts: 896
Default

I'm going to assume you understand how to make forms interact with each other.

For #1, are you looking to detect clicks outside your own form? Since I'm not totally clear on how you want to interact with the mouse, I can't really help too much.

As far as #2, simply set the Form.StartPosition property to FormStartPosition.Manual and then set the Form.Location property to where you would like to start.
Code:
NewForm.StartPosition = FormStartPosition.Manual;
NewForm.Location = (???, ???) ' Place your X, Y coordinates in the parens
On #3, again, I'm not clear on what you're after. What is the variable? Is it something displayed on the form? Is it used by another form for something?

It sounds like you'll probably want to create a property on the target form. You can increment the property, and in the property setter you can add code whatever code you need.
__________________
C# _VB.NET _
Reply With Quote
  #3  
Old 01-24-2011, 01:37 PM
MalkyTheDude's Avatar
MalkyTheDude MalkyTheDude is offline
Freshman
 
Join Date: Oct 2010
Location: Philippines
Posts: 26
Default

Hey snarfblam ^^ thanks for helping me out

for number 1, I need to get the x and y coordinates in a form when I click the mouse on it and be able to get these coordinates.
(for example, when I click on this part of an open form, the result would be saved in
dim coor as integer ). The form would be set to maximized, so I don't have to worry if the user clicks outside the form.

for number 3, I need to be able to display a new form whenever I click on the form and that form has an incrementing value on it. For example, when I click on the form one time, a new form will pop up with the number 1 on it. when I click on the new form again, a new form will pop up with the number 2 on it and so on until it reaches even infinity..... is that possible with vb?

anyway, thanks very much!!
__________________
"Nothing Ventured, Nothing Gained!"
Reply With Quote
  #4  
Old 01-30-2011, 09:02 PM
MalkyTheDude's Avatar
MalkyTheDude MalkyTheDude is offline
Freshman
 
Join Date: Oct 2010
Location: Philippines
Posts: 26
Default

Hi everyone!
just bumping the thread, hoping that anyone could help me...
__________________
"Nothing Ventured, Nothing Gained!"
Reply With Quote
  #5  
Old 01-31-2011, 04:42 PM
snarfblam's Avatar
snarfblamOpening a form exactly where I want it snarfblam is offline
Senior Contributor

Forum Leader
* Expert *
 
Join Date: Apr 2005
Location: USA
Posts: 896
Default

Quote:
Originally Posted by MalkyTheDude View Post
for number 1, I need to get the x and y coordinates in a form when I click the mouse on it and be able to get these coordinates.
This seems pretty straightforward. What have you tried, or where did you get stuck?

Quote:
Originally Posted by MalkyTheDude View Post
for number 3, I need to be able to display a new form whenever I click on the form and that form has an incrementing value on it.
Again, where are you stuck? Do you not know how to keep track of the number of clicks? Or how to create the forms? I'm guessing it's the latter, but I wouldn't go about explaining how to do so if I don't even know if that's the issue.

Please understand that a good question should never need a bump. I'm not saying you aren't making a fair effort with your program, but when you don't explain what you've tried and you aren't specific about what you're stuck on or what you don't understand it gives people the impression that you're not trying. That, and it's harder for somebody to help you when he's not sure exactly what you need help with. The more thought you put into a question, the more likely it is you'll get help.
__________________
C# _VB.NET _
Reply With Quote
  #6  
Old 01-31-2011, 09:31 PM
MalkyTheDude's Avatar
MalkyTheDude MalkyTheDude is offline
Freshman
 
Join Date: Oct 2010
Location: Philippines
Posts: 26
Default

Hi!
For number 1, I made a form with two labels on it, named xpoint and ypoint. I wanted that whenever I clcik on the form, the x value of the coordinates of where the mouse point was clicked will be put on the xpoint.text and the same goes for the y value to the ypoint.text too

I actually get that you have to put a code on the click event of the form so that when you click on the form the fucntion starts, but what I don't know is to how to actually achieve this. Is there a .getmousecoordinate code?

For number 3, what I want to achieve is that whenever I click on the form, a new form will pop up saying that "You have opened a new form! this is Form number:" then the number of the form (in this case, it should be 1 since it's the first form we opened).

Whenever the user clicks on the previous form (the form with the code) a new form will pop up with the same text as the other previously opened form ("You have opened..") only that it now says "This is form number 2 (or 3 or 4, depending on the number of the previous form opened"

my real trouble here is that I don't know how to create forms at runtime... I'm sorry bout that, but I'm doing my best to learn anyways. To be honest, with my current ability with vb.net 2010, I am only able to show and hide a form created with the gui

BTW thanks for putting up with me, snarfblam!
__________________
"Nothing Ventured, Nothing Gained!"
Reply With Quote
  #7  
Old 02-01-2011, 09:26 PM
snarfblam's Avatar
snarfblamOpening a form exactly where I want it snarfblam is offline
Senior Contributor

Forum Leader
* Expert *
 
Join Date: Apr 2005
Location: USA
Posts: 896
Default

You really need to be able to use the tools you have to solve problems. The first place you can look with a question like this is right in the IDE. The designer gives you a list of events, and the code window has Intellisense, which lists classes, properties, and functions.

If you look through the form's properties (I know, there are a lot) you'll come across the MousePosition property. This gives you the mouse position in screen coordinates. OR, if you looked at all the form's events, you would see the MouseDown event. Among other information, the MouseDown event gives you the client coordinates (relative to the control) the mouse was clicked at.

As far as #3, if I had to guess, I'd say there is probably a tutorial that covers this here, but I'm not positive. I can give a quick rundown.

First you'll want to add a new form to your project. For reference, I'll refer to it as NumberForm. Place a label on it that will contain your text, or whichever controls you would like.

You want to give it a public function that can set the text. Your main form will call this function after it creates the NumberForm. It should look something like this:
Code:
Public Sub SetIndex(Index As Integer)
    Me.SomeLabel.Text = "Clicked this many times: " & Index.ToString()
End Sub
Then, whenever you want, you can create an instance of your NumberForm.
Code:
' In the main form
Dim newNumberForm As New NumberForm
newNumberForm.SetIndex(clickCountVariable)
newNumberForm.Show()
__________________
C# _VB.NET _
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Opening a form exactly where I want it
Opening a form exactly where I want it
Opening a form exactly where I want it Opening a form exactly where I want it
Opening a form exactly where I want it
Opening a form exactly where I want it
Opening a form exactly where I want it Opening a form exactly where I want it Opening a form exactly where I want it Opening a form exactly where I want it Opening a form exactly where I want it Opening a form exactly where I want it Opening a form exactly where I want it
Opening a form exactly where I want it
Opening a form exactly where I want it
 
Opening a form exactly where I want it
Opening a form exactly where I want it
 
-->