sketchucation logo sketchucation
    • 登入
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update

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

    已排程 已置頂 已鎖定 已移動 Developers' Forum
    91 貼文 8 Posters 17.2k 瀏覽 8 Watching
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • thomthomT 離線
      thomthom
      最後由 編輯

      Maybe the .show event of the dialog triggers as it's displayed? But I'm not sure if it wait for the HTML - which you do not want - as that will lag.

      And can you do anything before calling show? You need a handle to the window - how are you getting that at the moment?

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

      1 條回覆 最後回覆 回覆 引用 0
      • J 離線
        Jim
        最後由 編輯

        What does it mean when I get a negative value for a window style? How do I decode it into it's positive representation?

        Hi

        1 條回覆 最後回覆 回覆 引用 0
        • thomthomT 離線
          thomthom
          最後由 編輯

          From GetWindowLong?

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

          1 條回覆 最後回覆 回覆 引用 0
          • J 離線
            Jim
            最後由 編輯

            yeah.

            s = get_style("Ruby Console") -1798569916

            Hi

            1 條回覆 最後回覆 回覆 引用 0
            • thomthomT 離線
              thomthom
              最後由 編輯

              hm....

              Are you receiving the data in the correct data type?

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

              1 條回覆 最後回覆 回覆 引用 0
              • J 離線
                Jim
                最後由 編輯

                Turns out the negative return value is not a problem - I just wasn't using it right.

                Hi

                1 條回覆 最後回覆 回覆 引用 0
                • J 離線
                  Jim
                  最後由 編輯

                  @thomthom said:

                  Maybe the .show event of the dialog triggers as it's displayed? But I'm not sure if it wait for the HTML - which you do not want - as that will lag.

                  And can you do anything before calling show? You need a handle to the window - how are you getting that at the moment?

                  Using FindWindow - which is a basic search by window name and class.

                  Hi

                  1 條回覆 最後回覆 回覆 引用 0
                  • J 離線
                    Jim
                    最後由 編輯

                    For a WebDialog, I couldn't find a handle until it was shown. I used EnumWindows and EnumChildWidows to locate it.

                    But I didn't see a lag when applying the ToolWIndow class immediately after .showing the webdialog.

                    Hi

                    1 條回覆 最後回覆 回覆 引用 0
                    • thomthomT 離線
                      thomthom
                      最後由 編輯

                      Neat! 😄

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

                      1 條回覆 最後回覆 回覆 引用 0
                      • J 離線
                        Jim
                        最後由 編輯

                        The Win32API.so file does not support the use of callbacks needed by EnumWindows and EnumChildWindows. So I have had to move to win32/api.so, which does support callbacks. But this will also allow more interesting things to be done, such as finding resizing Sketchup by its drawing area, and sending values to the Measurements box via a plugin.

                        Hi

                        1 條回覆 最後回覆 回覆 引用 0
                        • thomthomT 離線
                          thomthom
                          最後由 編輯

                          When there is multiple SketchUp windows open - how do you find the one you want?

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

                          1 條回覆 最後回覆 回覆 引用 0
                          • J 離線
                            Jim
                            最後由 編輯

                            Hopefully, the window titles are different. If not, I'm not sure.

                            Hi

                            1 條回覆 最後回覆 回覆 引用 0
                            • thomthomT 離線
                              thomthom
                              最後由 編輯

                              So you look for windows with "<filename> - SketchUp (Pro)"

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

                              1 條回覆 最後回覆 回覆 引用 0
                              • J 離線
                                Jim
                                最後由 編輯

                                Too fast... here's how to get the exact name. (But is_pro? is for windows 7+)

                                
                                def su_window_name
                                    pro = Sketchup.is_pro? ? " Pro" ; ""
                                    if ((title = Sketchup.active_model.title).empty?)
                                        return ("Untitled - SketchUp" + pro)
                                    else
                                        return (title += ".skp - SketchUp" + pro)
                                    end
                                end
                                
                                

                                Hi

                                1 條回覆 最後回覆 回覆 引用 0
                                • thomthomT 離線
                                  thomthom
                                  最後由 編輯

                                  But when there is two untitled windows there could be problems?

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

                                  1 條回覆 最後回覆 回覆 引用 0
                                  • J 離線
                                    Jim
                                    最後由 編輯

                                    Yes, but in that case how would any program know which one the user meant?

                                    You can find all of the matching windows. It's just hard to know which the user meant to use.

                                    Hi

                                    1 條回覆 最後回覆 回覆 引用 0
                                    • thomthomT 離線
                                      thomthom
                                      最後由 編輯

                                      @jim said:

                                      Yes, but in that case how would any program know which one the user meant?

                                      If you'd created the window then you'd get the handle from there. (Would be nice if the API could expose the handles in the Ruby API)

                                      I suppose that if it is possible to get an array of matching windows one could filter out the window you want by checking if one of them is the active - if it's the active SU window you want. (Assuming SU is the currently active window)
                                      Or maybe by Z-Order? Assuming that the top most is the most recent - again if that is what you want...

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

                                      1 條回覆 最後回覆 回覆 引用 0
                                      • thomthomT 離線
                                        thomthom
                                        最後由 編輯

                                        In most cases you'd get the window the user is working on, right?
                                        So how about
                                        GetForegroundWindow - then, in case one of the toolbars or webdialogs are the active window, iterate down the hierarchy using GetParent - checking for matching window title?

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

                                        1 條回覆 最後回覆 回覆 引用 0
                                        • JD HillJ 離線
                                          JD Hill
                                          最後由 編輯

                                          If you have an API which supports EnumWindows, you can use GetProcessId and GetWindowThreadProcessId to filter on windows in the current process.

                                          Developer - Bella Render

                                          1 條回覆 最後回覆 回覆 引用 0
                                          • thomthomT 離線
                                            thomthom
                                            最後由 編輯

                                            @jim said:

                                            But I didn't see a lag when applying the ToolWIndow class immediately after .showing the webdialog.

                                            You got a snippet of how you applied the ToolWindow style?

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

                                            1 條回覆 最後回覆 回覆 引用 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 1 / 5
                                            • 第一個貼文
                                              最後的貼文
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement