Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Zeblar Nagrim

Alternatives for void pointers

This topic is 5982 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Please take a look at this code:
  

...

enum ControlType
{
 BUTTON=0,
 CHECK_BUTTON,
 RADIO_BUTTON,
 LABEL,
 SCROLLBAR,
 TEXTBOX,
 LISTBOX,
 COMBOBOX
};

...

LRESULT CGUI::MessageProc(int Message, WPARAM wParam, LPARAM lParam)
{
  static void* l_ptCtrlInFocus=NULL;
  static ControlType l_eCtrlInFocusType;

  ...

  CGUIListbox* pListBox = FindListbox(l_tMousePos);
  if(pListBox != NULL)
  {
    l_ptCtrlInFocus = pListBox;
    l_eCtrlInFocusType = LISTBOX;
  }

  ...

  CGUITextbox* pTextBox = FindTextbox(l_tMousePos);
  if(pTextBox != NULL)
  {
    l_ptCtrlInFocus = pTextBox;
    l_eCtrlInFocusType = TEXTBOX;
  }

  ...

  switch(LOWORD(wParam))
  {

    ...

    case VK_UP:
    {
       if(l_ptCtrlInFocus != NULL)
       {
          switch(l_eCtrlInFocusType)
          {

          ...

          case LISTBOX:
             CGUIListbox* pListBox = (CGUIListbox*) l_ptCtrlInFocus;
             pListBox->OnKeyDown(LOWORD(wParam)); 
             break;

          ...

          case TEXTBOX:
             CGUITextbox* pTextBox = (CGUITextbox*) l_ptCtrlInFocus;
             pTextBox->OnKeyDown(LOWORD(wParam)); 
             break;
          ...
          }
       }
    }

   ...

  }

 ...
}

  
This code is ugly. I want to use a diffrent method. Something more OO. Any idea? Zeblar Nagrim, Lord of Chaos

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
this may clean up your code a bit...

((CGUIListbox*)l_ptCtrlInFocus)->OnKeyDown(LOWORD(wParam));

Share this post


Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!