window doesn't exist in constructor

Help
2004-11-17
2013-04-15
  • Steven Weiss

    Steven Weiss - 2004-11-17

    hi,
    i created a dialog and want to pass the dialog to a functor. because i didn't find a function which converts the dialog to a wnd<> i took a look to get_active_wnd() and found out that it's implemented with find_by_hwnd(). ergo i tried this code:

    AbfrageDlg::AbfrageDlg()
    {           
       for_each( theDocument().begin(), theDocument().end(), boost::bind(&AbfrageDlgImpl::InsertCharakterPair, find_by_hwnd(raw_hwnd()), _1) );
    }

    but an exception will be thrown in get_window_anythread()

    saying that the window doesn't exist...but you promised the window still exists in the constructor ;-). i guess the registration of the window to the global list of all windows is somehow broken???

    btw is there any function which gets a wnd<> from actual window classes? and if not, it would be nice to have one =)

    mfg steven

     
    • John Torjo

      John Torjo - 2004-11-17

      The window exists, only that find_by_wnd won't find it yet - because it's not fully constructed (that is, you're inside its constructor)

      Instead of find_by_wnd(raw_hwnd()), use '*this'

      Best,
      John

      Note: I will look into your other posts as well - somewhere (hopefully) this week.

       
    • John Torjo

      John Torjo - 2004-11-17

      "btw is there any function which gets a wnd<> from actual window classes? and
      if not, it would be nice to have one =)"

      Not sure what you mean. Please give an example. Thanks.

      Best,
      John

       
    • Steven Weiss

      Steven Weiss - 2004-11-17

      the reason i wrote the code above is that *this didn't work...

      for_each( theDocument().begin(), theDocument().end(), boost::bind(&AbfrageDlgImpl::InsertCharakterPair, *this, _1) );

      this code didn't compile. the InsertCharakterPair() is declared like this:

      struct AbfrageDlgImpl
      {
      static void InsertCharakterPair(wnd<> dlg, const CharakterzugPair& charakterZugPair);
      }

      so i had to find a way to get a wnd<> from my dialog and the find_by_wnd() seemed to be the solution. i use v1.5.1

       
      • John Torjo

        John Torjo - 2004-11-17

        Two workarounds:

        - You can do this in your event hander's on_full_create() function (see link below)
        (in this case, you know your dialog class is fully cosntructed, and this is what I recommend)
        - in InsertCharakterPair function, make dlg a window_base* pointer:

        void InsertCharakterPair(YourDlgClass* dlg,...)

        (http://www.torjo.com/win32gui/doc/event_handling.html#event_handler_creation)

        Best,
        John

         
        • Steven Weiss

          Steven Weiss - 2004-11-17

          thank you, that's it!

          greetz steven

           

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks