Changeset 797 in dev for branches/egtra


Ignore:
Timestamp:
Feb 1, 2011, 11:13:15 PM (14 years ago)
Author:
イグトランス (egtra)
Message:

プロパティシート周りを9x対応させた

Location:
branches/egtra/ab5.0/abdev
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/egtra/ab5.0/abdev/abdev-impl/Resource/Load.cpp

    r795 r797  
    3535}
    3636
    37 void* GetResource(HINSTANCE hinst, USHORT id, LPCTSTR type)
     37HICON LoadIconCursorImpl(HINSTANCE hinst, USHORT id, int cxDesired, int cyDesired, UINT load, bool isIcon)
     38{
     39    auto pResource = LoadResourceAlt(hinst, id, isIcon ? RT_GROUP_ICON : RT_GROUP_CURSOR);
     40
     41    auto idIcon = LookupIconIdFromDirectoryEx(reinterpret_cast<PBYTE>(pResource), isIcon, cxDesired, cyDesired, load);
     42    auto icon = LoadResourceAltWithSize(hinst, numeric_cast<USHORT>(idIcon), isIcon ? RT_ICON : RT_CURSOR);
     43
     44    return CreateIconFromResourceEx(reinterpret_cast<PBYTE>(icon.first),
     45        icon.second, isIcon, 0x00030000, cxDesired, cyDesired, load);
     46}
     47
     48} // unnamed namespace
     49
     50void* LoadResourceAlt(HINSTANCE hinst, USHORT id, LPCTSTR type)
    3851{
    3952    if (auto hrsrc = ::FindResource(hinst, MAKEINTRESOURCE(id), type))
     
    4760}
    4861
    49 std::pair<void*, DWORD> GetResourceWithSize(HINSTANCE hinst, USHORT id, LPCTSTR type)
     62std::pair<void*, DWORD> LoadResourceAltWithSize(HINSTANCE hinst, USHORT id, LPCTSTR type)
    5063{
    5164    typedef std::pair<void*, DWORD> result_type;
     
    6477    return result_type(nullptr, 0);
    6578}
    66 
    67 HICON LoadIconCursorImpl(HINSTANCE hinst, USHORT id, int cxDesired, int cyDesired, UINT load, bool isIcon)
    68 {
    69     auto pResource = GetResource(hinst, id, isIcon ? RT_GROUP_ICON : RT_GROUP_CURSOR);
    70 
    71     auto idIcon = LookupIconIdFromDirectoryEx(reinterpret_cast<PBYTE>(pResource), isIcon, cxDesired, cyDesired, load);
    72     auto icon = GetResourceWithSize(hinst, numeric_cast<USHORT>(idIcon), isIcon ? RT_ICON : RT_CURSOR);
    73 
    74     return CreateIconFromResourceEx(reinterpret_cast<PBYTE>(icon.first),
    75         icon.second, isIcon, 0x00030000, cxDesired, cyDesired, load);
    76 }
    77 
    78 } // unnamed namespace
    7979
    8080HICON LoadIconAlt(HINSTANCE hinst, USHORT id, int cxDesired, int cyDesired, UINT load)
     
    152152    using namespace boost::adaptors;
    153153
    154     auto accel = GetResourceWithSize(hinst, id, RT_ACCELERATOR);
     154    auto accel = LoadResourceAltWithSize(hinst, id, RT_ACCELERATOR);
    155155    if (accel.first == nullptr)
    156156    {
     
    173173HMENU LoadMenuAlt(HINSTANCE hinst, USHORT id)
    174174{
    175     return LoadMenuIndirect(GetResource(hinst, id, RT_MENU));
     175    return LoadMenuIndirect(LoadResourceAlt(hinst, id, RT_MENU));
    176176}
    177177
    178178INT_PTR DialogBoxAlt(HINSTANCE hinst, USHORT id, HWND hwndParent, DLGPROC dialogFunc, LPARAM initParam)
    179179{
    180     auto dlgTemplate = static_cast<DLGTEMPLATE*>(GetResource(hinst, id, RT_DIALOG));
     180    auto dlgTemplate = static_cast<DLGTEMPLATE*>(LoadResourceAlt(hinst, id, RT_DIALOG));
    181181    return ::DialogBoxIndirectParam(hinst, dlgTemplate, hwndParent, dialogFunc, initParam);
    182182}
     
    184184HWND CreateDialogAlt(HINSTANCE hinst, USHORT id, HWND hwndParent, DLGPROC dialogFunc, LPARAM initParam)
    185185{
    186     auto dlgTemplate = static_cast<DLGTEMPLATE*>(GetResource(hinst, id, RT_DIALOG));
     186    auto dlgTemplate = static_cast<DLGTEMPLATE*>(LoadResourceAlt(hinst, id, RT_DIALOG));
    187187    return ::CreateDialogIndirectParam(hinst, dlgTemplate, hwndParent, dialogFunc, initParam);
    188188}
     
    191191{
    192192    WTL::CDC dc = ::GetDC(nullptr);
    193     auto pbi = static_cast<BITMAPINFO const*>(GetResource(hinst, id, RT_BITMAP));
     193    auto pbi = static_cast<BITMAPINFO const*>(LoadResourceAlt(hinst, id, RT_BITMAP));
    194194    return CreateDIBitmap(dc, &pbi->bmiHeader, CBM_INIT, reinterpret_cast<BYTE const*>(pbi) + pbi->bmiHeader.biSize, pbi, DIB_RGB_COLORS);
    195195}
  • branches/egtra/ab5.0/abdev/abdev-impl/Resource/Load.h

    r795 r797  
    11#pragma once
    22
     3#include <utility>
    34#include <memory>
    45#include <windows.h>
     
    67
    78namespace ActiveBasic { namespace Resource {
     9
     10void* LoadResourceAlt(HINSTANCE hinst, USHORT id, LPCTSTR type);
     11std::pair<void*, DWORD> LoadResourceAltWithSize(HINSTANCE hinst, USHORT id, LPCTSTR type);
    812
    913HICON LoadIconAlt(HINSTANCE hinst, USHORT id, int cxDesired, int cyDesired, UINT load = 0);
  • branches/egtra/ab5.0/abdev/abdev/DialogBoxes.cpp

    r793 r797  
    502502void DlgNewProjectWizard(HWND hwnd){
    503503#define MAX_NEWPROJECTPAGE 3
    504     PROPSHEETHEADER psh;
    505     PROPSHEETPAGE psp;
    506     HPROPSHEETPAGE hpsp[MAX_NEWPROJECTPAGE];
     504    PROPSHEETHEADER psh = {};
     505    PROPSHEETPAGE psp = {};
     506    HPROPSHEETPAGE hpsp[MAX_NEWPROJECTPAGE] = {};
    507507    int i;
    508508
    509     psp.dwSize=sizeof(PROPSHEETPAGE);
    510     psp.hInstance=hResInst;
    511     psp.dwFlags=PSP_DEFAULT;
     509    psp.dwSize = sizeof(PROPSHEETPAGE);
     510    psp.hInstance = GetWindowInstance(hwnd);
     511    psp.dwFlags = PSP_DLGINDIRECT;
    512512
    513513    //各ページのセッティング
    514514    i=0;
    515     psp.pszTemplate=MAKEINTRESOURCE(IDD_NEWPROJECT_PAGE1);
     515    psp.pResource = static_cast<PROPSHEETPAGE_RESOURCE>(ActiveBasic::Resource::LoadResourceAlt(hResInst, IDD_NEWPROJECT_PAGE1, RT_DIALOG));
    516516    psp.pfnDlgProc=DlgNewProject_Page1;
    517517    hpsp[i]=CreatePropertySheetPage(&psp);
    518518    i++;
    519     psp.pszTemplate=MAKEINTRESOURCE(IDD_NEWPROJECT_PAGE2);
     519    psp.pResource = static_cast<PROPSHEETPAGE_RESOURCE>(ActiveBasic::Resource::LoadResourceAlt(hResInst, IDD_NEWPROJECT_PAGE2, RT_DIALOG));
    520520    psp.pfnDlgProc=DlgNewProject_Page2;
    521521    hpsp[i]=CreatePropertySheetPage(&psp);
    522522    i++;
    523     psp.pszTemplate=MAKEINTRESOURCE(IDD_NEWPROJECT_PAGE3);
     523    psp.pResource = static_cast<PROPSHEETPAGE_RESOURCE>(ActiveBasic::Resource::LoadResourceAlt(hResInst, IDD_NEWPROJECT_PAGE3, RT_DIALOG));
    524524    psp.pfnDlgProc=DlgNewProject_Page3;
    525525    hpsp[i]=CreatePropertySheetPage(&psp);
     
    967967}
    968968void DlgProjectOptionSetting(HWND hwnd){
    969     PROPSHEETHEADER psh;
    970     PROPSHEETPAGE psp[MAX_PJSETDLG];
    971     HPROPSHEETPAGE hpsp[MAX_PJSETDLG];
     969    PROPSHEETHEADER psh = {};
     970    PROPSHEETPAGE psp[MAX_PJSETDLG] = {};
     971    HPROPSHEETPAGE hpsp[MAX_PJSETDLG] = {};
    972972    int i;
    973973    memset(&SetSwitch,0,MAX_PJSETDLG);
     
    976976    i=0;
    977977    psp[i].dwSize=sizeof(PROPSHEETPAGE);
    978     psp[i].dwFlags=PSP_DEFAULT;
    979     psp[i].hInstance=hResInst;
    980     psp[i].pszTemplate=MAKEINTRESOURCE(IDD_PJ_OPTION1);
    981     psp[i].pfnDlgProc=(DLGPROC)DlgProjectOption_Whole;
     978    psp[i].dwFlags = PSP_DLGINDIRECT;
     979    psp[i].hInstance = GetWindowInstance(hwnd);
     980    psp[i].pResource = static_cast<PROPSHEETPAGE_RESOURCE>(ActiveBasic::Resource::LoadResourceAlt(hResInst, IDD_PJ_OPTION1, RT_DIALOG));
     981    psp[i].pfnDlgProc = DlgProjectOption_Whole;
    982982    hpsp[i]=CreatePropertySheetPage(&psp[i]);
    983983    i++;
    984984    psp[i].dwSize=sizeof(PROPSHEETPAGE);
    985     psp[i].dwFlags=PSP_DEFAULT;
    986     psp[i].hInstance=hResInst;
    987     psp[i].pszTemplate=MAKEINTRESOURCE(IDD_PJ_OPTION2);
    988     psp[i].pfnDlgProc=(DLGPROC)DlgProjectOption_Win32API;
     985    psp[i].dwFlags=PSP_DLGINDIRECT;
     986    psp[i].hInstance = GetWindowInstance(hwnd);
     987    psp[i].pResource = static_cast<PROPSHEETPAGE_RESOURCE>(ActiveBasic::Resource::LoadResourceAlt(hResInst, IDD_PJ_OPTION2, RT_DIALOG));
     988    psp[i].pfnDlgProc = DlgProjectOption_Win32API;
    989989    hpsp[i]=CreatePropertySheetPage(&psp[i]);
    990990    i++;
    991991    psp[i].dwSize=sizeof(PROPSHEETPAGE);
    992     psp[i].dwFlags=PSP_DEFAULT;
    993     psp[i].hInstance=hResInst;
    994     psp[i].pszTemplate=MAKEINTRESOURCE(IDD_PJ_OPTION3);
    995     psp[i].pfnDlgProc=(DLGPROC)DlgProjectOption_Manifest;
     992    psp[i].dwFlags = PSP_DLGINDIRECT;
     993    psp[i].hInstance = GetWindowInstance(hwnd);
     994    psp[i].pResource = static_cast<PROPSHEETPAGE_RESOURCE>(ActiveBasic::Resource::LoadResourceAlt(hResInst, IDD_PJ_OPTION3, RT_DIALOG));
     995    psp[i].pfnDlgProc = DlgProjectOption_Manifest;
    996996    hpsp[i]=CreatePropertySheetPage(&psp[i]);
    997997    i++;
    998998    psp[i].dwSize=sizeof(PROPSHEETPAGE);
    999     psp[i].dwFlags=PSP_DEFAULT;
    1000     psp[i].hInstance=hResInst;
    1001     psp[i].pszTemplate=MAKEINTRESOURCE(IDD_PJ_OPTION4);
    1002     psp[i].pfnDlgProc=(DLGPROC)DlgProjectOption_Debug;
     999    psp[i].dwFlags = PSP_DLGINDIRECT;
     1000    psp[i].hInstance = GetWindowInstance(hwnd);
     1001    psp[i].pResource = static_cast<PROPSHEETPAGE_RESOURCE>(ActiveBasic::Resource::LoadResourceAlt(hResInst, IDD_PJ_OPTION4, RT_DIALOG));
     1002    psp[i].pfnDlgProc = DlgProjectOption_Debug;
    10031003    hpsp[i]=CreatePropertySheetPage(&psp[i]);
    10041004
     
    19551955    return 0;
    19561956}
     1957PROPSHEETPAGE_RESOURCE LoadTest(HINSTANCE hinst, USHORT id, LPCTSTR type)
     1958{
     1959    auto t = ActiveBasic::Resource::LoadResourceAltWithSize(hResInst, id, type);
     1960    auto p = malloc(t.second);
     1961    memcpy(p, t.first, t.second);
     1962    return static_cast<PROPSHEETPAGE_RESOURCE>(p);
     1963}
    19571964void DlgOptionSetting(HWND hwnd){
    1958     PROPSHEETHEADER psh;
     1965    HINSTANCE hinst = GetWindowInstance(hwnd);
     1966    PROPSHEETHEADER psh = {};
    19591967#define MAX_SETDLG 32
    1960     PROPSHEETPAGE psp[MAX_SETDLG];
    1961     HPROPSHEETPAGE hpsp[MAX_SETDLG];
     1968    PROPSHEETPAGE psp[MAX_SETDLG] = {};
     1969    HPROPSHEETPAGE hpsp[MAX_SETDLG] = {};
    19621970    int i;
    19631971
     
    19701978    i=0;
    19711979
     1980
    19721981    //各ページのセッティング
    19731982    psp[i].dwSize=sizeof(PROPSHEETPAGE);
    1974     psp[i].dwFlags=PSP_DEFAULT;
    1975     psp[i].hInstance=hResInst;
    1976     psp[i].pszTemplate=MAKEINTRESOURCE(IDD_OPTION_WHOLE);
    1977     psp[i].pfnDlgProc=(DLGPROC)Dlg_Option_Whole;
     1983    psp[i].dwFlags=PSP_DLGINDIRECT;
     1984    psp[i].hInstance=hinst;
     1985    psp[i].pResource = static_cast<PROPSHEETPAGE_RESOURCE>(LoadTest(hResInst, IDD_OPTION_WHOLE, RT_DIALOG));
     1986    psp[i].pfnDlgProc=Dlg_Option_Whole;
    19781987    hpsp[i]=CreatePropertySheetPage(&psp[i]);
    19791988    i++;
    19801989    psp[i].dwSize=sizeof(PROPSHEETPAGE);
    1981     psp[i].dwFlags=PSP_DEFAULT;
    1982     psp[i].hInstance=hResInst;
    1983     psp[i].pszTemplate=MAKEINTRESOURCE(IDD_OPTION_EDITOR);
    1984     psp[i].pfnDlgProc=(DLGPROC)Dlg_Option_Editor;
     1990    psp[i].dwFlags=PSP_DLGINDIRECT;
     1991    psp[i].hInstance=hinst;
     1992    psp[i].pResource = static_cast<PROPSHEETPAGE_RESOURCE>(LoadTest(hResInst, IDD_OPTION_EDITOR, RT_DIALOG));
     1993    psp[i].pfnDlgProc=Dlg_Option_Editor;
    19851994    hpsp[i]=CreatePropertySheetPage(&psp[i]);
    19861995    i++;
    19871996    psp[i].dwSize=sizeof(PROPSHEETPAGE);
    1988     psp[i].dwFlags=PSP_DEFAULT;
    1989     psp[i].hInstance=hResInst;
    1990     psp[i].pszTemplate=MAKEINTRESOURCE(IDD_OPTION_COLOR);
    1991     psp[i].pfnDlgProc=(DLGPROC)Dlg_Option_Color;
     1997    psp[i].dwFlags=PSP_DLGINDIRECT;
     1998    psp[i].hInstance=hinst;
     1999    psp[i].pResource = static_cast<PROPSHEETPAGE_RESOURCE>(LoadTest(hResInst, IDD_OPTION_COLOR, RT_DIALOG));
     2000    psp[i].pfnDlgProc=Dlg_Option_Color;
    19922001    hpsp[i]=CreatePropertySheetPage(&psp[i]);
    19932002    i++;
    19942003    psp[i].dwSize=sizeof(PROPSHEETPAGE);
    1995     psp[i].dwFlags=PSP_DEFAULT;
    1996     psp[i].hInstance=hResInst;
    1997     psp[i].pszTemplate=MAKEINTRESOURCE(IDD_OPTION_TOOLBAR);
    1998     psp[i].pfnDlgProc=(DLGPROC)Dlg_Option_Toolbar;
     2004    psp[i].dwFlags=PSP_DLGINDIRECT;
     2005    psp[i].hInstance=hinst;
     2006    psp[i].pResource = static_cast<PROPSHEETPAGE_RESOURCE>(LoadTest(hResInst, IDD_OPTION_TOOLBAR, RT_DIALOG));
     2007    psp[i].pfnDlgProc=Dlg_Option_Toolbar;
    19992008    hpsp[i]=CreatePropertySheetPage(&psp[i]);
    20002009
     
    20032012    i++;
    20042013    psp[i].dwSize=sizeof(PROPSHEETPAGE);
    2005     psp[i].dwFlags=PSP_DEFAULT;
    2006     psp[i].hInstance=hResInst;
    2007     psp[i].pszTemplate=MAKEINTRESOURCE(IDD_OPTION_RAD);
    2008     psp[i].pfnDlgProc=(DLGPROC)Dlg_Option_Rad;
     2014    psp[i].dwFlags=PSP_DLGINDIRECT;
     2015    psp[i].hInstance=hinst;
     2016    psp[i].pResource = static_cast<PROPSHEETPAGE_RESOURCE>(LoadTest(hResInst, IDD_OPTION_RAD, RT_DIALOG));
     2017    psp[i].pfnDlgProc=Dlg_Option_Rad;
    20092018    hpsp[i]=CreatePropertySheetPage(&psp[i]);
    20102019#endif
Note: See TracChangeset for help on using the changeset viewer.