如何在CMFCPropertyGridCtrl

时间:2016-06-20 04:32:39

标签: c++ mfc mfc-feature-pack

如何在CMFCPropertyGridCtrl中更改属性的颜色(所有其他属性中的单个属性)?

1 个答案:

答案 0 :(得分:3)

您需要从CMFCPropertyGridCtrol类派生一个类,并覆盖CMFCPropertyGridCtrl::OnDrawProperty方法。这允许您在调用默认实现之前根据自己的喜好更改设备上下文:

<head>
  <base href="https://polygit.org/polymer+1.5.0/components/">

  <!-- Polygit can't find intl-messageformat.min.js, so we're importing
       it here for app-localize-behavior. Don't use this in your apps! -->
  <script src="https://rawgit.com/yahoo/intl-messageformat/v1.3.0/dist/intl-messageformat-with-locales.min.js"></script>

  <script src="webcomponentsjs/webcomponents-lite.min.js"></script>
  <link rel="import" href="paper-toggle-button/paper-toggle-button.html">
  <link rel="import" href="app-localize-behavior/app-localize-behavior.html">
</head>

<body>
  <x-foo></x-foo>

  <dom-module id="x-foo">
    <template>
      <paper-toggle-button on-change="_switchLanguage">Language: {{language}}</paper-toggle-button>
      <paper-toggle-button on-change="_switchGender">Gender: {{gender}}</paper-toggle-button>
      <div>Message: {{localize('response', 'gender', gender)}}</div>
    </template>
    <script>
      HTMLImports.whenReady(function() {
        Polymer({
          is: 'x-foo',
          behaviors: [
            Polymer.AppLocalizeBehavior
          ],
          properties: {
            gender: {
              type: String,
              value: "male"
            },
            language: {
              value: 'en'
            },
            resources: {
              value: function() {
                return {
                  'en': {
                    'response': "{gender, select,\
                                  male {He}\
                                  female {She}\
                                  } will respond shortly."
                  },
                  'fr': {
                    'response': "{gender, select,\
                                  male {Il}\
                                  female {Elle}\
                                  } répondra prochainement."
                  }
                }
              }
            }
          },
          _switchGender: function() {
            this.gender = this.gender === 'male' ? 'female' : 'male';
          },
          _switchLanguage: function() {
            this.language = this.language === 'fr' ? 'en' : 'fr';
          }
        });
      });
    </script>
  </dom-module>
</body>