Browse CVS Repository
Contents of /gikonavigoeson/gikonavi/ToolBarUtil.pas
Parent Directory
| Revision Log
| Revision Graph
Revision 1.27 -
( show annotations)
( download)
( as text)
Mon Feb 18 15:42:35 2008 UTC
(16 years, 1 month ago)
by h677
Branch: MAIN
CVS Tags: v1_59_0_771, v1_59_0_770, v1_59_0_773, v1_59_0_772, v1_59_0_775, v1_59_0_774, v1_59_0_777, v1_59_0_776, v1_59_0_778, v1_63_1_819, v1_62_0_812, v1_59_1_765, v1_60_0_788, v1_60_0_789, v1_58_0_748, v1_58_0_745, v1_60_0_781, v1_60_0_782, v1_58_0_746, v1_60_0_784, v1_60_0_786, v1_60_0_787, v1_59_0_767, v1_59_1_778, v1_59_0_768, v1_59_0_769, v1_57_1_744, v1_58_0_752, v1_58_0_750, v1_58_0_751, v1_58_0_756, v1_58_0_757, v1_58_0_754, v1_58_0_755, v1_58_0_759, v1_61_0_796, v1_61_0_797, v1_61_0_795, v1_61_0_798, v1_61_0_799, v1_63_0_818, v1_63_0_817, v1_63_0_816, v1_63_0_815, v1_62_0_805, v1_62_0_804, v1_62_0_807, v1_62_0_806, v1_62_0_803, v1_62_0_802, v1_62_0_809, v1_60_0_780, v1_60_0_779, v1_62_0_810, v1_62_0_811, v1_58_0_747, v1_60_0_783, v1_59_2_785, v1_60_1_793, v1_58_0_763, v1_58_0_762, v1_58_0_761, v1_58_0_760, v1_62_1_813, v1_57_2_749, v1_57_0_742, v1_57_0_743, v1_57_0_744, v1_61_0_800, v1_60_0_793, v1_60_0_792, v1_60_0_791, v1_60_0_790, v1_60_2_794, v1_61_1_801, HEAD
Branch point for: Bb57, Bb62, Bb63, Bb60, Bb61, Bb59, Bb58
Changes since 1.26: +1 -1 lines
File MIME type: text/x-pascal
ToolButtonをRemoveControlすると、アプリケーション終了時に
AccessViolationを起こす場合対応
| 1 |
unit ToolBarUtil; |
| 2 |
|
| 3 |
interface |
| 4 |
|
| 5 |
uses |
| 6 |
Windows, Messages, SysUtils, Classes, Controls, |
| 7 |
StdCtrls, ExtCtrls, ComCtrls, ActnList; |
| 8 |
|
| 9 |
const |
| 10 |
//罔?羣????若?????若?????????? |
| 11 |
DEF_STANDARD: array[0..11] of string = ('RoundAction', |
| 12 |
'', |
| 13 |
'ArrangeAction', |
| 14 |
'', |
| 15 |
'StopAction', |
| 16 |
'LoginAction', |
| 17 |
'', |
| 18 |
'CabinetBBSAction', |
| 19 |
'CabinetHistoryAction', |
| 20 |
'CabinetFavoriteAction', |
| 21 |
'MuteAction', |
| 22 |
'BeLogInOutAction'); |
| 23 |
//???鴻?????若?????若?????????? |
| 24 |
DEF_LIST: array[0..18] of string = ('ListNumberVisibleAction', |
| 25 |
'IconStyle', |
| 26 |
'UpFolderAction', |
| 27 |
'', |
| 28 |
'AllItemAction', |
| 29 |
'LogItemAction', |
| 30 |
'NewItemAction', |
| 31 |
'LiveItemAction', |
| 32 |
'ArchiveItemAction', |
| 33 |
'SelectItemAction', |
| 34 |
'', |
| 35 |
'ThreadEditorAction', |
| 36 |
'', |
| 37 |
'BoardIEAction', |
| 38 |
'', |
| 39 |
'SelectListReloadAction', |
| 40 |
'SelectThreadReloadAction', |
| 41 |
'', |
| 42 |
'SelectReservAction'); |
| 43 |
//???????吟???若?????若?????????? |
| 44 |
DEF_BROWSER: array[0..16] of string = ('BrowserMaxAction', |
| 45 |
'BrowserMinAction', |
| 46 |
'', |
| 47 |
'ScrollTopAction', |
| 48 |
'ScrollLastAction', |
| 49 |
'ScrollNewAction', |
| 50 |
'ScrollKokoAction', |
| 51 |
'', |
| 52 |
'SelectResAction', |
| 53 |
'ResRangeAction', |
| 54 |
'', |
| 55 |
'EditorAction', |
| 56 |
'', |
| 57 |
'IEAction', |
| 58 |
'', |
| 59 |
'ItemReloadAction', |
| 60 |
'UpBoardAction' |
| 61 |
); |
| 62 |
|
| 63 |
|
| 64 |
/// ???帥?潟?鴻?帥?ゃ????"tbsCheck"???帥?潟???≪???激?с??/span> |
| 65 |
CHECK_STYLE: array[0..37] of string = ('CabinetVisibleAction', |
| 66 |
'MuteAction', |
| 67 |
'ArrangeAction', |
| 68 |
'AllItemAction', |
| 69 |
'LogItemAction', |
| 70 |
'NewItemAction', |
| 71 |
'LiveItemAction', |
| 72 |
'ArchiveItemAction', |
| 73 |
'SelectItemAction', |
| 74 |
|
| 75 |
'StdToolBarVisibleAction', |
| 76 |
'AddressBarVisibleAction', |
| 77 |
'LinkBarVisibleAction', |
| 78 |
'ListToolBarVisibleAction', |
| 79 |
'ListNameBarVisibleAction', |
| 80 |
'BrowserToolBarVisibleAction', |
| 81 |
'BrowserNameBarVisibleAction', |
| 82 |
'MsgBarVisibleAction', |
| 83 |
'StatusBarVisibleAction', |
| 84 |
'CabinetHistoryAction', |
| 85 |
'CabinetFavoriteAction', |
| 86 |
'LargeIconAction', |
| 87 |
'SmallIconAction', |
| 88 |
'ListIconAction', |
| 89 |
'DetailIconAction', |
| 90 |
'BrowserTabVisibleAction', |
| 91 |
'BrowserTabTopAction', |
| 92 |
'BrowserTabBottomAction', |
| 93 |
'BrowserTabTabStyleAction', |
| 94 |
'BrowserTabButtonStyleAction', |
| 95 |
'BrowserTabFlatStyleAction', |
| 96 |
'LoginAction', |
| 97 |
'ListNumberVisibleAction', |
| 98 |
'AllResAction', |
| 99 |
'SelectResAction', |
| 100 |
'OnlyAHundredResAction', |
| 101 |
'OnlyKokoResAction', |
| 102 |
'OnlyNewResAction', |
| 103 |
'BeLogInOutAction' |
| 104 |
); |
| 105 |
|
| 106 |
/// ???帥?潟???鴻?帥?ゃ????"tbsDropDown"???帥?潟???≪???激?с??/span> |
| 107 |
/// Giko.pas : SetToolBarPopup ??篆??????篋? |
| 108 |
DROPDOWN_STYLE: array[0..4] of string = ('IconStyle', |
| 109 |
'IEAction', |
| 110 |
'CabinetBBSAction', |
| 111 |
'ResRangeAction', |
| 112 |
'ThreadRangeAction'); |
| 113 |
|
| 114 |
INI_FILENAME: string = 'ToolBar.ini'; |
| 115 |
|
| 116 |
//?阪??????絖? |
| 117 |
SEPARATOR_TEXT = '- ?阪???? -'; |
| 118 |
|
| 119 |
function IsCheckStyle(Action: TCustomAction): Boolean; |
| 120 |
function IsDropDownStyle(Action: TCustomAction): Boolean; |
| 121 |
procedure SetButtonStyle(Action: TCustomAction; Button: TToolButton); |
| 122 |
function GetActionItem(ActionList: TActionList; ActionName: string): TCustomAction; |
| 123 |
procedure ReadToolBarSetting(ActionList: TActionList; ToolBar: TToolBar); |
| 124 |
procedure SaveToolBarSetting(ToolBar: TToolBar); |
| 125 |
procedure MakeDefaultINIFile(); |
| 126 |
|
| 127 |
implementation |
| 128 |
|
| 129 |
uses |
| 130 |
IniFiles, GikoSystem, MojuUtils; |
| 131 |
|
| 132 |
function ConvertToolButton( setting : string ) : string; |
| 133 |
begin |
| 134 |
|
| 135 |
// ? [????00???鴻???粋;腓? ?? [???鴻??;腓榊??蚊??荐??] ??舟?? |
| 136 |
if setting = 'OnlyAHundredRes' then |
| 137 |
Result := 'ResRangeAction' |
| 138 |
else |
| 139 |
Result := setting; |
| 140 |
|
| 141 |
end; |
| 142 |
|
| 143 |
procedure ReadToolBarSetting(ActionList: TActionList; ToolBar: TToolBar); |
| 144 |
var |
| 145 |
FileName: string; |
| 146 |
ini: TMemIniFile; |
| 147 |
i: Integer; |
| 148 |
s: string; |
| 149 |
Action: TCustomAction; |
| 150 |
ToolButton: TToolButton; |
| 151 |
begin |
| 152 |
FileName := GikoSys.GetConfigDir + INI_FILENAME; |
| 153 |
if FileExists(FileName) then begin |
| 154 |
for i := ToolBar.ButtonCount - 1 downto 0 do begin |
| 155 |
ToolBar.Buttons[i].HostDockSite := nil; |
| 156 |
end; |
| 157 |
ini := TMemIniFile.Create(FileName); |
| 158 |
try |
| 159 |
i := 0; |
| 160 |
while True do begin |
| 161 |
s := ini.ReadString(ToolBar.Name, 'Button' + IntToStr(i), ''); |
| 162 |
s := ConvertToolButton( s ); |
| 163 |
if s = '-' then begin |
| 164 |
ToolButton := TToolButton.Create(ToolBar); |
| 165 |
ToolButton.Style := tbsSeparator; |
| 166 |
ToolButton.Width := 8; |
| 167 |
ToolButton.Left := 10000; |
| 168 |
ToolBar.InsertControl(ToolButton); |
| 169 |
end else if s <> '' then begin |
| 170 |
Action := GetActionItem(ActionList, s); |
| 171 |
if Action <> nil then begin |
| 172 |
ToolButton := TToolButton.Create(ToolBar); |
| 173 |
ToolButton.Action := Action; |
| 174 |
if ToolButton.ImageIndex = -1 then |
| 175 |
ToolButton.ImageIndex := 51; |
| 176 |
|
| 177 |
ToolButton.Left := 10000; |
| 178 |
SetButtonStyle(Action, ToolButton); |
| 179 |
ToolBar.InsertControl(ToolButton); |
| 180 |
end; |
| 181 |
end else |
| 182 |
Break; |
| 183 |
inc(i); |
| 184 |
end; |
| 185 |
finally |
| 186 |
ini.Free; |
| 187 |
end; |
| 188 |
end; |
| 189 |
end; |
| 190 |
|
| 191 |
procedure SaveToolBarSetting(ToolBar: TToolBar); |
| 192 |
var |
| 193 |
ini: TMemIniFile; |
| 194 |
i, j: Integer; |
| 195 |
Action: TBasicAction; |
| 196 |
begin |
| 197 |
ini := TMemIniFile.Create(GikoSys.GetConfigDir + INI_FILENAME); |
| 198 |
j := 0; |
| 199 |
try |
| 200 |
ini.EraseSection(ToolBar.Name); |
| 201 |
for i := 0 to ToolBar.ButtonCount - 1 do begin |
| 202 |
if ToolBar.Buttons[i].Style = tbsSeparator then begin |
| 203 |
//SelectComboBox?????????若???絖??????? |
| 204 |
if not (ToolBar.Buttons[i].Name = 'SelectComboBoxDummy') then begin |
| 205 |
ini.WriteString(ToolBar.Name, 'Button' + IntToStr(j), '-'); |
| 206 |
Inc( j ); |
| 207 |
end; |
| 208 |
end else begin |
| 209 |
Action := ToolBar.Buttons[i].Action; |
| 210 |
if Action <> nil then |
| 211 |
begin |
| 212 |
ini.WriteString(ToolBar.Name, 'Button' + IntToStr(j), Action.Name); |
| 213 |
Inc( j ); |
| 214 |
end; |
| 215 |
end; |
| 216 |
end; |
| 217 |
ini.UpdateFile; |
| 218 |
finally |
| 219 |
ini.Free; |
| 220 |
end; |
| 221 |
end; |
| 222 |
|
| 223 |
//ActionName??ction??菴????障?? |
| 224 |
function GetActionItem(ActionList: TActionList; ActionName: string): TCustomAction; |
| 225 |
var |
| 226 |
i: Integer; |
| 227 |
begin |
| 228 |
for i := 0 to ActionList.ActionCount - 1 do begin |
| 229 |
if ActionList.Actions[i].Name = ActionName then begin |
| 230 |
Result := TCustomAction(ActionList.Actions[i]); |
| 231 |
Exit; |
| 232 |
end; |
| 233 |
end; |
| 234 |
Result := nil; |
| 235 |
end; |
| 236 |
|
| 237 |
//???若?????帥?潟???鴻?帥?ゃ??┃絎??????????≪????荐?? |
| 238 |
procedure SetButtonStyle(Action: TCustomAction; Button: TToolButton); |
| 239 |
begin |
| 240 |
if IsCheckStyle(Action) then |
| 241 |
Button.Style := tbsCheck |
| 242 |
else if IsDropDownStyle(Action) then |
| 243 |
Button.Style := tbsDropDown |
| 244 |
else |
| 245 |
Button.Style := tbsButton; |
| 246 |
end; |
| 247 |
|
| 248 |
//Action?????с?????鴻?帥?ゃ?????≪???激?с?潟??????????菴????障?? |
| 249 |
function IsCheckStyle(Action: TCustomAction): Boolean; |
| 250 |
var |
| 251 |
i: Integer; |
| 252 |
begin |
| 253 |
for i := 0 to Length(CHECK_STYLE) - 1 do begin |
| 254 |
if Action.Name = CHECK_STYLE[i] then begin |
| 255 |
Result := True; |
| 256 |
Exit; |
| 257 |
end; |
| 258 |
end; |
| 259 |
Result := False; |
| 260 |
end; |
| 261 |
|
| 262 |
//Action???????????????潟?鴻?帥?ゃ?????≪???激?с?潟??????????菴????障?? |
| 263 |
function IsDropDownStyle(Action: TCustomAction): Boolean; |
| 264 |
var |
| 265 |
i: Integer; |
| 266 |
begin |
| 267 |
for i := 0 to Length(DROPDOWN_STYLE) - 1 do begin |
| 268 |
if Action.Name = DROPDOWN_STYLE[i] then begin |
| 269 |
Result := True; |
| 270 |
Exit; |
| 271 |
end; |
| 272 |
end; |
| 273 |
Result := False; |
| 274 |
end; |
| 275 |
|
| 276 |
procedure MakeDefaultINIFile(); |
| 277 |
var |
| 278 |
ini: TMemIniFile; |
| 279 |
i: Integer; |
| 280 |
begin |
| 281 |
//罔?羣????若?????若?????????? |
| 282 |
//DEF_STANDARD: |
| 283 |
//???鴻?????若?????若?????????? |
| 284 |
//DEF_LIST: |
| 285 |
//???????吟???若?????若?????????? |
| 286 |
//DEF_BROWSER: |
| 287 |
if not FileExists(GikoSys.GetConfigDir + INI_FILENAME) then begin |
| 288 |
ini := TMemIniFile.Create(GikoSys.GetConfigDir + INI_FILENAME); |
| 289 |
try |
| 290 |
for i := 0 to Length(DEF_STANDARD) - 1 do begin |
| 291 |
if DEF_STANDARD[i] <> '' then |
| 292 |
ini.WriteString('StdToolBar', 'Button' + IntToStr(i), DEF_STANDARD[i]) |
| 293 |
else |
| 294 |
ini.WriteString('StdToolBar', 'Button' + IntToStr(i), '-'); |
| 295 |
end; |
| 296 |
for i := 0 to Length(DEF_LIST) - 1 do begin |
| 297 |
if DEF_LIST[i] <> '' then |
| 298 |
ini.WriteString('ListToolBar', 'Button' + IntToStr(i), DEF_LIST[i]) |
| 299 |
else |
| 300 |
ini.WriteString('ListToolBar', 'Button' + IntToStr(i), '-'); |
| 301 |
end; |
| 302 |
for i := 0 to Length(DEF_BROWSER) - 1 do begin |
| 303 |
if DEF_BROWSER[i] <> '' then |
| 304 |
ini.WriteString('BrowserToolBar', 'Button' + IntToStr(i), DEF_BROWSER[i]) |
| 305 |
else |
| 306 |
ini.WriteString('BrowserToolBar', 'Button' + IntToStr(i), '-'); |
| 307 |
end; |
| 308 |
|
| 309 |
finally |
| 310 |
ini.UpdateFile; |
| 311 |
ini.Free; |
| 312 |
end; |
| 313 |
end; |
| 314 |
|
| 315 |
end; |
| 316 |
|
| 317 |
end. |
| |