Solved

Using custom pagesetup dialog template

Posted on 2008-10-01
4
841 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

759 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