Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

How to display PropertySheets

richardduncan
Beginner
890 Views

Can someone please clue me in regarding the use of PropertySheets.

I have dialog procedures written that work (I tested them through other means) and PropertySheetPages and PropertySheetHeader structures populated (I think) according to the SDK documentation; however, I cannot get these two things to work together. The Dialog Procedures are setup to catch WM_NOTIFY messages and no EndDialog commands or zero-valued returns are present within them.

When called, the dialog does seem to appear for about a micro-second and then promptly disappears.

Below is a snippet of code used to setupthe PropertySheets. This is within a subroutine called after a WM_COMMAND is passed to the main window. Furthermore, is that the correct way of doing this, as the documentation is not so clear to me.

Thanks in advance, Richard

!* property sheet creation: ****************************************
    type (T_PROPSHEETPAGE) :: OptionsPS(0:1)
 type (T_PROPSHEETHEADER) :: OptionsPSHeader

 interface
 integer(4) function NumericsDlgProc( hDlg, message, wParam, lParam )
 !DEC$ ATTRIBUTES STDCALL,DECORATE, ALIAS : 'NumericsDlgProc' :: NumericsDlgProc
 end function 
 end interface
 interface 
 integer(4) function OutputDlgProc( hDlg, message, wParam, lParam )
 !DEC$ ATTRIBUTES STDCALL,DECORATE, ALIAS : 'OutputDlgProc' :: OutputDlgProc
 end function 
 end interface
! create a few property sheets: OptionsPS(0)%dwSize = sizeof(OptionsPS) OptionsPS(0)%dwFlags = PSP_DEFAULT ! + PSP_USETITLE OptionsPS(0)%hInstance = ghInstance OptionsPS(0)%pszTemplate = loc(IDD_NUMERICS) OptionsPS(0)%pszTitle = loc("Set numerical parameters"C) OptionsPS(0)%pfnDlgProc = loc(NumericsDlgProc) ! this proc works otherwise OptionsPS(0)%lParam = 0 OptionsPS(0)%pfnCallback = NULL
OptionsPS(1)%dwSize = sizeof(OptionsPS) OptionsPS(1)%dwFlags = PSP_DEFAULT ! + PSP_USETITLE OptionsPS(1)%hInstance = ghInstance OptionsPS(1)%pszTemplate = loc(IDD_OUTPUT) OptionsPS(1)%pszTitle = loc("Select report output"C) OptionsPS(1)%pfnDlgProc = loc(OutputDlgProc) ! this proc works too OptionsPS(1)%lParam = 0 OptionsPS(1)%pfnCallback = NULL
! create the header: OptionsPSHeader%dwSize = sizeof(OptionsPSHeader) OptionsPSHeader%dwFlags = PSH_PROPSHEETPAGE OptionsPSHeader%hInstance = ghInstance OptionsPSHeader%hwndParent = ghwndMain OptionsPSHeader%nPages = 2 !sizeof(OptionsPS) OptionsPSHeader%nStartPage = 0 OptionsPSHeader%ppsp = loc(OptionsPS) OptionsPSHeader%pfnCallback = NULL
hOptionsPS = PropertySheet(OptionsPSHeader)
0 Kudos
7 Replies
Paul_Curtis
Valued Contributor I
891 Views
The attached file gives complete sample code for using property sheets.
0 Kudos
richardduncan
Beginner
891 Views
Thank you so much for the sample code Paul.
Paul's example does work; however, I also found my original code to work when I used the MAKEINTRESOURCE function (instead of LOC) to assign the pszTemplate component of the PROPSHEETPAGE structure. In using either method there is a problem that I cannot seem to correct.
When the dialog is initialized, everything looks right; however, when another tab is selected, the dialog repaints itself with blanks, i.e., it does not paint any of the controls on that tab. Moving the dialog (say, with a mouse drag) causes everything to paint correctly. This behavior occurs every time a new tab is selected. When the application with open property sheet dialog loses focus to and goes "behind" another application, and subsequently, the application/dialog is brought back to the front, both the property sheet dialog -and- the application both are repainting with blanks. Again, moving the dialog causes both to repaint correctly. This paint problem only happens when the property sheet dialog is open.
I suspect this one is easy to fix, but since the (PropertySheet) dialog proc is inside a black box, I don't know where to start.
Thanks much.
Richard
0 Kudos
Jugoslav_Dujic
Valued Contributor II
891 Views
Richard,
What happens with painting problem if your PropSheetProc's only return FALSE? (without doing anything else)
Make sure your property sheet dialogs themselves have "Control" and"Child"styles, no border, ("Clip children" won't do harm as well).
Jugoslav
0 Kudos
Paul_Curtis
Valued Contributor I
891 Views

Richrd,

The dialog for each tab needs to have the child attibute as Jugoslav noted.

Also, my code sample mentions but omits the essential context-specific activities which need to take place in each dialog when the PSN_SETACTIVE notification message is received. This is where you need to enable the various controls which will be active, check the checkboxes, tell the listboxes which item is currently active, load the editboxes, and so forth. If you don't do these things, blankness could well be the result.

Similarly, you need to explicitly read all your controls each time you get a PSN_KILLACTIVE.

HTH,
Paul Curtis
0 Kudos
richardduncan
Beginner
891 Views
Paul, when the dialog is first initialized, the controls (in the initial tab) are painted correctly and set/populated as directed in the routines within the WM_INITDIALOG block. I believethe problem to bethe dialog (TabControl actually) not painting as it should whenever a new tab is selected; particularly, the controls do display correctly after the entire dialog is moved with a mouse drag. Prior to this, the tab control contains only unpainted blankness. Evidenced by the limited repainting performed as the dialog is tabbed-through, the controls are present during this blankness - they just seem to be painted over by the tab control background.
I did try explicitly using the EnableWindow function on the individual components, as well ShowWindow and a few other related things; none of these have any effect, as expected. As a kludge, I suppose that I could send a message to move the dialog window by 1 pixel and then move it back again (but that seems really unnecessary).

Jugoslav, here is a stripped-down chunk of code from the WM_NOTIFY block of one of the dialog procs: (I think this is what you meant)
pHdr = lparam
select case (hdr%code)
! this tab has just been selected:
case (PSN_SETACTIVE)
iret = SetWindowLong (hDlg, DWL_MSGRESULT, .false.) ! accept activation
! another tab is selected:
case (PSN_KILLACTIVE)
iret = SetWindowLong (hDlg, DWL_MSGRESULT, .false.) ! allow activation loss
end select
res = 1
return
The dialogs did previously have the "Child" and "No border" attributes set; I have just fixed the "Control" and "Clip children" settings as well. Nevertheless, with these settings and the above code the same behavior persists.
Forgive me if I haveoverlooked something obvious; I am still learning the Win32 ropes.
Thanks guys for your help!
Richard
0 Kudos
Jugoslav_Dujic
Valued Contributor II
891 Views
res = 1
return
Here lie the dragons: The DlgProc should return .TRUE. (.NE.0) only for messages it processes, to prevent further processing. By returning 1 always, you say you handle WM_PAINT and all related stuff, and the calling procedure does nothing, i.e. it doesn't update the window. Actually, it's almost always OK to return .FALSE. (0). It should be instead:
case default
res = 0
end select
return
Jugoslav
0 Kudos
richardduncan
Beginner
891 Views

That was it exactly.

Thanks Jugoslav!

0 Kudos
Reply