⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialog.c

📁 frasr200的win 版本源码(18.21),使用make文件,使用的vc版本较低,在我的环境下编译有问题! 很不错的分形程序代码!
💻 C
📖 第 1 页 / 共 5 页
字号:
/*

	various dialog-box code

*/

#include <windows.h>
#include <commdlg.h>
#include <print.h>
#include <math.h>
#include <stdio.h>
#include "winfract.h"
#include "dialog.h"
#include "fractint.h"
#include "fractype.h"
#include "mathtool.h"
#include "profile.h"

extern HWND hwnd;                               /* handle to main window */
extern char szHelpFileName[];                   /* Help file name*/

extern BOOL zoomflag;                /* TRUE is a zoom-box selected */

extern char *win_choices[];
extern int win_numchoices, win_choicemade;
int CurrentFractal;

extern HANDLE hDibInfo;		/* handle to the Device-independent bitmap */
extern LPBITMAPINFO pDibInfo;		/* pointer to the DIB info */

extern int time_to_restart;                               /* time to restart?  */
extern int time_to_reinit;				/* time to reinit? */
extern int time_to_cycle;                               /* time to cycle? */

extern int xdots, ydots, colors, maxiter;
extern int ytop, ybottom, xleft, xright;
extern double xxmin, xxmax, yymin, yymax;
extern int fractype;
extern int calc_status;
extern double param[4];
extern int bailout;
extern struct moreparams far moreparams[];

extern int inside, outside, usr_biomorph, decomp, debugflag;
extern int usr_stdcalcmode, usr_floatflag;
extern	int	invert; 	/* non-zero if inversion active */
extern	double	inversion[3];	/* radius, xcenter, ycenter */
extern int numtrigfn;

extern int LogFlag, fillcolor;

int win_temp1, win_temp2, win_temp3, win_temp4;

int numparams,numtrig, numextra;
static char *trg[] = {"First Function","Second Function",
		      "Third Function","Fourth Function"};
static int paramt[] = {ID_FRACPARTX1, ID_FRACPARTX2,
                       ID_FRACPARTX3, ID_FRACPARTX4,
                       ID_FRACPARTX5, ID_FRACPARTX6 };
static int paramv[] = {ID_FRACPARAM1, ID_FRACPARAM2,
                       ID_FRACPARAM3, ID_FRACPARAM4,
                       ID_FRACPARAM5, ID_FRACPARAM6, };

extern int win_release;
extern char far win_comment[];

extern char far DialogTitle[];
extern unsigned char DefExt[10];
extern unsigned char FullPathName[128];
extern unsigned char readname[];

double far win_oldprompts[20];

extern int stopmsg(int ,CHAR far *);

/* far strings (near space is precious) */
char far about_msg01[] = "(C) 1990, 1993 The Stone Soup Group";
char far about_msg02[] = "";
char far about_msg03[] = "";
char far about_msg04[] = "";
char far about_msg05[] = "Winfract is copyrighted freeware and may not be";
char far about_msg06[] = "distributed for commercial or promotional purposes";
char far about_msg07[] = "without written permission from the Stone Soup Group.";
char far about_msg08[] = "Distribution of Winfract by BBS, network, and";
char far about_msg09[] = "software shareware distributors, etc. is encouraged.";
char far about_msg10[] = "";

BOOL FAR PASCAL About(hDlg, message, wParam, lParam)
HWND hDlg;
unsigned message;
WORD wParam;
LONG lParam;
{

float temp;
char tempname[40];
extern char far winfract_title_text[];
char about_msg00[80];

    switch (message) {

        case WM_INITDIALOG:
            sprintf(about_msg00,"Winfract version %d.%02d, Fractals for Windows release",
                win_release/100, win_release%100);
            SetDlgItemText(hDlg, ID_VERSION  ,about_msg00);
            SetDlgItemText(hDlg, ID_COMMENT  ,about_msg01);
            SetDlgItemText(hDlg, ID_COMMENT2 ,about_msg02);
            SetDlgItemText(hDlg, ID_COMMENT3 ,about_msg03);
            SetDlgItemText(hDlg, ID_COMMENT4 ,about_msg04);
            SetDlgItemText(hDlg, ID_COMMENT5 ,about_msg05);
            SetDlgItemText(hDlg, ID_COMMENT6 ,about_msg06);
            SetDlgItemText(hDlg, ID_COMMENT7 ,about_msg07);
            SetDlgItemText(hDlg, ID_COMMENT8 ,about_msg08);
            SetDlgItemText(hDlg, ID_COMMENT9 ,about_msg09);
            SetDlgItemText(hDlg, ID_COMMENT10,about_msg10);
            return (TRUE);

        case WM_COMMAND:
	    if (wParam == IDOK
                || wParam == IDCANCEL) {
                EndDialog(hDlg, TRUE);
                return (TRUE);
            }
            break;
    }
    return (FALSE);
}


BOOL FAR PASCAL Status(hDlg, message, wParam, lParam)
HWND hDlg;
unsigned message;
WORD wParam;
LONG lParam;
{
char tempstring[100];
    switch (message) {

        case WM_INITDIALOG:
            sprintf(tempstring,"fractal type: ");
            if (fractalspecific[fractype].name[0] != '*')
                strcat(tempstring, fractalspecific[fractype].name);
            else
                strcat(tempstring, &fractalspecific[fractype].name[1]);
            if (calc_status == 1)
                strcat(tempstring,"    (still being calculated)");
            else if (calc_status == 2)
                strcat(tempstring,"    (interrupted, resumable)");
            else if (calc_status == 3)
                strcat(tempstring,"    (interrupted, not resumable)");
            else
                strcat(tempstring,"    (completed)");
            /* ##### */
            SetDlgItemText(hDlg, IDS_LINE1,tempstring);
            if(fractalspecific[fractype].param[0][0] == 0)
                tempstring[0] = 0;
            else
                sprintf(tempstring,"%-30.30s   %14.10f",
                    fractalspecific[fractype].param[0], param[0]);
            SetDlgItemText(hDlg, IDS_LINE2,tempstring);
            if(fractalspecific[fractype].param[1][0] == 0)
                tempstring[0] = 0;
            else
                sprintf(tempstring,"%-30.30s   %14.10f",
                    fractalspecific[fractype].param[1], param[1]);
            SetDlgItemText(hDlg, IDS_LINE3,tempstring);
            if(fractalspecific[fractype].param[2][0] == 0)
                tempstring[0] = 0;
            else
                sprintf(tempstring,"%-30.30s   %14.10f",
                    fractalspecific[fractype].param[2], param[2]);
            SetDlgItemText(hDlg, IDS_LINE4,tempstring);
            if(fractalspecific[fractype].param[3][0] == 0)
                tempstring[0] = 0;
            else
                sprintf(tempstring,"%-30.30s   %14.10f",
                    fractalspecific[fractype].param[3], param[3]);
            SetDlgItemText(hDlg, IDS_LINE5,tempstring);
            sprintf(tempstring,"Xmin:        %25.16f", xxmin);
            SetDlgItemText(hDlg, IDS_LINE6,tempstring);
            sprintf(tempstring,"Xmax:        %25.16f", xxmax);
            SetDlgItemText(hDlg, IDS_LINE7,tempstring);
            sprintf(tempstring,"Ymin:        %25.16f", yymin);
            SetDlgItemText(hDlg, IDS_LINE8,tempstring);
            sprintf(tempstring,"Ymax:        %25.16f", yymax);
            SetDlgItemText(hDlg, IDS_LINE9,tempstring);
            return (TRUE);

        case WM_COMMAND:
	    if (wParam == IDOK
                || wParam == IDCANCEL) {
                EndDialog(hDlg, TRUE);
                return (TRUE);
            }
            break;
    }
    return (FALSE);
}


BOOL FAR PASCAL SelectFractal(hDlg, message, wParam, lParam)
HWND hDlg;
unsigned message;
WORD wParam;
LONG lParam;
{

    int i;
    int index;

    switch (message) {

        case WM_INITDIALOG:
            SetDlgItemText(hDlg, ID_LISTTITLE, 	DialogTitle);
            for (i = 0; i < win_numchoices; i++) 
                SendDlgItemMessage(hDlg, IDM_FRACTAL, LB_ADDSTRING,
                    NULL, (LONG) (LPSTR) win_choices[i]);
            SendDlgItemMessage(hDlg, IDM_FRACTAL, LB_SETCURSEL,
                win_choicemade, 0L);
            return (TRUE);

        case WM_COMMAND:
            switch (wParam) {

                case IDOK:
okay:           
                    index=SendDlgItemMessage(hDlg, IDM_FRACTAL,
                        LB_GETCURSEL, 0, 0L);
                    if (index == LB_ERR) {
                        MessageBox(hDlg, "No Choice selected",
                            "Select From a List", MB_OK | MB_ICONEXCLAMATION);
                        break;
                        }
                    win_choicemade = index;
                    EndDialog(hDlg, 1);
                    break;
                  
                case IDCANCEL:
                    win_choicemade = -1;
                    EndDialog(hDlg, 0);
                    break;
                    
                case IDM_FRACTAL:
                    switch (HIWORD(lParam)) {
                        case LBN_SELCHANGE:
                            index = SendDlgItemMessage(hDlg, IDM_FRACTAL,
                                LB_GETCURSEL, 0, 0L);
                            if (index == LB_ERR)
                                break;
                            break;
                         
                       case LBN_DBLCLK:
                            goto okay;

                    }
	        return (TRUE);
                }

        }
    return (FALSE);
}


BOOL FAR PASCAL SelectFracParams(hDlg, message, wParam, lParam)
HWND hDlg;
unsigned message;
WORD wParam;
LONG lParam;
{

    int i, j;
    char temp[30];

    switch (message) {

        case WM_INITDIALOG:
                win_temp1 = CurrentFractal;
	        SetDlgItemText(hDlg, ID_FRACNAME,   fractalspecific[win_temp1].name);
                for (numparams = 0; numparams < 4; numparams++)
                    if (fractalspecific[win_temp1].param[numparams][0] == 0)
                        break;
                numtrig = (fractalspecific[win_temp1].flags >> 6) & 7;
                if (numparams+numtrig > 6) numparams = 6 - numtrig;
                for (i = 0; i < 6; i++) {
                    temp[0] = 0;
                    if (i < numparams)
                        sprintf(temp,"%f",param[i]);
                    SetDlgItemText(hDlg, paramv[i], temp);
                    SetDlgItemText(hDlg, paramt[i],"(n/a)");
                    if (i < numparams)
                       SetDlgItemText(hDlg, paramt[i], fractalspecific[win_temp1].param[i]);
                    }
               for(i=0; i<numtrig; i++) {
                    SetDlgItemText(hDlg, paramt[i+numparams], trg[i]);
                    SetDlgItemText(hDlg, paramv[i+numparams],
                        trigfn[trigndx[i]].name);
                    }
                numextra = 0;
                if (fractalspecific[win_temp1].flags & MORE) {
                    /* uh-oh - over four parameters! */
                    int i, extra;
                    if ((extra = find_extra_param(win_temp1)) > -1)
                        for (i = 0; i < 6 - numparams - numtrig; i++)
                            if (moreparams[extra].param[i][0] != 0) {
                                numextra++;
                                sprintf(temp,"%f",
                                    moreparams[extra].paramvalue[i]);
                                SetDlgItemText(hDlg, paramt[i+numparams+numtrig],
                                    moreparams[extra].param[i]);
                                SetDlgItemText(hDlg, paramv[i+numparams+numtrig],
                                    temp);
                                }
                    }
                sprintf(temp,"%d",bailout);
	        SetDlgItemText(hDlg, ID_BAILOUT,   temp);
                sprintf(temp,"%.12f",xxmin);
	        SetDlgItemText(hDlg, ID_FRACXMIN,   temp);
                sprintf(temp,"%.12f",xxmax);
	        SetDlgItemText(hDlg, ID_FRACXMAX,   temp);
                sprintf(temp,"%.12f",yymin);
	        SetDlgItemText(hDlg, ID_FRACYMIN,   temp);
                sprintf(temp,"%.12f",yymax);
	        SetDlgItemText(hDlg, ID_FRACYMAX,   temp);
                return (TRUE);

        case WM_COMMAND:
            switch (wParam) {

                case IDOK:
                    {
                    for (i = 0; i < numtrig; i++) {
                        GetDlgItemText(hDlg, paramv[i+numparams], temp, 10);
                        temp[6] = 0;
                        for (j = 0; j <= 6; j++)
                            if(temp[j] == ' ') temp[j] = 0;
                        strlwr(temp);
                        for(j=0;j<numtrigfn;j++)
                            if(strcmp(temp,trigfn[j].name)==0)
                                break;
                        if (j >= numtrigfn) {
                            char oops[80];
                            sprintf(oops, "Trig param %d, '%s' is not a valid trig function\n", i+1, temp);
                            strcat(oops, "Try sin, cos, tan, cotan, sinh, etc.");
                            stopmsg(0,oops);
                            break;
                            }
                        }
                        if (i != numtrig) break;
                    }
                    for (i = 0; i < numparams; i++) {
                        GetDlgItemText(hDlg, paramv[i], temp, 20);
                        param[i] = atof(temp);
                        }
                    for (i = 0; i < numtrig; i++) {
                        GetDlgItemText(hDlg, paramv[i+numparams], temp, 10);
                        temp[6] = 0;
                        for (j = 0; j <= 6; j++)
                            if (temp[j] == 32) temp[j] = 0;
                        set_trig_array(i, temp);
                        }
                    for (i = 0; i < numextra; i++) {
                        GetDlgItemText(hDlg, paramv[i+numparams+numtrig], temp, 20);
                        param[i+4] = atof(temp);
                        }
		    GetDlgItemText(hDlg, ID_BAILOUT   , temp, 10);
		    bailout = atof(temp);
		    GetDlgItemText(hDlg, ID_FRACXMIN  , temp, 20);
		    xxmin = atof(temp);
		    GetDlgItemText(hDlg, ID_FRACXMAX  , temp, 20);
		    xxmax = atof(temp);
		    GetDlgItemText(hDlg, ID_FRACYMIN  , temp, 20);
		    yymin = atof(temp);
		    GetDlgItemText(hDlg, ID_FRACYMAX  , temp, 20);
		    yymax = atof(temp);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -