掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
EnumChildWindowsでTLabelを取得するには? (ID:45400)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
さらに、LabelのHintとCaptionだけ羅列するようにしてみました。 procedure TForm1.Button1Click(Sender: TObject); var dfmName: string; fs: TFileStream; ms: TMemoryStream; begin if OpenDialog1.Execute then begin dfmName := OpenDialog1.FileName; fs := TFileStream.Create(dfmName, fmOpenRead); ms := TMemoryStream.Create; try try ObjectResourceToText(fs, ms); Memo1.Lines.Text := ExtractLabelParam(ms); except Memo1.Lines.Text := ExtractLabelParam(fs); end; finally ms.Free; fs.Free; end; end; end; function TForm1.ExtractLabelParam(st: TStream): string; var s: string; sLine: TStringList; LabelFlag: boolean; begin Result := ''; LabelFlag := False; sLine := TStringList.Create; try st.Position := 0; sLine.LoadFromStream(st); for s in sLine do begin if (Pos('object', s) > 0) and (Pos(': TLabel', s) > 0) then begin Result := Result + 'Name : '+Copy(s, Pos('object', s)+7, Pos(': TLabel', s)-(Pos('object', s)+7)) + #13; LabelFlag := True; end; if LabelFlag then begin if Pos('Caption =', s) > 0 then Result := Result + ' ' + Trim(s) + #13; if Pos('Hint =', s) > 0 then Result := Result + ' ' + Trim(s) + #13; if Trim(s) = 'end' then begin Result := Result + #13; LabelFlag := False; end; end; end; finally sLine.Free; end; end; あとは"#12345"の全角文字をどうにかするだけ(^_^;) あ、これはDelphi2007でテストしてます。
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.