Announcement

Collapse
No announcement yet.

XP Theme enabling..

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • XP Theme enabling..

    Why is it so? If to XP Theme enable a program, COMMCTRL.INC has to be
    included, else the program won't start. Weird, so I boiled it down to
    the ImageList_AddIcon function and since it's just a wrapper for the
    ImageList_ReplaceIcon call, it means both those two are needed. IOW,
    instead of including the entire COMMCTRL.INC, one can just include
    FUNCTION ImageList_AddIcon and the declare for ImageList_ReplaceIcon.

    Ok, but why at all? My code is not calling any of them, and I found no
    info about them being necessary at MSDN. Somehow, the XP Theme engine
    must be doing some really weird stunt with ImageList_AddIcon there ..


    ------------------
    PowerBASIC Staff
    ------------------
    Private web-site: http://www.tolkenxp.com/pb
    Free downloads: POFFS, incLean, PBcodec, custom controls and PB samples.

  • #2

    From what you describe (error message? maybe some import from missing from "COMMCTRL.DLL"?), seems you could make program run simply by doing an InitCommonControlsEx with the appropriate flags for icons.

    If your program is not calling ImageList_xxx, your program does not need "COMMCTRL.INC". Must be one of those built-in functions in COMMCTRL.INC which is causing COMMCTRL.DLL to be added to the import table.

    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Nope, it does not have anything to do with initializing - it's that
      exact function, ImageList_AddIcon. Had to step through COMMCTRL.INC
      and rem out block by block to find it. And since ImageList_AddIcon
      is just a wrapper for ImageList_ReplaceIcon, both the function and
      the declare for ImageList_ReplaceIcon is needed. It's very stange.


      ------------------
      PowerBASIC Staff
      ------------------
      Private web-site: http://www.tolkenxp.com/pb
      Free downloads: POFFS, incLean, PBcodec, custom controls and PB samples.

      Comment


      • #4
        Ok, my mistake, sort of. You are right, Michael - declaring and calling
        InitCommonControls is enough too. Must be because the ImageList_AddIcon
        function is a wrapper for ImageList_ReplaceIcon that initialization
        happens if those two are included instead.

        IOW, forget it - declaring and calling InitCommonControls alone at
        program start is enough for XP Theme's app's to start ok.


        ------------------
        PowerBASIC Staff
        ------------------
        Private web-site: http://www.tolkenxp.com/pb
        Free downloads: POFFS, incLean, PBcodec, custom controls and PB samples.

        Comment


        • #5
          Yep, that's right Borje. I had a rude awakening once when a themed app I was writing failed to show the main window. This was in the old days when I used to develop software in Win98, thankfully no more...

          ------------------
          email
          http://www.kgpsoftware.com
          kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

          Comment


          • #6
            I found that out a long time ago and even posted it somewhere.

            I noticed it needed image functions when using the declares to disable
            certain common controls to cut down on included code and was getting errors when
            disabling the Image APIs with the declare.

            ------------------
            If you aim at nothing...you will hit it.
            sigpic
            Mobile Solutions
            Sys Analyst and Development

            Comment


            • #7
              Call me naive, but ...

              If WIndows/XP is smart enough to know it is going to be doing a 'themed' application...

              Shouldn't it be smart enough to know to load the common controls DLL to the address space of said process?

              Or does it load it, but is not smart enough to initialize it for whatever it needs to "do" themes?

              (FWIW, I have no clue what makes an application "themed")

              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                I think it can be done in several ways, but the way I just did it
                is - in a resource file, add:
                Code:
                1 24 "xptheme.xml"
                In the code (as I just have learned), either include CommCtrl.inc or
                add the declare for InitCommonControls and call it at startup. Then
                save the following as xptheme.xml in same folder. Note that name and
                version under assemblyIdentity should be name and version of the program,
                so for a program called "MyProg.exe" version 1.0 it could look like:
                Code:
                <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
                <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
                <assemblyIdentity
                    name="MyProg.exe"
                    processorArchitecture="x86"
                    version="1.0.0.0"
                    type="win32"/>
                <description>Windows Shell</description>
                <dependency>
                    <dependentAssembly>
                        <assemblyIdentity
                            type="win32"
                            name="Microsoft.Windows.Common-Controls"
                            version="6.0.0.0"
                            processorArchitecture="x86"
                            publicKeyToken="6595b64144ccf1df"
                            language="*"
                        />
                    </dependentAssembly>
                </dependency>
                </assembly>
                Compile and stir carefully, and you have made yourself a modern-looking
                XP Theme-enabled PB program with fancy buttons, etc, when Theme is enabled.
                No external files necessary to include in delivery, since xptheme.xml
                (can probably be any name) is baked into it via the resource file. Those
                values, 1 24, are MS equates CREATEPROCESS_MANIFEST_RESOURCE_ID
                and RT_MANIFEST, but I use the values direct instead of having to define
                them. There's an example in the file download section here by Bob Plymale
                called Theme.zip (thank you, Bob), and more info can be found at MSDN.

                PS, "Windows XP" and "smart" in same sentence? It's still basically Win 3.1,
                or even DOS, but in a fancier and more complicated costume..

                ------------------
                PowerBASIC Staff
                ------------------
                Private web-site: http://www.tolkenxp.com/pb
                Free downloads: POFFS, incLean, PBcodec, custom controls and PB samples.

                [This message has been edited by Borje Hagsten (edited April 21, 2005).]

                Comment


                • #9
                  Yup, that is all that is required for themes unless you use Tab
                  Controls. Especially if they have icons. Bgrounds of the icons
                  don't paint transparent, and sometimes are larger than tab. Color
                  of the tab panel is also white instead of ButtonFace. And Image
                  buttons...along with RRbuttons aren't Themed. I found some code
                  to add to your RRbutton to theme it, but never got around to adding
                  it yet.

                  ------------------
                  If you aim at nothing...you will hit it.

                  [This message has been edited by Roger Garstang (edited April 21, 2005).]
                  sigpic
                  Mobile Solutions
                  Sys Analyst and Development

                  Comment


                  • #10
                    publicKeyToken="6595b64144ccf1df"
                    Of course, Cut'n'Paste would have saved me 2 hours of grief!
                    There are no l's { ells - you know, lower case L, chr$(108)} here.

                    ------------------

                    Comment


                    • #11
                      >there are no l's { ells - you know, lower case l, chr$(108)} here

                      actually, in resource scripts "l" is used..

                      Code:
                      myresname   myrestype
                      begin
                         123l,    // force to 32-bit instead of default 16-bit
                         "happy days\0"
                      end
                      this would be the 'user-defined resource' way to store a pb udt like...
                      Code:
                      type myrestype
                       a   as long
                       b   as asciiz * %max_myrestype_text_len
                      end type
                      more on user-defined resources here:
                      user-defined resource demo january 26 2003

                      Michael Mattias
                      Tal Systems (retired)
                      Port Washington WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment


                      • #12
                        i think it can be done in several ways, but the way i just did it
                        is - in a resource file, add:
                        Code:
                        1 24 "xptheme.xml"
                        seems to me you could just 'inline' that xml script, if avoiding the use of yet another physical file ("xptheme.xml") would be desireable..

                        Code:
                        // myprog.rc
                        // ....
                        //   theme definition  ///
                        1 24 
                        begin
                        <?xml version="1.0" encoding="utf-8" standalone="yes"?>,
                        <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestversion="1.0">,
                        <assemblyidentity,
                         name="myprog.exe",
                        ...
                        
                        end
                        i'm not sure if you need the newline characters (i'm not that familiar with xml), but you could insert those easily enough.

                        of course, if you don't mind "yet another physical file" then it's no big deal. me, i really do not like needing a zillion physical files to make up a 'source code package' and if i already need the "*.rc" file, well, this way would be one less file to lose/corrupt/accidentally erase, etc.

                        reference: user-defined resource demo january 26 2003

                        [later]
                        or, you could use mr. durham's recently posted code at http://www.powerbasic.com/support/pb...ad.php?t=24569 if you just want to keep the 'theme' info in your 'regular' source code...
                        [/later]

                        golly, i like having all these options!

                        mcm



                        [this message has been edited by michael mattias (edited april 26, 2005).]
                        Michael Mattias
                        Tal Systems (retired)
                        Port Washington WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          Thanks, Borje, that works a treat. I also looked at Bob Plymale's example in the download section, but does anyone have a method for dealing with the tab control and image button problem?

                          I have an image button that I sometimes need to blank by removing the image. At that moment the button changes from square-cornered to round - not very elegant!

                          Comment


                          • #14
                            You will have to manually theme the button or any control.

                            Give me your email and I will email you an example of manually theming.

                            Bob

                            ------------------

                            Comment


                            • #15
                              Many thanks for that offer, Bob. My email address is:
                              simon.morgan <at> buchanancomputing.co.uk

                              Comment


                              • #16
                                Why not post that in the source forum?

                                ------------------
                                http://www.hellobasic.com
                                PwrDev - Visual Designer for pb/dll, pb/win, pb/cc
                                PwrStat - Static library linker for pb/dll or pb/win.
                                hellobasic

                                Comment


                                • #17
                                  Bob

                                  I would also like to know how to manually theme a button or control

                                  Thanks

                                  ------------------
                                  Trento Castricone
                                  http://www.raineyday.com
                                  mailto:[email protected][email protected]</A>
                                  Trento Castricone
                                  www.fileraptor.com
                                  [email protected]

                                  Comment


                                  • #18
                                    I also.

                                    Comment


                                    • #19
                                      Well, I am looking for my code now. I did that over a year ago.
                                      I did send it to several people, just do not remember who. But if they see
                                      this email can they please send me the code and I will post it to the forum.

                                      If I cannot find the code or no one sends me a copy I will redo it next weekend and
                                      post.

                                      Bob

                                      bob at plymale dot us

                                      ------------------

                                      Comment

                                      Working...
                                      X