Solved

Using custom pagesetup dialog template

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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month5 days, 21 hours left to enroll

627 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