Migrate from GitHub to SourceForge with this tool. Check out all of SourceForge's recent improvements.

Status bar - tips and manipulators

  • stevejay

    stevejay - 2005-05-26


    I'm trying to get to grips with Win32GUI at the moment.  I have a little project where I've created a multi-pane status bar, with an icon in the first pane.  I'm trying to get a tooltip displaying just for that icon, plus have the status bar being shown and hidden using set_cmd_checker to link it to a menu item.  I can get one or the other of these two behaviours occuring successfully, but not at the same time.  If I do that, i get an assertion ("deleted_before") when quitting my little program.

    Because I am creating a multi-pane status bar, I decided to derive from the status_bar class.  It's very possible that this is at the root of the trouble, but I do like the idea of keeping the code for a more complex status bar separate from the frame class.

    The program is available zipped from here: http://www.stevejay.net/win32gui_problems_statusbar3.zip

    (If you want to know I'm trying to do the above, it's simply because I think I should be able to :-)

    The biggest issue I am facing at the moment is that I don't know where to do stuff.  Sometimes you can do something in the window's constructor, in the window's handler on_full_create function or in WinMain.  For example, if I was adding a simple status bar to a simple frame.  In the frame's constructor, I could say:


    Or in the on_full_create function in the frame's event handler class, I could say:


    Or in WinMain, after the creation of the frame instance there (with "top" being the indirect pointer to it), I could say:

    wnd<status_bar> sb = create_wnd<status_bar>(top);

    I know that the Win32GUI documentation says:
    "If you need to do custom initialization, while you can do it in your event handler constructor, I highly recommend you simplly override the on_full_create() function and do it there."

    But what exactly is meant by "custom initialisation"?  All initialisation?  If not, what bits?

    (You might be able to tell: I'm drowning here.  It's one step forward, two steps back :-( 


    • Steven Weiss

      Steven Weiss - 2005-05-26

      i have no idea about your problem and unfortunately no time to look at it...but i can help you on your other questions.

      ok, let's go:
      you should indeed do your initialization in on_full_create() because then you can be sure that everything is initialized correct - the window object and it's event handler. but of course there are some exceptions: if the constructor of your window class takes an argument you will want to process it (for example, assign to a member variable).

      my advice for WinMain() is: only do as few as possible there - most time i only load some options from registry or ini-files and show the frame window. the rest is done in the frame-window class. this is good abstraction since WinMain() should not know whether the window has a status bar, menu or such things

    • stevejay

      stevejay - 2005-05-27

      Hi Steven,

      Thanks for the reply! :-)

      I suppose my confusion stems partly from what I see in the example projects that come with the Win32GUI library.  As an example of what I mean, consider the tooltips project that's found in the following location in the Win32GUI root folder: 'examples/controls/tooltips.'

      In the contructor for the sample_dlg class, there's a bunch of initialisation statements going on, to do with tip text and adding tooltip controls:
      sample_dlg::sample_dlg() {
          tip_text(ID_remember, &sample_dlg::remember_str);
          tip_text(ID_me, &sample_dlg::pos_as_str);

          // days of the week
          add_tip_ctrl( create_wnd<tooltip_ctrl>(this,create_info().add_style(TTS_BALLOON)), "days");
          tip_ctrl(ID_mon, "days");
          tip_ctrl(ID_tue, "days");
          tip_ctrl(ID_wed, "days");
          tip_ctrl(ID_thu, "days");
          tip_ctrl(ID_fri, "days");
          tip_ctrl(ID_sat, "days");
          tip_ctrl(ID_sun, "days");
          tip_text(ID_sun, sunday);

          // "Turn off" checkbox
          wnd<tooltip_ctrl> turn_off = create_wnd<tooltip_ctrl>(this,create_info().add_style(TTS_BALLOON));
          turn_off->bg_color( color().blue(255) );
          turn_off->text_color( color(255,255,255) );
          add_tip_ctrl(turn_off, "off");
          tip_ctrl(ID_turn_off, "off");

      Should that code/could that code be in the on_full_create function in the sample_dlg_handler event handler class for the sample _dlg class?

      BTW I'm using version 1.6.5 of Win32GUI, and I notice that you've very helpfully added a FAQ section to the documentation.  I'm just wondering about the "How can I get the return value of modal dialogs?" question.  If I try doing as the code example shows, it doesn't work; I have to add ".result" on the end of the dialog create line, so that the example in the FAQ would read:

      signal ret = create_modal_dlg<some_other_dlg> (null_wnd).wait(wait_for::ok_pushed || wait_for::cancel_pushed || wait_for::destroy).result;
      if (ret == wait_for::ok_pushed) {
              // ...

      Is there something I'm doing wrong to need this addition?


    • Steven Weiss

      Steven Weiss - 2005-05-27

      you're right, i for myself would also put the code into on_full_create() ;-).

      the faq was written at 1.6.2 - and at that time the code was right. i'll update it, thus thank you that you mentioned it!

    • stevejay

      stevejay - 2005-05-27

      Hi again,

      Okay, now I'm happy :-)


    • stevejay

      stevejay - 2005-05-29

      Hi again,

      Just to let ya know - I sorted out getting tooltips and a command manipulator for the status bar.  (I was doing things slightly the wrong way around.)  I also stuck a progress control on the status bar.  Ahh, such fun :-)


      • Steven Weiss

        Steven Weiss - 2005-05-29

        yeah, the longer you do something with win32gui the more you'll love it ;-). especially if you've worked with mfc before hehe

        mfg steven


Log in to post a comment.