Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using custom pagesetup dialog template

Posted on 2008-10-01
4
Medium Priority
?
844 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 200 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

721 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