SOL9 2.0 Class: FileVersionDialog

 SOL9 C++ Class Library  SOL9 Samples  SOL9 Tutorial  SOL9 FAQ  SOL9 ClassTree 

Source code

/*
 * FileVersionDialog.h 
 * Copyright (c) 2011 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL9
// 2008/12/16


#include <sol\PopupView.h>
#include <sol\ListView.h>
#include <sol\PushButton.h>
#include <sol\MessageFont.h>
#include <sol\FileVersion.h>

#pragma    comment(lib,"version.lib")

namespace SOL {

class FileVersionDialog: public PopupView {

private:
    FileVersion    version;
    ListView    listview;
    PushButton    ok;
    MessageFont mfont;

public:
    FileVersionDialog()
        :PopupView()
    {
    }

public:
    FileVersionDialog(View* parent, const TCHAR* label, Args& args)
    :PopupView(parent, label,        
            args.set(XmNwidth, 520)
                .set(XmNheight, 340)
                .set(XmNstyle, WS_SIZEBOX|WS_THICKFRAME))
    {
        Args ar;
        //2009/09/07
        //ar.set(XmNexStyle, (ulong)WS_EX_CLIENTEDGE);
        ar.set(XmNstyle, (ulong)LVS_REPORT);
        listview.create(this, _T(""), ar);
        
        ar.reset();
        ok.create(this, _T("OK"), ar);
        mfont.create();
    
        ok.setFont(mfont.getFont());
        ok.addCallback(XmNactivateCallback, this,
                    (Callback)&FileVersionDialog::popdown, NULL);
        resize();
        
        showFileInfo();
        addEventHandler(WM_SIZE, this, 
            (Handler)&FileVersionDialog::size, NULL);
    }

public:
    Boolean create(View* parent)
    {
        Boolean rc = False;
        Args args;
        args.set(XmNwidth, 520);
        args.set(XmNheight, 340);
        args.set(XmNstyle, WS_SIZEBOX|WS_THICKFRAME);

        rc = PopupView::create(parent, _T("FileVersion"), args);

        Args ar;
        //2009/09/07
        //ar.set(XmNexStyle, (ulong)WS_EX_CLIENTEDGE);
        ar.set(XmNstyle, (ulong)LVS_REPORT);
        listview.create(this, _T(""), ar);
        
        ar.reset();
        ok.create(this, _T("OK"), ar);
        mfont.create();
    
        ok.setFont(mfont.getFont());
        ok.addCallback(XmNactivateCallback, this,
                    (Callback)&FileVersionDialog::popdown, NULL);
        resize();
        
        showFileInfo();
        addEventHandler(WM_SIZE, this, 
            (Handler)&FileVersionDialog::size, NULL);

        return rc;                    
    }


private:
    void setWindowTitle(const TCHAR* title) {
        if (title) {
            if (strlen(title)>0) {
                TCHAR msg[1024];
                _stprintf_s(msg, SizeOf(msg), _T("%s - FileVersion"), title);
                setText(msg);
            }
        }
    }

private:
    bool showFileInfo()
    {
        bool rc = false;

        listview.clear();
        const TCHAR* labels[] = {_T("Name"), _T("Value")};
        listview.setColumn(labels, 2);

        try {
            int n=0;

            setWindowTitle(version.getProgramName());

            const TCHAR* text[2];
            text[0] = _T("Comments");
            text[1] = (TCHAR*)version.getComments();
            listview.insertLine(n++, text, 2);

            text[0] = _T("CompanyName");
            text[1] = (TCHAR*)version.getCompanyName();
            listview.insertLine(n++, text, 2);

            text[0] = _T("FileDescription");
            text[1] = (TCHAR*)version.getFileDescription();
            listview.insertLine(n++, text, 2);

            text[0] = _T("FileVersion");
            text[1] = (TCHAR*)version.getFileVersion();
            listview.insertLine(n++, text, 2);

            text[0] = _T("InternalName");
            text[1] = (TCHAR*)version.getInternalName();
            listview.insertLine(n++, text, 2);
        
            text[0] = _T("LegalCopyRight");
            text[1] = (TCHAR*)version.getLegalCopyRight();
            listview.insertLine(n++, text, 2);

            text[0] = _T("LegalTrademarks");
            text[1] = (TCHAR*)version.getLegalTrademarks();
            listview.insertLine(n++, text, 2);

            text[0] = _T("OriginalFilename");
            text[1] = (TCHAR*)version.getOriginalFilename();
            listview.insertLine(n++, text, 2);
            
            text[0] = _T("ProductName");
            text[1] = (TCHAR*)version.getProductName();
            listview.insertLine(n++, text, 2);

            text[0] = _T("ProductVersion");
            text[1] = (TCHAR*)version.getProductVersion();
            listview.insertLine(n++, text, 2);

            text[0] = _T("PrivateBuild");
            text[1] = (TCHAR*)version.getPrivateBuild();
            listview.insertLine(n++, text, 2);

            text[0] = _T("SpecialBuild");
            text[1] = (TCHAR*)version.getPrivateBuild();
            listview.insertLine(n++, text, 2);
            rc = true;
        } catch (...) {
            ;//This has no version resource
        }
        return rc;        
    }

private:
    long size(Event& ev) {
        LPARAM lp = ev.getLParam();
        int w = LOWORD(lp);
        int h = HIWORD(lp);
        listview.move(4, 4, w-8, h-44, 1);
        ok.move(w-70, h-40+14, 50, 22, 1);
        return 0;
    }

};

}


Last modified: 1 Feb 2012

Copyright (c) 2009-2012 Antillia.com ALL RIGHTS RESERVED.