1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
|
/* Copyright ENPC */
/* wmdialog.c
* Scilab
* Jean-Philipe Chancelier
* Bugs and mail : Scilab@inria.fr
* scilab command x_mdialog ( Windows part )
* see also men_mdialog.c
*/
#include "wmen_scilab.h"
/* Function prototypes */
static void FillInPropertyPage( PROPSHEETPAGE* , int, LPSTR, DLGPROC);
static int GetVal(HWND hDlg,int i,int j);
extern MDialog SciMDialog; /** used to stored the mdialog data **/
#define MAX_STR MAX_PATH
static char buf[MAX_STR]; /** maximum size of answer **/
/**************************************
* FUNCTION: MDialogPage(HWND, UINT, UINT, LONG)
* PURPOSE: Processes messages for "Your Information" page
* MESSAGES:
*
* WM_INITDIALOG - intializes the page
* WM_NOTIFY - processes the notifications sent to the page
**************************************/
BOOL APIENTRY MDialogPage(HWND hDlg,UINT message,UINT wParam,LONG lParam)
{
int i;
switch (message)
{
case WM_INITDIALOG:
for ( i=0 ; i < SciMDialog.NItPg[SciMDialog.CPage] ; i++ )
{
SetDlgItemText(hDlg, IDE_MDTEXT1+i,
SciMDialog.pszTitle[SciMDialog.CPage*NITEMMAXPAGE+i]);
SendMessage(GetDlgItem(hDlg, (IDE_MD1+i)), WM_SETTEXT, 0,
(LPARAM)SciMDialog.pszName[SciMDialog.CPage*NITEMMAXPAGE+i]);
}
SetDlgItemText(hDlg, IDE_MDTIT, SciMDialog.labels);
break;
/** sans effets pour l''instant
case WM_DRAWITEM:
{
LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
DrawIcon(lpdis->hDC, 0, 0,
(HICON)GetClassLong(GetParent(hDlg), GCL_HICON));
}
break;
**/
case WM_NOTIFY:
switch (((NMHDR FAR *) lParam)->code)
{
case PSN_KILLACTIVE:
SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
return 1;
break;
case PSN_RESET:
/** cancel **/
SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
break;
case PSN_SETACTIVE:
if ( SciMDialog.CPage == 0 )
PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_NEXT);
if ( SciMDialog.CPage > 0 && SciMDialog.CPage < SciMDialog.NPages -1 )
PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
if ( SciMDialog.CPage == SciMDialog.NPages -1 && SciMDialog.CPage != 0 )
PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_FINISH);
if ( SciMDialog.CPage == SciMDialog.NPages -1 && SciMDialog.CPage == 0 )
PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_FINISH);
SendMessage(GetDlgItem(hDlg,0x3024 ), BM_SETSTYLE, (WPARAM)BS_PUSHBUTTON, MAKELONG(FALSE, 0));
/** Je ne sais pas pourquoi mais ce qui suit fait que le dernier menu est mal mis a jour
avec gcwin32 avec VC++ ca marche : J'ai donc comment'e ce qui suit
et mis le meme code plus haut au initdialog
j'espere que ca ne fout pas la merde SciMDialog.CPageXXXXXX
for ( i =0 ; i < SciMDialog.NItPg[SciMDialog.CPage] ; i++)
SendMessage(GetDlgItem(hDlg, (IDE_MD1+i)), WM_SETTEXT, 0,
(LPARAM)SciMDialog.pszName[SciMDialog.CPage*NITEMMAXPAGE+i]);
**/
break;
case PSN_WIZBACK:
for ( i =0 ; i < SciMDialog.NItPg[SciMDialog.CPage] ; i++)
{
if ( GetVal(hDlg,i, SciMDialog.CPage*NITEMMAXPAGE+i) == 0)
SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
}
SciMDialog.CPage--;
break;
case PSN_WIZNEXT:
for ( i =0 ; i < SciMDialog.NItPg[SciMDialog.CPage] ; i++)
{
if ( GetVal(hDlg,i, SciMDialog.CPage*NITEMMAXPAGE+i) == 0)
SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
}
SciMDialog.CPage++;
break;
case PSN_WIZFINISH:
for ( i =0 ; i < SciMDialog.NItPg[SciMDialog.CPage] ; i++)
{
if ( GetVal(hDlg,i, SciMDialog.CPage*NITEMMAXPAGE+i) == 0)
SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
}
break;
default:
return FALSE;
}
break;
default:
return FALSE;
}
return TRUE;
}
/***/
static int GetVal(HWND hDlg,int i,int j)
{
int n;
SendDlgItemMessage(hDlg, (IDE_MD1+i),WM_GETTEXT,(WPARAM)MAX_STR,(LPARAM) buf);
n=strlen(buf);
if ( n != (int) strlen( SciMDialog.pszName[j]))
{
char *p;
p = (char *) REALLOC((char*) SciMDialog.pszName[j], (n+1)*sizeof(char));
if ( p == (char *) 0)
{
SciMDialog.ierr=1;
return(0);
}
else
{
SciMDialog.pszName[j] = p ;
}
}
strcpy(SciMDialog.pszName[j],buf);
return(1);
}
/**************************************
* FUNCTION: FillInPropertyPage(PROPSHEETPAGE *, int, LPSTR, LPFN)
* PURPOSE: Fills in the given PROPSHEETPAGE structure
* COMMENTS:
* This function fills in a PROPSHEETPAGE structure with the
* information the system needs to create the page.
**************************************/
void FillInPropertyPage( PROPSHEETPAGE* psp, int idDlg, LPSTR pszProc, DLGPROC pfnDlgProc)
{
psp->dwSize = sizeof(PROPSHEETPAGE);
psp->dwFlags = 0;
psp->hInstance = hdllInstance;
#ifdef __GNUC__XXX
psp->u1.pszTemplate = MAKEINTRESOURCE(idDlg);
psp->u2.pszIcon = "texticon";
#else
psp->pszTemplate = MAKEINTRESOURCE(idDlg);
psp->pszIcon = "texticon";
#endif
psp->pfnDlgProc = pfnDlgProc;
psp->pszTitle = pszProc;
psp->lParam = 0;
}
/**************************************
* FUNCTION: mDialogWindow();
* WARNING Th calling function must check
* the maximum number of pages
**************************************/
int mDialogWindow(void)
{
int i,lastitems;
PROPSHEETPAGE psp[NPAGESMAX];
PROPSHEETHEADER psh;
HWND hwndOwner;
if ( (hwndOwner = GetActiveWindow()) == NULL)
hwndOwner = textwin.hWndParent;
SciMDialog.NPages = SciMDialog.nv / NITEMMAXPAGE;
for ( i = 0 ; i < SciMDialog.NPages ; i++)
{
SciMDialog.NItPg[i]= NITEMMAXPAGE;
FillInPropertyPage( &psp[i], IDD_INFO3, TEXT("Scilab Dialog"),
(DLGPROC) MDialogPage );
}
/** Items in the last page **/
lastitems = SciMDialog.nv % NITEMMAXPAGE;
if ( lastitems != 0 )
{
SciMDialog.NPages++;
SciMDialog.NItPg[SciMDialog.NPages-1]= lastitems ;
FillInPropertyPage( &psp[SciMDialog.NPages-1], IDD_INFO1+lastitems-1,
TEXT("Scilab Dialog"),
(DLGPROC) MDialogPage);
}
SciMDialog.CPage = 0;
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_WIZARD | PSH_NOAPPLYNOW | PSP_USEHICON;
psh.hwndParent = hwndOwner;
psh.pszCaption = (LPSTR) TEXT("Scilab mdialog Wizard");
psh.nPages = SciMDialog.NPages;
#ifdef __GNUC__XXX
psh.u2.nStartPage = SciMDialog.CPage;
psh.u3.ppsp = (LPCPROPSHEETPAGE) &psp;
#else
psh.nStartPage = SciMDialog.CPage;
psh.ppsp = (LPCPROPSHEETPAGE) &psp;
#endif
return (PropertySheet(&psh));
}
|