CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Confused!

  1. #1
    Guest

    Confused!

    Hi, i am very confused about this, hope some one can clear this up for me.
    I am making a simple game that depend on mouse click, so that is handled by the onButtonUp. The question is when i want to make an option of 1 or 2 players on the main menu, VC gives a simple function without any parameters.
    How am i going to get the similar input as to onButtonUp ( which is the CPoint)

    Thanks.


  2. #2
    Join Date
    Aug 1999
    Location
    UK
    Posts
    17

    Re: Confused!

    Firstly you should try to change the way that you allow different User selection. If your game has maximum of 2 Users then you should use a readonly Combobox as your control otherwise if there are more than 2 users you could use a spin control.
    If you still need to use the Mouse then reply to me and i will guide you. Thanks


  3. #3
    Guest

    Re: Confused!

    Hi Hatim,
    the game is either human and human or human and computer.
    so by clicking on the option (human and human or...), it obviously bring me to a function w/o parameters. These two options i guess is going to be a separate function as for human vs computer, only 1 mouse click is needed to happen (2nd mouse click is generated by the computer).
    I don't know how clear is this, but i can't get my self explain better.
    And i only plan to use the menu.

    Thanks.



  4. #4
    Join Date
    Aug 1999
    Location
    Vic, Australia
    Posts
    11

    Re: Confused!


    void CADialog::OnLButtonUp(UINT nFlags, CPoint point)
    or
    void CAView::OnLButtonUp(UINT nFlags, CPoint point)




    This appears to be the definition of the mouse up event, are you saying yours is


    void CADialog::OnLButtonUp(void)
    or
    void CAView::OnLButtonUp(void)




    If your prototype is the first option, then you can tell what they selected by the value of point.


    CRect rectHumanPlayer(,,,,)
    CRect rectComputerPlayer(,,,,)

    if (rectHumanPlayer.PtIn(point))
    {
    } else
    if (rectComputerPlayer.PtIn(point))
    {
    }




    Is this any help?


  5. #5
    Guest

    Re: Confused!

    Hi, maybe i can put it in this way. How do i find out which option is selected from the menu (which one is being clicked).

    Thanks.


  6. #6
    Join Date
    Aug 1999
    Location
    Vic, Australia
    Posts
    11

    Re: Confused!

    Sorry, I guess I was the one who was confused.

    When u select an option from a menu, windows will post a message to you of the form,

    PostMessage(WM_COMMAND, ID_OPTION_CHOSEN)

    Where ID_OPTION_CHOSEN is the option that the user selected.

    Basically using the ON_COMMAND handler with a line like,

    ON_COMMAND(ID_OPTION_CHOSEN, OnOptionChosen)

    in the message map,
    and create a function like

    void CMyFrame::OnOptionChosen()
    {
    // The option was chosen!!!
    }

    You would have one command handler per option on the menu!

    Does this help?



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

Featured