1 (edited by AD1408 2017-12-29 05:43:49)

Topic: Font Change for Grid and Memo

I got Dmitry's font change sample project for font change for grid and wanted to add additional font change on memo fields too.
However, couldn't get it working properly.


Issues:
♦ When changing memo font same font changes reflects on grid font too. In other word both components font settings shows the same font size color etc.
♦ I couldn't get grid rows to resize (vertically) to accommodate larger font sizes.


Additional features for memo field:
I'm not sure any of the below is available in current MVD. If not, perhaps Dmitry can help us on items below, when he takes a bit of break on Vodka in these festive season.

  • Insert Horizontal Line at cursor point.

  • Insert Current Date and time at cursor point.

  • Insert Symbol via some form of symbol map.


Please see the attached sample project:

Post's attachments

Attachment icon Font change.zip 20.69 kb, 425 downloads since 2017-12-29 

Adam
God... please help me become the person my dog thinks I am.

2 (edited by derek 2017-12-29 19:03:12)

Re: Font Change for Grid and Memo

Hi Adam,
I'm struggling to see why you would want to interactively change the font, size, colours etc - maybe someone else could have a look at it (but after a quick glance of the code, it seems that you are now wanting to load 2 different font settings but you only have 1 'savefont' procedure, so both grid and memo will always take the font settings of whatever was last saved).
With regard to the other points, attached is the way that I use to add text either at the end of a memo or part way through it (either by using the mouse or positioning with the keyboard).  It's only a couple of lines of code so it's probably the simplest (which is why I use it - LOL!) but there may be other (better?) ways to do it.
My attachment demonstrates your 'dates' example, but the principle is exactly the same for inserting anything from whatever combobox drop downs you want to place on the form, so you just copy and paste the code as required.  I've used it quite a bit in apps for inserting names and addresses, part numbers and descriptions - that sort of thing.
I've also done it 'on click' of the drop down rather than using a separate button - just seemed a bit neater - but you can put it back on a button if needed.
Regards,
Derek.

Post's attachments

Attachment icon Font change.zip 354 kb, 411 downloads since 2017-12-29 

Re: Font Change for Grid and Memo

Hi Derek,


Thank you very much for the updated sample project.


Since we don't have a RTF component in MVD, changing font attributes on component level where appropriate can offer something extra at present.

... it seems that you are now wanting to load 2 different font settings but you only have 1 'savefont' procedure, ...

I couldn't work out component level savefont procedure so that each component keeps their font settings. Is it doable to have multiple font save procedures for each component? Such as having font settings for grid, memo1, memo2 separately - in this case 3 different font settings.


Is it possible to auto resizing grid row height according to defined font size?


I couldn't understand and couldn't see any code for right click menu items you have added. What they do?
On symbol insertion, i meant to get symbols on a form and insert selected one from there. Something like:
https://s17.postimg.org/ntrdpvfa7/zzz_Temp1.png


I guess you don't have any trick for inserting horizontal line in memo field at present?

Adam
God... please help me become the person my dog thinks I am.

Re: Font Change for Grid and Memo

procedure Form1_Button22_OnClick (Sender: string; var Cancel: boolean);
begin
    OpenFile('C:\Windows\system32\charmap.exe');
end;

Domebil

Re: Font Change for Grid and Memo

domebil wrote:

procedure Form1_Button22_OnClick (Sender: string; var Cancel: boolean);
begin
    OpenFile('C:\Windows\system32\charmap.exe');
end;


Thanks a lot for the code to get Win Characters Set domebil.
What I wanted to do is to display Characters Set on my own form and insert selected character directly on the memo field at cursor point on a click of "Insert" button as on the screen cap above. Beside Win Characters Set doesn't copy a selected character in a way that MVD accepts.


Unfortunately, all issues mentioned on my previous post #3 remains unresolved.

Adam
God... please help me become the person my dog thinks I am.

6 (edited by derek 2017-12-31 14:11:44)

Re: Font Change for Grid and Memo

You could always take a subset of the symbols from charmap and add them to a drop-down list and then insert them into the memo as required (in the same way I outlined in my previous post). 
Bear in mind that not all symbols will be supported (but you can see which ones work and which ones don't when you add them to the list - the ones that don't work appear as a small rectangle).
Derek.

Post's attachments

Attachment icon Font change.zip 359.97 kb, 397 downloads since 2017-12-31 

Re: Font Change for Grid and Memo

Hi Derek,


Thank you very much for the latest update......................


I have tried adding and inserting symbols the way I like to do it within MVD using grid. Almost there but not quite. I couldn't come up with a code for inserting selected grid cell symbol into memo field onClick of the button?

Please see the attached sample project.


Also thank you for showing how to insert pre-defined phrases into memo.


ps/ I have changed inserting symbols with combobox slightly, so that user can add and edit symbols list via grid. Beside, for myself having combo data managed within MVD rather than embedding into db is better as I tend to alter db quite often and therefore start with blank db file.


Happy New Year .................................

Post's attachments

Attachment icon Font change Derek 2 Work.zip 17.85 kb, 386 downloads since 2018-01-01 

Adam
God... please help me become the person my dog thinks I am.

8 (edited by derek 2018-01-01 15:36:30)

Re: Font Change for Grid and Memo

Hi Adam and Happy New Year to one and all,
If you want to insert the cell contents (text, symbols - anything) from a tablegrid rather than a combobox, I'd do it this way (see attached) but as always, there may be other options;  I've attached it to a cell_click event rather than a button (it's one click less) - LOL!
Regards,
Derek

Post's attachments

Attachment icon getcellatpos.zip 350.98 kb, 414 downloads since 2018-01-01 

Re: Font Change for Grid and Memo

Hi Derek,


Great stuff.....
Thank you very much...........
Your kind help has always been a great learning source for me and I'm sure for other MVD users too.


Now, on this learning project outstanding items reduced down to two thanks to your help.
♦ Font issue;
  - Being able to save different fonts for different components or same components different instances. i.e. If I have 2 grid and 3 memo fields,
    I like to be able to save their own font settings separately.
  - Auto adjust grid row heights according to font size specified.
♦ Inserting horizontal line into memo field.

Adam
God... please help me become the person my dog thinks I am.

Re: Font Change for Grid and Memo

Hi Adam,
Have a look at the attached for having different font styles for different fields (I've cut out all of the code relating to the other issues so I could see more clearly what was needed for the fonts problem.  If it does what you need, you can just cut and paste it back into your original project).
One thing I can't get a handle on is saving different combinations of font styles (ie bold AND italic, bold AND underline etc), but if I remember rightly, that was also an issue in Dmitry's original font change sample project (so I guess I'm in good company!).
With regard to inserting horizontal lines, you could just add '___________'  or '-----------------'  etc to your tablegrid of symbols;  however, you don't know how many dashes or underscores you need to fill a line because, although the memo box on the form is a set width, because you have introduced the facility to change the font, font size etc, you can't tell what will ever fit properly.
Derek.

Post's attachments

Attachment icon changefonts.zip 346.86 kb, 428 downloads since 2018-01-02 

Re: Font Change for Grid and Memo

Hi Derek,


Thank you very much for the latest update..........

... One thing I can't get a handle on is saving different combinations of font styles (ie bold AND italic, bold AND underline etc) ...

Hopefully, Dmitry will provide the solution here.


On inserting Horizontal line front, I'm thinking that we can create a line in various heights as a font  and insert it same way as in combo symbol insertion. Only issue here is getting line font filling (repeat) one horizontal line to fit to the memo current width. Taking into account form together with memo field may be resizeable.

Adam
God... please help me become the person my dog thinks I am.

Re: Font Change for Grid and Memo

Hi Adam,
"Regular" font style has a value of 0, "Bold" is 1, "Italic" is 2, "Bold Italic" is 3. "Underline" is 4. "Strikeout" is 8. If you have "Bold Underline" then the value is the combination of "Bold" (1) and "Underline" (4) for a value of 5.  Just an FYI, you are not obligated to store these values in the Windows Registry. You can also store your app settings in an "ini" file or just a plain text "txt' or 'csv" file. Or in a table similar to your stopwatch project.


However, in my personal opinion, I would not allow users to change fonts on components in a project. You are opening yourself up to a whole lot of issues and a whole lot of script to accommodate for all the possible combinations of fonts and sizes of components. I just would not want to tackle such a task. Instead, I would sit down with users during the design phase of the project to decide on a predetermined style of components and leave it at that. But this is just my personal opinion.


As far as inserting a line, I have done just what Derek has shown and used dashes to separate sections of a memo field. You really do not need to put a full line across the memo field for separation. I have projects where memo fields are used more or less as a journal. I typically use a series of 10 or 20 dashes on a line and a date on another line and it visually looks fine for a separation..


I know this isn't what you are looking for, but I'm just trying to keep you from having a lot of headaches down the road. :-)

13 (edited by AD1408 2018-01-03 19:26:46)

Re: Font Change for Grid and Memo

Hi EHW,


Thank you very much for very useful information......................


Due to lack of having RTF component in MVD I was trying to add some feeble function to memo fields. I don't know when Dmitry is going to add much more useful components such as RTF, treeview etc. However, on version 4, I'd have much preferred to have RTF or Treeview component instead of Google maps. Beside these, the Grid component needs to be updated desperately before anything else due to some difficult or unfixable bugs and missing some features.


I take your point about changing font of components which I was not aware of possibility of creating many issues. I was mainly interested in changing memo field font settings only. Would I still encounter issues that you thinking of? If so, could you give couple of examples please.


...  I would sit down with users during the design phase of the project to decide on a predetermined style of components and leave it at that. ...

It's fine if application developed for a specific user but when general public use is the case then....


... Just an FYI, you are not obligated to store these values in the Windows Registry. You can also store your app settings in an "ini" file or just a plain text "txt' or 'csv" file. Or in a table similar to your stopwatch project.

Agreed. I'm not fun of using registry for storing settings etc. In fact I don't like Windows registry a bit.
I played around doing table version but failed. For learning purposes, if and when you have bit of free time could you please apply table and ini or text file based settings to the above Derek's latest sample project "changefonts.zip"


You and Derek have been great teachers for me here. Once again Thank you so much to both of you ......................................


Happy New Year.............

Adam
God... please help me become the person my dog thinks I am.

14 (edited by ehwagner 2018-01-04 16:19:16)

Re: Font Change for Grid and Memo

Adam,
Attached is a sample use of an ini file to store fonts for controls.


Issues you need to address when inserting a full line across a memo field is how many dashes you need to produce for the width of the memo field. For each font/font size (and there are a lot) you need to know how many pixels are needed for one dash, then do a calculation utilizing the pixel width of the memo field, then do a loop to propagate the number of dashes. What makes it worse is if you place multiple lines throughout the memo field and then change the font of the memo field, you would need to go back through the memo field and retrieve all the dash lines and recalculate and re-propagate all the lines. There are a lot of fonts and font sizes. I just don't see that it would be worth the effort. I would simply use a smaller number of dashes like 10 or 20 as suggested. Then it will not matter what the font/font size is, unless you change the font size to something extraordinary like 72.


Hope this helps. Happy New Year to you too!

Post's attachments

Attachment icon ChangeFonts using ini.zip 585.98 kb, 426 downloads since 2018-01-04 

Re: Font Change for Grid and Memo

Hi EHW,


Great stuff...........
Thank you very much..............
Truly appreciated.....................


If I understood correctly, now we can save for each memo field their own  font settings properly using your method, using ini file rather than win registry. I don't know why Dmitry used win registry rather than simpler and cleaner ini file in his sample font change project.


On horizontal line; first thank you for explanation and secondly you are absolutely right about unsuitability of using a font for it.
I'm thinking that it needs to be pixels based elastic line instead of a font, without wrap with option to increase vertical pixels count for adjusting height of the line. User may choose line height from pre-defined line heights via combobox. I know it's not some thing but bit like some other MVD components growing and shrinking when form resized where anchors used.

Adam
God... please help me become the person my dog thinks I am.

Re: Font Change for Grid and Memo

Hi
I need disable "Double click" and "Enter" functions  of the table grid. I don´t want run the edit form with those functions. Only  with a buttons.
Thanks

Re: Font Change for Grid and Memo

Adam,
Yes you can use it for any memo field. In fact you can use it for any control in any form if you want. The values inside the brackets [ ] can be any value you want. I elected to use the ?form.control" name for easier readability. Whatever value you use just make sure that your font button OnClick procedure has the same value and the OnShow procedure for the control LoadFont has the same value.


There are usually more than one way to do things in MVD. I'm glad Dimitry shows other ways of doing things especially when it may not be obvious to some or hasn't been exposed previously in the forum.  It's always beneficial to me to see other ways.


As far as your lines inside memo fields, using a pixel based elastic line, as you put it, is not an option in memo fields in it's current state. When Dimitry introduces an RTF type memo fields, then maybe you'll be able to use this type of line. For now you're stuck with dashes or underscores.