Solved

Using custom pagesetup dialog template

Posted on 2008-10-01
4
840 Views
Last Modified: 2012-06-27
I'm trying to use a custom pagesetup dialog template which i've stored in a resource file that is used by my program:

12 DIALOG 0, 0, 356, 196
STYLE DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Page Setup"
LANGUAGE LANG_ENGLISH, 0x1
FONT 8, "MS Shell Dlg"
{
 // controls here
}

I've compiled this (without any apparent problems) and I created a custom pagesetup dialog class based on the standard one in dialogs.pas.

As you can see in the resource template, the pagesetup dialog is named 12, so I assume the ID will be 12.

I've added the following code to the dialog's GetDefaults method:

    Inc(PageSetupDlgRec.Flags, PSD_ENABLEPAGESETUPTEMPLATE);
    PageSetupDlgRec.lpPageSetupTemplateName := MakeIntResource(12);

The idea is that that'd supposed to load the new template, however, when creating and executing an instance of the class, it doesn't appear to have loaded the template as it still uses the default, where did I go wrong?
0
Comment
Question by:Freddy1990
  • 2
  • 2
4 Comments
 
LVL 21

Expert Comment

by:developmentguru
ID: 22618188
Wow, first you are doing things the hard way!  If all you need is a custom dialog for page setup do it as a new Delphi form and call it up using ShowModal.  For your OK and Cancel buttons you can set the modal result property to mrOK and mrCancel if you do not need to do any additional processing at the time the user clicks the button.  The result will be passed back as the function result from ShowModal.  Don't forget to set the form's border style property to bsDialog.

if MyDialog.ShowModal = mrOK then
  begin
    //read out the values
  end;

If you are trying to do all the extra low level work for a reason that would disallow using forms, let me know.
0
 
LVL 3

Author Comment

by:Freddy1990
ID: 22619522
Of course I'm doing this for a reason, I can go ahead and make a form, but I'd like to use the pagesetup dialog with it's own components (like the example page which is changed when another paper format is selected and such...), rather than building one from scratch (which I'd only do as a last resort, the idea is that it's supposed to be identical to the notepad pagesetup dialog)... Anyway, I don't think my question is that big of a deal is it? I've got everything I need, the combining is just the problem, once I can get the new class to use the custom dialog template, I can continue and finish it up... I've browsed trough tons of c++ code already which does this, but it doesn't seem to be as straight forward for delphi...
0
 
LVL 21

Assisted Solution

by:developmentguru
developmentguru earned 50 total points
ID: 22678878
Sorry about the delay.  I found an example where the programmer created the standard dialog and was able to add his own custom control to it.
http://www.scalabium.com/faq/dct0107.htm

Here is a link to a $19.00 package that is supposed to make customizing standard dialogs easy in Delphi
http://www.vclcomponents.com/Delphi/Dialogs/Dialog_Workshop_for_Delphi_and_C__Builder_Standard_Edition-info.html

Not sure if this is another or if it is the same one...
http://www.componentage.com/delphidialogs.htm

Let me know if you need more

0
 
LVL 3

Accepted Solution

by:
Freddy1990 earned 0 total points
ID: 22706929
Srr for the delay, I've been rather busy...

Well, I've finally sorted out the problem, however I really needed to do this based purely on api calls, no vcl components or anything, I finally succeeded, there was a combo of small bugs preventing the dialog from opening...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question