04. februar 2004 - 08:32
Der er
12 kommentarer og 1 løsning
Med FontDialog og INI file, foesøges der valg af Font.Styles
Det er kun FontStyle jeg ikke kan få til, at fungerer! Håber du vil få Font.Style til at virke. Har prøvet mange muligheder! Her er mim INI-file. [MinSektion] FontName=Arial FontSize=10 FontColor=clRed FontStyle= Denne virker ikke! Benytter FontDialog komponenten. Se fejmeddelerne i proceduren nedenfor. procedure TForm1.Button9Click(Sender: TObject); var FontName : string; FontSize : Integer; FontStyle : string; FontColor : string; begin FontDialog1.Execute; FontName := FontDialog1.Font.Name; FontSize := FontDialog1.Font.Size; //[Error] Unit1.pas(228): Incompatible types: 'String' and 'TFontStyles' FontStyle := FontDialog1.Font.Style; ***** FontColor := ColorToString(FontDialog1.Font.Color); {FontName} MyINI.WriteString('MinSektion', 'FontName', FontName); Edit1.Text := MyINI.ReadString('MinSektion', 'FontName', 'Ikke fundet'); Memo1.Font.Name:= Edit1.Text; {FontSize} MyINI.WriteInteger('MinSektion', 'FontSize', FontSize); Edit2.Text:= IntToStr(MyINI.ReadInteger('MinSektion', 'FontSize', 10)); Memo1.Font.Size:= Strtoint(Edit2.Text); {FontStyle} MyINI.WriteString('MinSektion', 'FontStyle', FontStyle); Edit3.Text := MyINI.ReadString('MinSektion', 'FontStyle', 'Ikke fundet'); //[Error] Unit1.pas(261): Incompatible types: 'TFont' and 'TCaption' Memo1.Font:= Edit3.Text; ***** {FontColor} MyINI.WriteString('MinSektion', 'FontColor', FontColor ); Edit4.Text := MyINI.ReadString('MinSektion', 'FontColor', 'Ikke fundet'); Memo1.Font.Color:= StringToColor(Edit4.Text); end; Med venlig hilsen Monie Jacobsen My mail adress is monie at sunwind dot dk
Annonceindlæg tema
Offentlig digitalisering
Fra effektivisering til digital suverænitet. Hvordan skaber det offentlige en digital fremtid med AI, sikkerhed og kontrol i centrum?
04. februar 2004 - 11:28
#1
Problemet er at du kan ikke konvetere et TFontStyles til en streng. Du kan konvetere den til en integer, og gemme den som sådan !
Prøv det her :
type
pFontStyles = ^TFontStyles;
pInteger = ^Integer;
function FontStylesToInteger(const Value : TFontStyles) : Integer;
begin
Result := pInteger(pFontStyles(@Value))^;
end;
function IntegerToFontStyles(const Value : Integer) : TFontStyles;
begin
Result := pFontStyles(pInteger(@Value))^;
end;
Hvorfor og hvordan virker det her skidt så ? Læs den følgende artikkel :
http://www.pythia.dk/artikler/vis_artikel.php?id=26 Jens B
04. februar 2004 - 11:50
#2
Hej Er ikke supperekspert i Delphi 6 Koderne du skrev til mig virker meget kryptisk! Er "type " placeret rigtig? I forhold til den procedure TForm1.Button9Click, hvordan skal det indsætte, bruges. Vil du prøve, at indskrive dit forslag i mine koder? type pFontStyles = ^TFontStyles; pInteger = ^Integer; var Form1: TForm1; MyINI: TINIFile; // TINIFile objektet PathToINIFile: String; implementation {$R *.dfm} function FontStylesToInteger(const Value : TFontStyles) : Integer; begin Result := pInteger(pFontStyles(@Value))^; end; function IntegerToFontStyles(const Value : Integer) : TFontStyles; begin Result := pFontStyles(pInteger(@Value))^; end; Compile Procejt uden fejlmeddling. men stadig ingen Font.Styles. Håber du vil hjælpe. Med venlig hilsen Monie Jacobsen My mail adress is monie at sunwind dot dk
04. februar 2004 - 12:05
#3
Mit kode har du sat rigtigt ind ... Så skal du bare ændre i button9 : DER STOD (Har klippet det vigtigste ud): var FontStyle : string; begin FontStyle := FontDialog1.Font.Style; .... {FontStyle} MyINI.WriteString('MinSektion', 'FontStyle', FontStyle); end; Det erstatter du med : var FontStyle : Integer; begin FontStyle := FontStylesToInteger(FontDialog1.Font.Style); .... {FontStyle} MyINI.WriteInteger('MinSektion', 'FontStyle', 0); end; Og så omvendt når du skal læse dem ind Jens B
04. februar 2004 - 12:21
#4
Hej Få nu følgende fejlmeddelser: Har med-sendet helle proceduren for en orden skyld. [Warning] Unit1.pas(102): Symbol 'IncludeTrailingBackslash' is specific to a platform [Error] Unit1.pas(239): Incompatible types: 'String' and 'Integer' [Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas' procedure TForm1.Button9Click(Sender: TObject); var FontName : string; FontSize : Integer; FontStyle : string; FontColor : string; begin FontDialog1.Execute; FontName := FontDialog1.Font.Name; FontSize := FontDialog1.Font.Size; FontStyle := FontStylesToInteger(FontDialog1.Font.Style); //[Error] Unit1.pas(228): Incompatible types: 'String' and 'TFontStyles' // FontStyle := FontDialog1.Font.Style; FontColor := ColorToString(FontDialog1.Font.Color); //procedure WriteString(const Section, Ident, Value: String); MyINI.WriteString('MinSektion', 'FontName', FontName); //function ReadString(const Section, Ident, Default: String): String; Edit1.Text := MyINI.ReadString('MinSektion', 'FontName', 'Ikke fundet'); Memo1.Font.Name:= Edit1.Text; MyINI.WriteInteger('MinSektion', 'FontSize', FontSize); //function ReadInteger(const Section, Ident: String; Default: Longint): Longint; Edit2.Text:= IntToStr(MyINI.ReadInteger('MinSektion', 'FontSize', 10)); Memo1.Font.Size:= Strtoint(Edit2.Text); //procedure WriteString(const Section, Ident, Value: String); //MyINI.WriteString('MinSektion', 'FontStyle', FontStyle); MyINI.WriteInteger('MinSektion', 'FontStyle', 0); //function ReadString(const Section, Ident, Default: String): String; Edit3.Text := MyINI.ReadString('MinSektion', 'FontStyle', 'Ikke fundet'); //[Error] Unit1.pas(261): Incompatible types: 'TFont' and 'TCaption' //Memo1.Font:= Edit3.Text; //procedure WriteString(const Section, Ident, Value: String); MyINI.WriteString('MinSektion', 'FontColor', FontColor ); //function ReadString(const Section, Ident, Default: String): String; Edit4.Text := MyINI.ReadString('MinSektion', 'FontColor', 'Ikke fundet'); Memo1.Font.Color:= StringToColor(Edit4.Text); end; Med venlig hilsen Monie Jacobsen
04. februar 2004 - 12:40
#5
hej Ved at sætte FontStyle : Integer; så er der kun en fejlmeddelse tilbage! [Error] Unit1.pas(264): Incompatible types: 'TFont' and 'TCaption' Se markeringen med: ********* procedure TForm1.Button9Click(Sender: TObject); var FontName : string; FontSize : Integer; FontStyle : Integer; FontColor : string; begin FontDialog1.Execute; FontName := FontDialog1.Font.Name; FontSize := FontDialog1.Font.Size; FontStyle := FontStylesToInteger(FontDialog1.Font.Style); FontColor := ColorToString(FontDialog1.Font.Color); {Font Name} //procedure WriteString(const Section, Ident, Value: String); MyINI.WriteString('MinSektion', 'FontName', FontName); //function ReadString(const Section, Ident, Default: String): String; Edit1.Text := MyINI.ReadString('MinSektion', 'FontName', 'Ikke fundet'); Memo1.Font.Name:= Edit1.Text; {Font Size} //procedure WriteString(const Section, Ident, Value: String) MyINI.WriteInteger('MinSektion', 'FontSize', FontSize); //function ReadInteger(const Section, Ident: String; Default: Longint): Longint; Edit2.Text:= IntToStr(MyINI.ReadInteger('MinSektion', 'FontSize', 10)); Memo1.Font.Size:= Strtoint(Edit2.Text); {Font Style} //procedure WriteString(const Section, Ident, Value: String); MyINI.WriteInteger('MinSektion', 'FontStyle', 0); //function ReadString(const Section, Ident, Default: String): String; Edit3.Text := MyINI.ReadString('MinSektion', 'FontStyle', 'Ikke fundet'); Memo1.Font:= Edit3.Text;******Her kommer fejmeddelsen {Font Color} //procedure WriteString(const Section, Ident, Value: String); MyINI.WriteString('MinSektion', 'FontColor', FontColor ); //function ReadString(const Section, Ident, Default: String): String; Edit4.Text := MyINI.ReadString('MinSektion', 'FontColor', 'Ikke fundet'); Memo1.Font.Color:= StringToColor(Edit4.Text); end; Mvh Monie Jacobsen
04. februar 2004 - 12:43
#6
Memo1.Font.name := Edit3.Text
04. februar 2004 - 12:56
#7
Hej Har rette: Det var mig der sov.. undskyld! Memo1.Font.name := Edit3.Text Men får nu meddelse: [Hint] Unit1.pas(241): Value assigned to 'FontStyle' never used som referer til næste linje. FontStyle := FontStylesToInteger(FontDialog1.Font.Style); Få ikke resultatat af valget at se i Edit3.txt Mvh Monie Jacobsen
04. februar 2004 - 13:51
#8
Ja nu sover du igen .. Du skal selvfølgelig gemme den MyINI.WriteInteger('MinSektion', 'FontStyle', FontStyle); Prøv nu selv at rette dine fejl ! Jens B
04. februar 2004 - 14:10
#9
Har rette det til som du har beskrevet. Så godt og så langt virker det. Men får nogle andre fejlmeddelse nu. Deklarere: Var FontName : string; FontSize : Integer; FontStyle : Integer; FontColor : string; [Error] Unit1.pas(155): Incompatible types: 'Integer' and 'String' procedure TForm1.btnFontStyleClick(Sender: TObject); begin FontStyle := IndskrivSaetning('Indskriv et Text','Defaul');****** Her er fejlmeddelsen //procedure WriteString(const Section, Ident, Value: String); MyINI.WriteInteger('MinSektion', 'FontStyle', 0); //function ReadString(const Section, Ident, Default: String): String; Edit3.Text := MyINI.ReadString('MinSektion', 'FontStyle', 'Ikke fundet'); //Memo1.Font.Style:= Edit3.Text; end; [Error] Unit1.pas(215): Incompatible types: 'TFontStyles' and 'TCaption' {Font Style} //procedure WriteString(const Section, Ident, Value: String); MyINI.WriteInteger('MinSektion', 'FontStyle', 0); //function ReadString(const Section, Ident, Default: String): String; Edit3.Text := MyINI.ReadString('MinSektion', 'FontStyle', 'Ikke fundet'); Memo1.Font.Style := Edit3.Text; *********** Her er fejlmeddelsen Med venlig hilsen Moie Jacobsen
04. februar 2004 - 14:26
#10
IndskrivSaetning retunerer tydelig vis en streng. Du forsøger at tildele den til en integer. Det er noget frofærteligt vrøvl du har gang i ! Det giver slet ikke mening.
04. februar 2004 - 14:39
#11
Min IndskrivSaetning er her. Jeg har svart streng variabler function IndskrivSaetning( sCaption: string; rDefault: String): String; var s: string; tmp: String; idx: Integer; begin s := InputBox('Indskriv en sætning', sCaption, String(rDefault)); try tmp := LowerCase(s); for idx := 1 to length(tmp) do begin if not (tmp[idx] in ['a'..'z', 'æ', 'ø', 'å', '[', ']' ]) then raise EConvertError.Create('Ikke gyldig sætning.'); end; except on e: EConvertError do begin ShowMessage('Fejl: ' + e.Message); tmp := IndskrivSaetning(sCaption, rDefault); end; end; // try..except. Result := tmp; end; Med venlig hilsen Monie Jacobsen
04. februar 2004 - 15:54
#12
Jeg hopper af her ! Jens B
05. april 2004 - 05:24
#13
Ok
Kurser inden for grundlæggende programmering