Solved

Using custom pagesetup dialog template

Posted on 2008-10-01
4
836 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now