sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [code] Win32 Moving/Showing/Hiding Toolbars and Dialogs

    Scheduled Pinned Locked Moved Developers' Forum
    91 Posts 8 Posters 15.9k Views 8 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      Jim
      last edited by

      Thanks for following (and cleaning) up the example. Will some this be getting into TT_Lib at some point?

      Hi

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        @jim said:

        Will some this be getting into TT_Lib at some point?

        TT_Lib2, yes.

        I already got a wrapper to create toolwindows.

        <span class="syntaxdefault"><br />&nbsp;&nbsp;&nbsp;&nbsp;def&nbsp;show_toolbar<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options&nbsp;</span><span class="syntaxkeyword">=&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;</span><span class="syntaxdefault">title&nbsp;</span><span class="syntaxkeyword">=>&nbsp;</span><span class="syntaxstring">'Bezier&nbsp;Surface'</span><span class="syntaxkeyword">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;</span><span class="syntaxdefault">pref_key&nbsp;</span><span class="syntaxkeyword">=>&nbsp;</span><span class="syntaxstring">"#{TT;;Plugins;;BPatch;;ID}_Toolbar"</span><span class="syntaxkeyword">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;</span><span class="syntaxdefault">width&nbsp;</span><span class="syntaxkeyword">=>&nbsp;</span><span class="syntaxdefault">128</span><span class="syntaxkeyword">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;</span><span class="syntaxdefault">height&nbsp;</span><span class="syntaxkeyword">=>&nbsp;</span><span class="syntaxdefault">52</span><span class="syntaxkeyword">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;</span><span class="syntaxdefault">resizable&nbsp;</span><span class="syntaxkeyword">=>&nbsp;</span><span class="syntaxdefault">false</span><span class="syntaxkeyword">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;</span><span class="syntaxdefault">scrollable&nbsp;</span><span class="syntaxkeyword">=>&nbsp;</span><span class="syntaxdefault">false<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxkeyword">}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@</span><span class="syntaxdefault">toolbar&nbsp;</span><span class="syntaxkeyword">||=&nbsp;</span><span class="syntaxdefault">TT</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">GUI</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">ToolWindow</span><span class="syntaxkeyword">.new(&nbsp;</span><span class="syntaxdefault">options&nbsp;</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@</span><span class="syntaxdefault">toolbar</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">show_window<br />&nbsp;&nbsp;&nbsp;&nbsp;end<br /></span>
        

        (Extract from a work in progress project.)

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          Wonder if one can hook into windows like this under OSX...

          Thomas Thomassen β€” SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jim
            last edited by

            @pout said:

            What are possible advantages of using toolwindows instead of webdialogs?
            And is the communication between SU and the toolwindow still done in the same way?

            For some windows, if it is a Toolwindow it will not show up in the Alt-Tab list. But this is normal for SketchUp dialog windows anyway, so there should be no difference there.

            Hi

            1 Reply Last reply Reply Quote 0
            • J Offline
              Jim
              last edited by

              @thomthom said:

              I some times experience that the window automatically closes after a few seconds. it has happened only sporadically...)

              It's just getting GC'd. window is a local variable referencing the WebDialog, and the variable no longer exists after the method exits. Since the WebDialog no longer has any references, it is GC'd.

              @thomthom said:

              Can GWL_STYLE and GWL_EXSTYLE changes be combines into one call?

              Maybe - the "styles" are just bits but at different offset (one is -16, the other -20). If you meant is there a win32api function for setting both simultaneously then I don't know.

              Hehe, the php highlighter work OK on Ruby. πŸ‘

              Hi

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                @jim said:

                It's just getting GC'd. window is a local variable referencing the WebDialog, and the variable no longer exists after the method exits. Since the WebDialog no longer has any references, it is GC'd.

                Oh... that's a gotcha I didn't think of. You need to keep a reference to the WD for the duration of its lifespan.

                @jim said:

                Maybe - the "styles" are just bits but at different offset (one is -16, the other -20). If you meant is there a win32api function for setting both simultaneously then I don't know.

                The thing is - today, I don't really see any lag... πŸ˜• πŸ˜’

                What's nice about having toolwindows is that now I can make my custom toolbar. πŸ˜„

                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  Just came across a nice API call that will be useful for creating webdialog toolbars:
                  http://social.msdn.microsoft.com/forums/en/csharpgeneral/thread/e7fef568-2c0b-41eb-9785-304f84d03819/#bf79c87e-ef49-456f-a485-aa767d841d20

                  One can use WS_EX_NOACTIVATE to prevent a window from catching focus - but from what I understand it'll still allow interaction events. I'll try it out as soon as I get home.

                  Thomas Thomassen β€” SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    hm....

                    @unknownuser said:

                    The WS_EX_NOACTIVATE value for dwExStyle prevents foreground activation by the system. To prevent queue activation when the user clicks on the window, you must process the WM_MOUSEACTIVATE message appropriately. To bring the window to the foreground or to activate it programmatically, use SetForegroundWindow or SetActiveWindow. Returning FALSE to WM_NCACTIVATE prevents the window from losing queue activation. However, the return value is ignored at activation time.

                    http://msdn.microsoft.com/en-us/library/ms632680%28v=vs.85%29.aspx

                    "queue activation"?

                    Thomas Thomassen β€” SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      bleh... turns out to not be so straight forwards as I though. Seems that one needs to handle some window messages:
                      http://www.allquests.com/question/132471/Ws-ex-noactivate.html
                      http://stackoverflow.com/questions/2969680/c-showing-form-with-ws-ex-noactivate-flag

                      But working out how to handle window messages would be a very interesting thing - as then we could recreate the roll-up/down feature of SU's toolwindows.

                      Thomas Thomassen β€” SketchUp Monkey & Coding addict
                      List of my plugins and link to the CookieWare fund

                      1 Reply Last reply Reply Quote 0
                      • honoluludesktopH Offline
                        honoluludesktop
                        last edited by

                        tt, most of this discussion is "over my head", but will the result permit toolbars to unfold perpendicular to the edge of a sketchup window like the menus do? If so please provide a simple version that we can use to compact our application toolbars.

                        1 Reply Last reply Reply Quote 0
                        • thomthomT Offline
                          thomthom
                          last edited by

                          It doesn't modify existing toolbars. I'm simply modifying the appearance of webdialogs.

                          @honoluludesktop said:

                          but will the result permit toolbars to unfold perpendicular to the edge of a sketchup window like the menus do?

                          You mean toolbars where you click on a button and it displays a dropdown list of more buttons?

                          Thomas Thomassen β€” SketchUp Monkey & Coding addict
                          List of my plugins and link to the CookieWare fund

                          1 Reply Last reply Reply Quote 0
                          • honoluludesktopH Offline
                            honoluludesktop
                            last edited by

                            Yes, Would go a long way to cleaning up our screens.

                            1 Reply Last reply Reply Quote 0
                            • thomthomT Offline
                              thomthom
                              last edited by

                              Interesting though - but I'm not sure if it's possible. In either case - if you start making all toolbars like that they end up having the same problem as menus - that everything is hidden in sub-menus and you need an extra operation to reveal it - to be able to explore available commands. I feel the usability would not be improved.

                              If one has that many toolbars open I'd rather ask if they are all required to be there on screen.

                              Personally I assign hotkeys to the most frequent commands I use. Then I have a few toolbars for semi-frequent command. For everything else I use the menus.

                              I have been toying with the idea of having a webdialog which allows you to filter out the commands you want - and make sets of tools you can switch between depending on the job.

                              Thomas Thomassen β€” SketchUp Monkey & Coding addict
                              List of my plugins and link to the CookieWare fund

                              1 Reply Last reply Reply Quote 0
                              • honoluludesktopH Offline
                                honoluludesktop
                                last edited by

                                @thomthom said:

                                ...........if you start making all toolbars like that they end up having the same problem as menus - that everything is hidden in sub-menus and you need an extra operation to reveal it - to be able to explore available commands. I feel the usability would not be improved.
                                .........

                                You are probably right about this.

                                1 Reply Last reply Reply Quote 0
                                • thomthomT Offline
                                  thomthom
                                  last edited by

                                  I do have an experimental hack to catch all menus, commands and toolbar items that's created. I hope to tind time soon to put together a basic version of a plugin that let you quickly search and filter out available commands.

                                  Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                  List of my plugins and link to the CookieWare fund

                                  1 Reply Last reply Reply Quote 0
                                  • Dan RathbunD Offline
                                    Dan Rathbun
                                    last edited by

                                    @thomthom said:

                                    @honoluludesktop said:

                                    but will the result permit toolbars to unfold perpendicular to the edge of a sketchup window like the menus do?

                                    You mean toolbars where you click on a button and it displays a dropdown list of more buttons?

                                    These are called "Flyout Toolbars" and have been a part of the AutoCAD GUI since at least R13 (circa 1994) and perhaps even R12 in Win16 mode.

                                    This is one of the things on my to do list for Win32 Sketchup.

                                    I'm not here much anymore.

                                    1 Reply Last reply Reply Quote 0
                                    • thomthomT Offline
                                      thomthom
                                      last edited by

                                      @thomthom said:

                                      Just came across a nice API call that will be useful for creating webdialog toolbars:
                                      http://social.msdn.microsoft.com/forums/en/csharpgeneral/thread/e7fef568-2c0b-41eb-9785-304f84d03819/#bf79c87e-ef49-456f-a485-aa767d841d20

                                      One can use WS_EX_NOACTIVATE to prevent a window from catching focus - but from what I understand it'll still allow interaction events. I'll try it out as soon as I get home.

                                      Just had a go at this. I could not get a webdialog to not get any focus when I set WS_EX_NOACTIVATE - but I could make a Notepad window to change. I don't understand why.
                                      When I check the EX_STYLES of the webdialog the WS_EX_NOACTIVATE bits appear to be set.

                                      ❓ ❓

                                      Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                      List of my plugins and link to the CookieWare fund

                                      1 Reply Last reply Reply Quote 0
                                      • Dan RathbunD Offline
                                        Dan Rathbun
                                        last edited by

                                        WebDialogs are child windows of the SU app window.

                                        The Notepad window is a toplevel window.

                                        I'm not here much anymore.

                                        1 Reply Last reply Reply Quote 0
                                        • thomthomT Offline
                                          thomthom
                                          last edited by

                                          Does that matter?
                                          Floating toolbars are also child of the SU window...

                                          Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                          List of my plugins and link to the CookieWare fund

                                          1 Reply Last reply Reply Quote 0
                                          • thomthomT Offline
                                            thomthom
                                            last edited by

                                            Sidenote: Win32 - Get SketchUp Window Handle

                                            Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                            List of my plugins and link to the CookieWare fund

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 3 / 5
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement