* * *

Author Topic: Personalized message & dialog boxes  (Read 916 times)

Raul_ES

  • Jr. Member
  • **
  • Posts: 66
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
Personalized message & dialog boxes
« on: September 26, 2018, 12:16:31 am »
Hi friends,

I am trying to do the following, nothing weird I believe. Just a unit with personalized/themed message and dialog boxes all within. I want to generate different kind of dialogs with different icons, buttons, input boxes, for instance a message box, a password input dialog,a yes/no message, etc. So I can make them all have a similar look in accordance to my needs and the rest of the program.  If it's a normal monitor they will look in a way, if it is a touch panel buttons will
be larger, etc. If it's Windows they'll look in a way, if it's Gtk/Qt in another....

I think that the solution would be to pass parameters to the constructor o maybe overloading it. I have'nt figured out how to make my own constructors and how to overload. I allready know how to manage the modal results from the dialogs, but I need the rest.


Please, check out the following code. Is the part that calls the dialogForm:

Code: Pascal  [Select]
  1.  
  2. begin
  3.     case dialogForm.ShowModal of // how I create my own constructors? or maybe just a set of parameters?
  4.     mrOk : begin
  5.  
  6.            // do whatever...
  7.  
  8.            end;
  9.     mrCancel : begin
  10.               // do anything else...
  11.            end;
  12.     end;
  13.  

Thanks
Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

lucamar

  • Full Member
  • ***
  • Posts: 231
Re: Personalized message & dialog boxes
« Reply #1 on: September 26, 2018, 01:04:48 am »
Why don't you use the standard dialogs? They are already themed and most are, at least, lightly customizable.

ETA: Also, you can look to their source code to see how they are built and managed.
« Last Edit: September 26, 2018, 01:06:58 am by lucamar »
Been there, done that ... barely kept the timelines.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 1.8.4/fpc 3.0.4 - Ubuntu 10, Kubuntu 14, Windows XP SP3 (Home & Prof.) and various DOS incarnations.

jamie

  • Hero Member
  • *****
  • Posts: 835
Re: Personalized message & dialog boxes
« Reply #2 on: September 26, 2018, 11:17:54 pm »
The "TTaskDialog" is very flexible, have you looked into that  yet?

Raul_ES

  • Jr. Member
  • **
  • Posts: 66
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
Re: Personalized message & dialog boxes
« Reply #3 on: October 10, 2018, 12:09:45 am »
Why don't you use the standard dialogs? They are already themed and most are, at least, lightly customizable.

ETA: Also, you can look to their source code to see how they are built and managed.

Thanks lucamar,

I'm struggling to make the project I'm working on as visualy  clear as possible so I am taking a lot of time to make its GUI as user-friendly and eye-candy as I can. The final user has to be able to use the program without any previous readings, it has to be able to answer to dialogs and make decisions quickly. It is a multiuser envoironment, young employees coexisting with older ones, visualy impaired users, different OSes, users changing from one platform to another, etc I thought that making my own dialogs with big icons, bitmaps with explanations, large buttons, etc is a good idea.

In any case, I believe it's a good coding exercise I want to try. :-) i am trying to locate the source code to check it out.

regards,
Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

Raul_ES

  • Jr. Member
  • **
  • Posts: 66
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
Re: Personalized message & dialog boxes
« Reply #4 on: October 10, 2018, 12:13:48 am »
The "TTaskDialog" is very flexible, have you looked into that  yet?

Thanks Jamie,

I didn't know about the TTaskDialog class. thanks for sharing! It's interesting but it stills lack some more flexibility I would really need.

Any way, I am rethinking the design.

regards,
Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

jamie

  • Hero Member
  • *****
  • Posts: 835
Re: Personalized message & dialog boxes
« Reply #5 on: October 10, 2018, 12:33:41 am »
 You can build custom dialogs, simply add a blank form to your project, set the MODAL results button, place all of your
controls on as you wish and call the form as ShowModal and it should display like a dialog box but with all your custom
buttons and interfaces on it.

Raul_ES

  • Jr. Member
  • **
  • Posts: 66
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
Re: Personalized message & dialog boxes
« Reply #6 on: October 13, 2018, 08:29:00 pm »
Hi jamie. The solution I am working on is similar to your idea.

The main form launches a complex dialog with all its components unvisible with a function something like:

Code: Pascal  [Select]
  1. modalResult := myDialog(WARNING; "Attention!"; "text..."; BUTTONOK);
  2.  

Then the myDialog unit will process the paramaters and its onCreate() event will make components visible or not depending on the parameters.

Then the dialog has to return an array of results [1,0,0,0,1....] the first value will be 1 if a button ok was
pressed, another value will contain a string with the input of a text box,. a password maybe, 1 if the checkbox was checked...

I have to work it further because a have a bit of confussion about processing the modal results of the dialog an how to pass the parameters and the results from one form to another :-/


Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

lucamar

  • Full Member
  • ***
  • Posts: 231
Re: Personalized message & dialog boxes
« Reply #7 on: October 13, 2018, 09:08:01 pm »
I have to work it further because a have a bit of confussion about processing the modal results of the dialog an how to pass the parameters and the results from one form to another :-/

Processing modal results is fairly easy: assign a ModalResult to each button in your dialog and check the result of MyDialog.ShowModal(...). Returning results is fairly easy too; you can simply use properties of your dialog form like does p.e.TOpenDialog, TSaveDialog, etc.

If you could share your code we may be able to help you a little more but, in general, building custom dialogs is fairly straigth forward and you have the source of the Dialogs unit to see how this is achieved.
Been there, done that ... barely kept the timelines.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 1.8.4/fpc 3.0.4 - Ubuntu 10, Kubuntu 14, Windows XP SP3 (Home & Prof.) and various DOS incarnations.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus