Results 1 to 7 of 7

Thread: [2.0] Method call wait for user interaction

  1. #1

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    [2.0] Method call wait for user interaction

    In part of my code, seperate to the GUI i need the user to make a choice, ideally by clicking on a choice of (my) usercontrols.

    I noticed that the method for doing a drag-drop operation is like this:

    Code:
    Card_MouseDown(object sender, MouseEventArgs e)
            {
                // Start the dragging process
                DragDropEffects effect = DoDragDrop(sender,DragDropEffects.Copy);
    //handle dragdrop
    }
    The code in handle dragdrop isn't reached until the user has done the necessisary drag, and let go (i.e. DoDragDrop seems to wait for the user interaction).

    Is there some way i could do something similar to this for a method of selecting between my user controls.

    e.g.
    Code:
    Control OneSelectedControl = GetUserSelection();
    Control SecondSelectedControl = GetUserSelection();
    Thanks for any help.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] Method call wait for user interaction

    I don't understand what you mean. Are you saying that you want the user to make multiple selections and you don't want them to be able to do anything else in between? Also, how can a UserControl be separate to the GUI? It sounds to me like you just want a dialgoue box that can't be dismissed until all the required selections have been made.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: [2.0] Method call wait for user interaction

    Thanks for the reply, I'll try and explain a bit better (i was in a hurry when i wrote my first post).


    I'm making a turn-based game involving cards.I've made my own usercontrol to represent a card.

    I've got a 'GameManagement' class which handles all of my game logic.
    In some places, in the GameManagement class' methods i need to user to choose one or more cards 'in play' (on my form) so that the GameManagement can perform various actions.

    I could have a model dialog box, but i don't want to have a seperate selection form appear when it's much more intuitive to get the user to click on the cards as they are layed out on the main form.

    I do want to prevent the user from doing anything but selecting the cards, but i think that shouldn't be a problem if i know how i can get this to work.

    I hope i've explained myself ok, thanks for any further help.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] Method call wait for user interaction

    This sounds like a job for events. You disallow all actions but selecting a card and then you have some event raised when a card is selected. The event handler will then check to see how many cards have been selected and once the required number of selections ahve been made you perfrom the appropriate action. It's an analogous situation to having required fields on a form. You disable the OK button to begin with and the TextChanged event handler of each TextBox checks whether all required fields have been populated. Once they have the OK button is enabled. If a TextBox is then cleared the TextChnaged event handler will disable the OK button again.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: [2.0] Method call wait for user interaction

    Thanks for the help. I think i understand what you're saying, but i'm not sure if it would behave exactly as i want.

    The key thing that i want to be able to do is have this selection be inline. So that i can use the results right there in the code. I want to be able to do something like this, in a metohd in my GameManagement class:

    Code:
    Control OneSelectedControl = GetUserSelection();
    Control SecondSelectedControl = GetUserSelection();
    //Do something with the 2 selected controls
    I'd like GetUserSelection in this example to behave somewhat like the DoDragDrop method does, stopping code execution until the user has done the nesessisary drag with their mouse. The difference in my case being that instead of a drag drop, i want the method to wait for the user to click various controls.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] Method call wait for user interaction

    Control.DoDragDrop internally calls the DoDragDrop function from the ole32.dll system library. It's that function that doesn't return until the drag and drop operation is complete.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: [2.0] Method call wait for user interaction

    Ahh ok, so there's no way of me creating that effect (but with control clicking instead of drag dropping) without me creating a dll in C++ or something then?
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width