Lazarus

Free Pascal => General => Topic started by: Raul_ES on September 26, 2018, 12:16:31 am

Title: Personalized message & dialog boxes
Post by: Raul_ES 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
Title: Re: Personalized message & dialog boxes
Post by: lucamar 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.
Title: Re: Personalized message & dialog boxes
Post by: jamie on September 26, 2018, 11:17:54 pm
The "TTaskDialog" is very flexible, have you looked into that  yet?
Title: Re: Personalized message & dialog boxes
Post by: Raul_ES 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,
Title: Re: Personalized message & dialog boxes
Post by: Raul_ES 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,
Title: Re: Personalized message & dialog boxes
Post by: jamie 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.
Title: Re: Personalized message & dialog boxes
Post by: Raul_ES 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 :-/


Title: Re: Personalized message & dialog boxes
Post by: lucamar 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.
TinyPortal © 2005-2018