Você está na página 1de 34

Help is available within the Resource Editor to explain the options for each of the dialog controls.

Some of the controls have two Properties sets: General and Styles. lic! the mouse on the name of the Properties set you want to view or modify. "ou can change the dialog box itself by double#clic!ing the left mouse button in any clear area in the box. $he Properties box opens for the dialog. $o change where your dialog appears on the screen% change the x and y values in the Properties box. $hese specify the screen pixel position of the dialog box&s upper#left corner. "ou can change the si'e of the dialog box by holding down the left mouse button as you drag the right or lower perimeter of the box. "ou can use the scroll bars to move the view region if you have si'ed your dialog window to be larger than the edit window. (f you want to edit the appearance of the dialog box later% you can open the resource file ).R * from the +ile menu% and clic! on the dialog icon. $he Resource Editor is automatically invo!ed and the dialog box is opened. Each control in a dialog box has a unique integer identifier. When the Resource Editor creates the include file (.FD), it assigns the PARAME ER attribute to each control and to the dialog box itself, so the! beco"e na"ed constants. #t also assigns each control and the dialog box an integer $alue. %ou can read the list of na"es and $alues in !our dialog boxes include file (for exa"&le, EMP.FD). When !our a&&lication uses a control, it can refer to the control or dialog box b! its na"e (for exa"&le, IDC_SCROLL BAR_TEMPERATURE or IDD_TEMP), or b! its integer $alue. #f !ou 'ant to rena"e a control or "a(e so"e other change to !our dialog box, !ou should "a(e the change through the Resource Editor in Microsoft De$elo&er )tudio. Do not use a text editor to alter !our .FD include file because the dialog resource 'ill not be able to access the changes. When !ou create a dialog box 'ith the Resource Editor, !ou s&ecif! the t!&es of dis&la!s and controls that are to be included in the box. %ou then "ust &ro$ide &rocedures to "a(e the dialog box acti$e. hese &rocedures use both dialog functions and !our subroutines to control !our &rogra"*s res&onse to the user*s dialog box in&ut. %our a&&lication "ust include the state"ent USE DIALOGM to access the dialog functions, and it "ust include the .FD file the Resource Editor created for !our dialog. For exa"&le+ PROGRAM TEMPERATURE USE DIALOGM IMPLICIT NONE INCLUDE 'TEMP.FD' CALL DoDialog( ) END PROGRAM he next sections describe ho' to code a dialog a&&lication+ #nitiali,ing and Acti$ating the Dialog -ox .allbac( Routines

Each dialog box has an associated $ariable of the deri$ed t!&e dialog. he dialog deri$ed t!&e is defined in the D#A/01M.F23 "odule, 'hich !ou access 'ith 4)E D#A/01M. When !ou 'rite !our dialog a&&lication, !ou refer to !our dialog box as a $ariable of t!&e dialog. For exa"&le+ USE DIALOGM INCLUDE 'TEMP.FD' TYPE (dialog) dlg LOGICAL r !"r# r !"r# $ DLGINIT( IDD_TEMP% dlg )

his code associates the dialog t!&e 'ith the dialog (IDD_TEMP in this exa"&le) defined in !our resource and include files ( EMP.R. and EMP.FD in this exa"&le). %ou gi$e !our a&&lication access to !our dialog resource file b! adding the .R. file to !our &ro5ect. %ou gi$e !our a&&lication access to the dialog include file b! including the .FD file in each sub&rogra". %ou associate the dialog &ro&erties in these files 'ith the dialog t!&e b! calling DLGINIT 'ith !our dialog na"e. An a&&lication that controls a dialog box should &erfor" the follo'ing actions+ 6. .all DLGINIT to initiali,e the dialog t!&e and associate !our dialog and its &ro&erties 'ith the t!&e. 7. #nitiali,e the controls 'ith the dialog set functions, such as DLGSET. 8. )et the callbac( routines to be executed 'hen a user "ani&ulates a control in the dialog box 'ith DLGSETSUB. 9. Run the dialog 'ith DLGMODAL. :. Retri$e control infor"ation 'ith the dialog get functions, such as DLGGET. ;. Free resources fro" the dialog 'ith DLGUNINIT. As an exa"&le of acti$ating a dialog box and controls, the follo'ing code initiali,es the te"&erature dialog box and controls created in the &re$ious exa"&le, sets the callbac( routine as U&da! T '&, dis&la!s the dialog box, and releases the dialog resources 'hen done+ SUBROUTINE DoDialog( ) USE DIALOGM IMPLICIT NONE INCLUDE 'TEMP.FD' INTEGER r !i#! LOGICAL r !log TYPE (dialog) dlg E(TERNAL U&da! T '& ) I#i!iali* . IF ( .#o!. DlgI#i!( idd_! '&% dlg ) ) T+EN ,RITE (-%-) .Error/ dialog #o! 0o"#d. ELSE ) S ! "& ! '& ra!"r 1o#!rol2. r !log $ DlgS !( dlg% IDC_SCROLLBAR_TEMPERATURE% 344% dlg_ra#g ) r !log $ DlgS !( dlg% IDC_EDIT_CELSIUS% .544. ) CALL U&da! T '&( dlg% IDC_EDIT_CELSIUS% dlg_16a#g ) r !log $ DlgS !S"7( dlg% IDC_EDIT_CELSIUS% U&da! T '& ) r !log $ DlgS !S"7( dlg% IDC_EDIT_FA+REN+EIT% U&da! T '& ) r !log $ DlgS !S"7( dlg% IDC_SCROLLBAR_TEMPERATURE% U&da! T '& ) ) A1!i8a! !6 dialog. r !i#! $ DlgModal( dlg ) ) R l a2 dialog r 2o"r1 2. CALL DlgU#i#i!( dlg ) END IF END SUBROUTINE DoDialog he dialog functions, such as DLGSET and DLGSETSUB, refer to the dialog controls b! the na"es !ou assigned to the" in the Pro&erties box 'hile creating the dialog box in the Resource Editor. For exa"&le+ r !log $ DlgS !( dlg% IDC_SCROLLBAR_TEMPERATURE% 344% DLG_RANGE)

#n this state"ent, the dialog function DLGSET assigns the control na"ed IDC_SCROLL BAR_TEMPERATURE a $alue of 733. he index DLG_RANGE s&ecifies that this $alue is a scroll bar range. he next state"ents+ r !log $ DlgS !( dlg% IDC_EDIT_CELSIUS% .544. ) CALL U&da! T '&( dlg% IDC_EDIT_CELSIUS% DLG_C+ANGE) set the dialog*s to& Edit box, na"ed IDC_EDIT_CELSIUS in the Resource Editor, to an initial $alue of 633, and call the routine U&da! T '& to 'rite this initial $alue to the screen. he next state"ents+ r !log $ DlgS !S"7( dlg% IDC_EDIT_CELSIUS% U&da! T '& ) r !log $ DlgS !S"7( dlg% IDC_EDIT_FA+REN+EIT% U&da! T '& ) r !log $ DlgS !S"7( dlg% IDC_SCROLLBAR_TEMPERATURE% U&da! T '& ) associate the callbac( routine U&da! T '& 'ith the three controls. Routines are assigned to the controls 'ith the function DLGSETSUB. #ts first argu"ent is the dialog $ariable, the second is the control na"e, the third is the na"e of the routine !ou ha$e 'ritten for the control, and the o&tional fourth argu"ent is an index to select bet'een "ulti&le routines. %ou can set the callbac( routines for !our dialog controls an!'here in !our a&&lication+ before o&ening !our dialog 'ith DLGMODAL, or fro" 'ithin another callbac( routine. All callbac( routines should ha$e the follo'ing interface+ SUBROUTINE callback ( dlg, control_name, callbacktype ) he dlg &ara"eter refers to the dialog box and allo's the callbac( to change $alues of the dialog controls. he control_name &ara"eter is the na"e of the control that caused the callbac(. he callbacktype &ara"eter indicates 'hat callbac( is occuring (for exa"&le, DLG_CLIC9ED, DLG_C+ANGE, DLG_DBLCLIC9). he last t'o &ara"eters allo' !ou to 'rite a single subroutine that can be used 'ith "ulti&le callbac(s fro" "ore than one control. !&icall!, !ou do this for controls co"&rising a logical grou&. For exa"&le, all the controls in the te"&erature dialog in the &re$ious exa"&le are associated 'ith the sa"e callbac( routine, U&da! T '&. %ou can also associate "ore than one callbac( routine 'ith the sa"e control, but !ou "ust then &ro$ide an index &ara"eter to indicate 'hich callbac( is to be used. As an exa"&le of a callbac( routine+ SUBROUTINE U&da! T '&( dlg% 1o#!rol_#a' % 1all7a1:!;& ) USE DIALOGM IMPLICIT NONE TYPE (dialog) dlg INTEGER 1o#!rol_#a' INTEGER 1all7a1:!;& INCLUDE 'TEMP.FD' C+ARACTER(3<=) ! >! INTEGER 1 l% 0ar% r !i#! LOGICAL r !log ) S"&&r 22 1o'&il r ?ar#i#g2 0or "#r 0 r #1 d arg"' #!2. INTEGER lo1al_1all7a1:!;& lo1al_1all7a1:!;& $ 1all7a1:!;& SELECT CASE (1o#!rol_#a' ) CASE (IDC_EDIT_CELSIUS) ) C l2i"2 8al" ?a2 'odi0i d 7; !6 "2 r 2o ) "&da! 7o!6 Fa6r #6 i! a#d S1roll 7ar 8al" 2. r !log $ DlgG !( dlg% IDC_EDIT_CELSIUS% ! >! ) READ (! >!% -% io2!a!$r !i#!) 1 l

IF ( r !i#! . @. 4 ) T+EN 0ar $ (1 lA4.4)-((353.4AB3.4)C544.4)DB3.4 ,RITE (! >!%-) 0ar R !log $ DlgS !( dlg% IDC_EDIT_FA+REN+EIT% TRIM(ADEUSTL(! >!)) ) r !log $ DlgS !( dlg% IDC_SCROLLBAR_TEMPERATURE% 1 l%dlg_&o2i!io# ) END IF CASE (IDC_EDIT_FA+REN+EIT) ) Fa6r #6 i! 8al" ?a2 'odi0i d 7; !6 "2 r 2o ) "&da! 7o!6 1 l2i"2 a#d S1roll 7ar 8al" 2. r !log $ DlgG !( dlg% IDC_EDIT_FA+REN+EIT% ! >! ) READ (! >!% -% io2!a!$r !i#!) 0ar IF ( r !i#! . @. 4 ) T+EN 1 l $ (0arAB3.4)-(544.4C(353.4AB3.4))D4.4 ,RITE (! >!%-) 1 l r !log $ DlgS !( dlg% IDC_EDIT_CELSIUS% TRIM(ADEUSTL(! >!)) ) r !log $ DlgS !( dlg% IDC_SCROLLBAR_TEMPERATURE% 1 l% dlg_&o2i!io# ) END IF CASE (IDC_SCROLLBAR_TEMPERATURE) ) S1roll 7ar 8al" ?a2 'odi0i d 7; !6 "2 r 2o ) "&da! 7o!6 C l2i"2 a#d Fa6r #6 i! 8al" 2. r !log $ DlgG !( dlg% IDC_SCROLLBAR_TEMPERATURE% 1 l% dlg_&o2i!io# ) 0ar $ (1 lA4.4)-((353.4AB3.4)C544.4)DB3.4 ,RITE (! >!%-) 0ar r !log $ DlgS !( dlg% IDC_EDIT_FA+REN+EIT% TRIM(ADEUSTL(! >!)) ) ,RITE (! >!%-) 1 l r !log $ DlgS !( dlg% IDC_EDIT_CELSIUS% TRIM(ADEUSTL(! >!)) ) END SELECT END SUBROUTINE U&da! T '& Each control in a dialog box, exce&t a &ushbutton, has a default callbac( that &erfor"s no action. he default callbac( for a &ushbutton<s clic( e$ent sets the return $alue of the dialog to the &ushbutton*s na"e and then exits the dialog. his "a(es all &ushbuttons exit the a&&lication b! default, and gi$es the 0= and .A>.E/ buttons good default beha$ior. he routine that calls DLGMODAL can then test to see 'hich &ushbutton caused the dialog to exit. .allbac(s for a &articular control are called after the $alue of the control has been changed b! the user<s action. .alling DLGSET does not cause a callbac( to be called for the changing $alue of a control. #n &articular, 'hen inside a callbac(, &erfor"ing a DLGSET on a control 'ill not cause the associated callbac( for that control to be called. .alling DLGSET before or after DLGMODAL has been called also does not cause the callbac( to be called. #f the callbac( needs to be called, it can be called "anuall! 'ith CALL callbackroutine after the DLGSET is &erfor"ed. "ou can use dialog functions as you would any intrinsic or run#time function. $hey are compatible with any pro,ect type% not ,ust -indows#based applications. $he dialog functions initiali'e and close the dialog box% retrieve user input from a dialog box% display data in the dialog box and modify the dialog box controls. $he include file ).+.* of the dialog box contains the names of the dialog controls that you specified in the Properties box of the Resource Editor when you created the dialog box. $he module .(/01G2.21. contains predefined variable names and type definitions. $hese control names% variables% and type definitions are used in the dialog function argument lists to manage your dialog box. $he dialog functions are listed in the following table. Dialog function Purpose

DLGEXIT loses an open dialog DLGGET Gets the value of a control variable DLGGETCHAR Gets the value of a character control variable DLGGETINT Gets the value of an integer control variable DLGGETLOG Gets the value of a logical control variable DLGINIT (nitiali'es the dialog DLGMODAL .isplays a dialog box DLGSET /ssigns a value to a control variable DLGSETCHAR /ssigns a value to a character control variable DLGSETINT /ssigns a value to an integer control variable DLGSETLOG /ssigns a value to a logical control variable DLGSETRET RN Sets the return value for DLGMODAL DLGSETS ! /ssigns a defined callbac! routine to a control DLG NINIT .eallocates memory for an initiali'ed dialog Each of these functions is described in the Reference. Each control in a dialog box has a unique integer identifier and na"e. %ou s&ecif! the na"e in the Pro&erties box for each control 'ithin the Resource Editor, and the Resource Editor assigns the PARAME ER attribute and an integer $alue to each control na"e. %ou can refer to a control b! its na"e, for exa"&le IDC_SCROLL BAR_TEMPERATURE, or b! its integer $alue, 'hich !ou can read fro" the include (.FD) file. Each control has one or "ore $ariables associated 'ith it, called control indexes. hese indexes can be integer, logical, character or external. For exa"&le, a &lain -utton has three associated $ariables+ one is a logical $alue associated 'ith its current state, one is a character $ariable that deter"ines its title, and the third is an external $ariable that indicates the subroutine to be called if a "ouse clic( occurs. .ontrols can ha$e "ulti&le $ariables of the sa"e t!&e. For exa"&le, the scroll bar control has four integer $ariables associated 'ith it+ scroll bar &osition, scroll bar range, the ste& ta(en if the user "o$es the scroll bar slide, and the ste& ta(en if the user clic(s on the scroll bar s&ace next to the slide. .ontrols and their indexes are discussed in+ .ontrol #ndexes A$ailable #ndexes for Each Dialog .ontrol )&ecif!ing .ontrol #ndexes

he $alue of a dialog control<s index is set 'ith the DLGSET functions+ DLGSET, DLGSETINT, DLGSETLOG, DLGSETCHAR, and DLGSETSUB. he control na"e and control index na"e are argu"ents to the DLGSET functions and s&ecif! the &articular control index being set. For exa"&le+ r !log $ DlgS !( dlg% IDC_SCROLLBAR_TEMPERATURE% F<% DLG_POSITION ) he index DLG_POSITION s&ecifies the scroll bar &osition is to be set to 9:. #n the next state"ent+ r !log $ DlgS !( dlg% IDC_SCROLLBAR_TEMPERATURE% 344% DLG_RANGE ) the index DLG_RANGE s&ecifies the scroll bar range is to be set to 733. he DLGSET functions ha$e the follo'ing s!ntax+

return

DLGSET (dlg, control_name, value, control_index_name)

he control_index_name deter"ines 'hat the value in the DLGSET function "eans. he control index na"es are declared in the "odule D#A/01M.M0D and should not be declared in !our routines. A$ailable control indexes and ho' the! s&ecif! the inter&retation of the value argu"ent are listed in the follo'ing table. Control inde! D/1?-#1) EP Ho" t#e $alue i% inter&reted

he a"ount of change that occurs in a )croll bar*s &osition 'hen the user clic(s beside the )croll bar slide (default @ 63) D/1?.AA>1E A subroutine called after the user has "odified a control and the control has been u&dated on the screen D/1?./#.=ED A subroutine called 'hen the control recei$es a "ouseBclic( D/1?D-/./#.= A subroutine called 'hen a control is doubleBclic(ed D/1?DEFA4/ )a"e as not s&ecif!ing a control index D/1?E>A-/E he enable state of the control (value @ 'TRUE' "eans enabled, value @ '(ALSE' "eans disabled) D/1?>4M# EM) he total nu"ber of ite"s in a list box or co"bo box D/1?P0)# #0> he current &osition of the )croll bar D/1?RA>1E he "axi"u" $alue of a )croll bar &osition (default @ 633)C the "ini"u" is al'a!s 6 D/1?)E/.AA>1E A subroutine called 'hen the selection in a list box or co"bo box changes D/1?)MA//) EP he a"ount of change that occurs in a )croll bar*s &osition 'hen the user clic(s on a scroll bar arro' D/1?) A E he user changable state of a control D/1? # /E he title text associated 'ith a control D/1?4PDA E A subroutine called after the user has "odified the control state but before the control has been u&dated on the screen he index na"es associated 'ith dialog controls do not need to be used unless there is "ore than one $ariable of the sa"e t!&e for the control and !ou do not 'ant the default $ariable. For exa"&le, the state"ents+ r !log $ DlgS !( dlg% IDC_SCROLLBAR_TEMPERATURE% F<% DLG_POSITION ) r !log $ DlgS !( dlg% IDC_SCROLLBAR_TEMPERATURE% F<) both set the )croll bar &osition to 9:, because DLG_POSITION is the default control index for the scroll bar. $he available indexes and defaults for each of the controls are listed in the following table. Control T"pe Integer in#e$ na%e na%e Su'routine in#e$ na%e Logical in#e$ na%e C&aracter in#e$

Static text .0G3E4/50E .0G3$($0E Group box .0G3E4/50E .0G3$($0E 5utton .0G3E4/50E .0G3$($0E .0G3 0( 6E. hec! box .0G3S$/$E )default*.0G3E4/50E .0G3$($0E .0G3 0( 6E. Radio button .0G3S$/$E )default*.0G3E4/50E .0G3$($0E .0G3 0( 6E. Edit box .0G3E4/50E .0G3S$/$E.0G3 H/4GE )default*.0G37P./$E Scroll bar .0G3P1S($(14 )default*.0G3R/4GE.0G35(GS$EP.0G3S2/00S$EP .0G3E4/50E .0G3 H/4GE 0ist box .0G3472($E2Ssets or returns the total number of items in a list% or you can include an index% 8 to n% to determine which list items have

been selected and their order .0G3E4/50E .0G3S$/$Eby default% sets or returns the text of the first selected item% or you can include an index% 8 to n% to set or return the text of a particular item.0G3SE0 H/4GE )default*.0G3.50 0( 6 ombo box .0G3472($E2Ssets or returns the total number of items in a list% or you can include an index% 8 to n% to determine which list item has been selected.0G3E4/50E .0G3S$/$Eby default% sets or returns the text of the select# ed item or first item in the list% or you can include an index% 8 to n% to set or return indicates the text of a particular item .0G3SE0 H/4GE )default*.0G3.50 0( 6.0G3 H/4GE.0G37P./$E .rop#down list box .0G3472($E2S )default*sets or returns the total number of items in a list% or you can include an index% 8 to n% to determine which list item has been selected.0G3S$/$Esets or returns the index of the selected item .0G3E4/50E .0G3S$/$Eby default% sets or returns the text of the select# ed item or first item in the list% or you can include an index% 8 to n% to set or return indicates the text of a particular item .0G3SE0 H/4GE )default*.0G3.50 0( 6 Where there is onl! one &ossibilit! for a &articular dialog control<s index t!&e (integer, logical, character, or subroutine), !ou do not need to s&ecif! the control index na"e in an argu"ent list. For exa"&le, !ou can set the )tatic text control IDC_TE(T_CELSIUS to a ne' $alue 'ith either of the follo'ing state"ents+ r !log$DLGSETC+AR(dlg%IDC_TE(T_CELSIUS%.N ?C l2i"2Ti!l .%DLG_TITLE) r !log$DLGSET(dlg%IDC_TE(T_CELSIUS% .N ? C l2i"2 Ti!l .% DLG_TITLE) %ou do not need the control index DLG_TITLE because there is onl! one character index for a )tatic text control. he generic function DLGSET chooses the control index to change based on the argu"ent t!&e, in this case .AARA. ER. For each t!&e of index, !ou can use the generic DLGSET function or the s&ecific DLGSET function for that t!&e+ DLGSETINT, DLGSETLOG, DLGSETCHAR, and DLGSETSUB. For exa"&le, !ou can disable the )tatic text control IDC_TE(T_CELSIUS b! setting its logical $alue to '(ALSE' 'ith either DLGSET or DLGSETLOG+ r !log $ DLGSETLOG (dlg% IDC_TE(T_CELSIUS% .FALSE.% DLG_ENABLE) r !log $ DLGSET (dlg% IDC_TE(T_CELSIUS% .FALSE.% DLG_ENABLE) #n both these cases, the control index DLG_ENABLE can be o"itted because there is onl! one logical control index for )tatic text controls.

%ou can quer! the $alue of a &articular control index 'ith the DLGGET functions, DLGGET, DLGGETINT, DLGGETLOG, and DLGGETCHAR. For exa"&le+ INTEGER 1"rr #!_8al LOGICAL ar _;o"_ #a7l d r !log$DLGGET(dlg%IDC_SCROLLBAR_TEMPERATURE%1"rr #!_8al% DLG_RANGE) ..$DLGGET(dlg%IDC_SCROLLBAR_TEMPERATURE%ar _;o"_ #a7l d%DLG ENABL) return the range and the enable state of the scroll bar. he argu"ents !ou declare (1"rr #!_8al and ar _;o" #a7l d in the &receding exa"&le) to hold the queried $alues "ust be of the sa"e t!&e as the $alues retrie$ed. #f !ou use s&ecific DLGGET functions such as DLGGETINT or DLGGETCHAR, the control index $alue retrie$ed "ust be the a&&ro&riate t!&e. For exa"&le, !ou cannot use DLGGETCHAR to retrie$e an integer or logical $alue. he DLGGET functions return '(ALSE' for illegal t!&e co"binations. %ou cannot quer! for the na"e of an external callbac( routine. #n general, it is better to use the generic functions DLGSET and DLGGET rather than their t!&eBs&ecific $ariations because then !ou do not ha$e to 'orr! about "atching the function to t!&e of $alue set or retrie$ed. DLGSET and DLGGET &erfor" the correct o&eration auto"aticall!, based on the t!&e of argu"ent !ou &ass to the". he dialog controls &ro$ided in the Resource Editor are $ersatile and flexible and 'hen used together can &ro$ide a so&histicated userBfriendl! interface for !our a&&lication. his section discusses the a$ailable dialog controls. An! control can be disabled b! !our a&&lication at an! ti"e, so that it no longer changes or res&onds to the user. his is done b! setting the control index DLG_ENABLE to '(ALSE' 'ith DLGSET or DLGSETLOG. For exa"&le+ LOGICAL r !log r !log $ DLGSET (dlg% IDC_C+EC9BO(5% .FALSE.% DLG_ENABLE) his exa"&le disables the control na"ed IDC_C+EC9 BO(5. When !ou create !our dialog box in the Resource Editor, the dialog controls are gi$en a tab order. When the user hits the A- (e!, the dialog box focus shifts to the next control in the tab order. -! default, the tab order of the controls follo's the order in 'hich the! 'ere created. his "a! not be the order !ou 'ant. %ou can change the order b! o&ening the /a!out "enu and choosing ab 0rder (or b! &ressing the (e! co"bination . R/DD) in the Resource Editor. A tab nu"ber 'ill a&&ear next to each control. .lic( the "ouse on the control !ou 'ant to be first, then on the control !ou 'ant to be second in the tab order and so on. ab order also deter"ines 'hich control gets the focus if the user &resses the 1rou& box hot(e!. ()ee 4sing 1rou& -oxes.) he next sections describe the function and use of the dialog controls+ 4sing )tatic ext 4sing Edit -oxes 4sing 1rou& -oxes 4sing .hec( -oxes and Radio -uttons 4sing -uttons 4sing /ist -oxes and .o"bo -oxes 4sing )croll -ars

)etting Return Ealues and Exiting

Static text is an area in the dialog that your application writes text to. $he user cannot change it. "our application can modify the Static text at any time% for instance to display a current user selection% but the user cannot modify the text. Static text is typically used to label other controls or display messages to the user. An Edit box is an area that !our a&&lication can 'rite text to at an!ti"e, but unli(e )tatic ext, the user can 'rite to an Edit box b! clic(ing the "ouse in the box and t!&ing. he follo'ing state"ents 'rite to an Edit box+ C+ARACTER(34) ! >! C.S #d ! >!.C r !log $ DLGSET (dlg% IDC_EDITBO(5% ! >!) he next state"ent reads the character string in an Edit box+ r !log $ DLGGET (dlg% IDC_EDITBO(5% ! >!) he $alues a user enters into the Edit box are al'a!s retrie$ed as character strings, and !our a&&lication needs to inter&ret these strings as the data the! re&resent. For exa"&le, nu"bers entered b! the user are inter&reted b! !our a&&lication as character strings. /i(e'ise, nu"bers !ou 'rite to the Edit box are sent as character strings. %ou can con$ert bet'een nu"bers and strings b! using internal read and 'rite state"ents to "a(e t!&e con$ersions. o read a nu"ber in the Edit box, retrie$e it as a character string 'ith DLGGET or DLGGETCHAR, and then execute an internal read using a $ariable of the nu"eric t!&e !ou 'ant (such as integer or real). For exa"&le+ REAL > LOGICAL r !log C+ARACTER(3<=) ! >! r !log $ DLGGET (dlg% IDC_EDITBO(5% ! >!) READ (! >!% -) > #n this exa"&le, the real $ariable > is assigned the $alue that 'as entered into the Edit box, including an! deci"al fraction. .o"&lex and double co"&lex $alues are read the sa"e 'a!, exce&t that !our a&&lication "ust se&arate the Edit box character string into the real &art and i"aginar! &art. %ou can do this 'ith t'o se&arate Edit boxes, one for the real and one for the i"aginar! &art, or b! requiring the user to enter a se&arator bet'een the t'o &arts and &arsing the string for the se&arator before con$erting. #f the se&arator is a co""a (,) !ou can read the string 'ith t'o real edit descri&tors 'ithout ha$ing to &arse the string. o 'rite nu"bers to an Edit box, do an internal 'rite to a string, then send the string to the Edit box 'ith DLGSET. For exa"&le+ INTEGER G LOGICAL r !log C+ARACTER(3<=) ! >! ,RITE (! >!%'(IF)') G r !log $ DLGSET (dlg% IDC_EDITBO(5% ! >!) Fortran Po'er)tation does not su&&ort "ultiline Edit boxes. A 1rou& box $isuall! organi,es a collection of controls as a grou&. When !ou select 1rou& box in Resource Editor, !ou create an ex&andingFshrin(ing box around the controls !ou 'ant to grou& and gi$e the grou& a title. %ou can add a hot(e! to !our grou& title 'ith an a"&ersand (G). For exa"&le, s&ecif!ing the grou& title as+ HT '& ra!"r

causes the H I to be underlined in the title and "a(es it a hot(e!. When the user &resses the (e! co"bination A/ D , the focus of the dialog box shifts to the next control after the 1rou& box in the tab order. his control should be a control in the grou&. (%ou can $ie' and change the tab order fro" the /a!outF ab 0rder "enu o&tion in the Resource Editor.) Disabling the 1rou& box disables the hot(e!, but does not disable an! of the controls 'ithin the grou&. As a "atter of st!le, !ou should generall! disable the controls in a grou& 'hen !ou disable the 1rou& box..hec( boxes and Radio -uttons &resent the user 'ith an eitherFor choice. A Radio -utton is &ushed or not, and a .hec( box is chec(ed or not. %ou use DLGGET or DLGGETLOG to chec( the state of these controls. heir state is a logical $alue that is 'TRUE' if the! are &ushed or chec(ed, and '(ALSE' if the! are not. For exa"&le+ LOGICAL &"26 d_2!a! % 16 1: d_2!a! % r !log r !log $ DLGGET (dlg% IDC_RADIOBUTTON5% &"26 d_2!a! ) r !log $ DLGGET (dlg% IDC_C+EC9BO(5% 16 1: d_2!a! ) #f !ou need to change the state of the button, for initiali,ation or in res&onse to other user in&ut, !ou use DLGSET or DLGSETLOG. For exa"&le+ LOGICAL r !log r !log $ DLGSET (dlg% IDC_RADIOBUTTON5% .FALSE.) r !log $ DLGSET (dlg% IDC_C+EC9BO(5% .TRUE.) 4nli(e .hec( -oxes and Radio -uttons, -uttons do not ha$e a state. he! do not hold the $alue of being &ushed or not &ushed. When the user clic(s on a -utton 'ith the "ouse, the -utton*s callbac( routine is called. hus, the &ur&ose of a -utton is to initiate an action. %ou deter"ine the action initiated b! the external &rocedure !ou assign as a callbac(. For exa"&le+ LOGICAL r !log E(TERNAL Di2&la;Ti' r !log $ DlgS !S"7( dlg% IDC_BUTTON_TIME% Di2&la;Ti' ) Fortran Po'er)tation does not su&&ort userBdra'n -uttons. %ou "ust add -uttons 'ith the Resource Editor in Microsoft De$elo&er )tudio. /ist boxes and .o"bo boxes are used 'hen the user needs to select a $alue fro" a set of "an! $alues. he! are si"ilar to a set of Radio buttons exce&t that /ist boxes and .o"bo boxes are scrollable and can contain "ore ite"s than a set of Radio buttons 'hich are li"ited b! the screen dis&la! area. Also, unli(e Radio buttons, the nu"ber of entries in a /ist box or .o"bo box can change at runBti"e. he difference bet'een a /ist box and a .o"bo box is that a /ist box is si"&l! a list of ite"s, 'hile a .o"bo box is a co"bination of a /ist box and an Edit box. A /ist box allo's the user to choose "ulti&le selections fro" the list at one ti"e, 'hile a .o"bo box allo's onl! a single selection, but a .o"bo box allo's the user to edit the selected $alue 'hile a /ist box onl! allo's the user to choose fro" the gi$en list. A Dro&Bdo'n list box loo(s li(e a .o"bo box since it has a dro&Bdo'n arro' to dis&la! the list. /i(e a .o"bo box, onl! one selection can be "ade at a ti"e in a Dro&Bdo'n list box, but, li(e a /ist box, the selected $alue cannot be edited. A Dro&Bdo'n list box ser$es the sa"e function as a /ist box exce&t for the

disad$antage that the user can choose onl! a single selection, and the ad$antage that it ta(es u& less dialog screen s&ace. Fortran Po'er)tation does not su&&ort userBdra'n list boxes or .o"bo boxes. %ou "ust create /ist boxes and .o"bo boxes 'ith the Resource Editor in Microsoft De$elo&er )tudio. he follo'ing sections describe ho' to use /ist boxes and .o"bo boxes+ 4sing /ist boxes 4sing .o"bo boxes 4sing Dro&Bdo'n /ist boxes

For both /ist boxes and .o"bo boxes, the control index DLG_NUMITEMS deter"ines ho' "an! ite"s are in the box. 0nce this $alue is set, !ou set the text of /ist box ite"s b! s&ecif!ing a character string for each ite" index. #ndexes run fro" 6 to the total nu"ber of list ite"s set 'ith DLG_NUMITEMS. For exa"&le+ LOGICAL r !log r !log $ DlgS ! r !log $ DlgS ! r !log $ DlgS ! r !log $ DlgS ! ( ( ( ( dlg% dlg% dlg% dlg% IDC_LISTBO(5% IDC_LISTBO(5% IDC_LISTBO(5% IDC_LISTBO(5% B% DLG_NUMITEMS ) .Mo .% 5 ) .Larr;.% 3 ) .C"rl;.% B )

&uts three ite"s in the /ist box. he initial $alue of each /ist box entr! is a blan( string and the $alue beco"es nonblan( after it has been set. %ou can change the list length and ite" $alues at an! ti"e, including fro" 'ithin callbac( routines. #f the list is shortened, the set of entries is truncated. #f the list is lengthened, blan( entries are added. #n the &receding exa"&le, !ou could extend the list length and define the ne' ite" 'ith+ r !log $ DLGSET ( dlg% IDC_LISTBO(5% F) r !log $ DLGSET ( dlg% IDC_LISTBO(5% .S6 '&.% F) )ince /ist boxes allo' selection of "ulti&le entries, !ou need a 'a! to deter"ine 'hich entries are selected. When the user selects a /ist box ite", it is assigned an integer index equal to the order in 'hich the ite" 'as selected. %ou can test 'hich list ite"s are selected b! reading the selection indexes in order until a ,ero $alue is read. For exa"&le, if in the &re$ious /ist box the user selected Moe and then .url!, the /ist box selection indexes 'ould ha$e the follo'ing $alues+ Selection inde! )alue 6 7 8 6 (for Moe) 8 (for .url!) 3 (no "ore selections) #f /arr! alone had been selected, the /ist box selection index $alues 'ould be+

Selection inde! )alue 6 7 7 (for /arr!) 3 (no "ore selections) o deter"ine the ite"s selected, the /ist box $alues can be read 'ith DLGGET until a ,ero is encountered. For exa"&le+ INTEGER G% #"'% ! 2! INTEGER% ALLOCATABLE // 8al" 2(/)

LOGICAL r !log r !log $ DLGGET (dlg% IDC_LISTBO(5% #"'% DLG_NUMITEMS) ALLOCATE 8al" 2(#"') G $ 5 ! 2! $ A5 DO ,+ILE (! 2! .NE. 4) r !log $ DLGGET (dlg% IDC_LISTBO(5% 8al" 2(G)% G) ! 2! $ 8al" 2(G) G $ G D 5 END DO #n this exa"&le, G is the selection index and 8al" 2(G) holds the list nu"bers, in order, of the ite"s selected b! the user, if an!. o read a single selection, or the first selected ite" in a set, !ou can use DLG_STATE, since for a /ist -ox DLG_STATE holds the character string of the first selected ite" (if an!). For exa"&le+ ) G ! !6 2!ri#g 0or !6 0ir2! 2 l 1! d i! '. r !log $ DLGGET (dlg% IDC_LISTBO(5% 2!r% DLG_STATE) Alternati$el!, !ou can first retrie$e the list nu"ber of the selected ite", and then get the string associated 'ith that ite"+ INTEGER 8al" C+ARACTER(3<=) 2!r ) G ! !6 li2! #"'7 r o0 !6 0ir2! 2 l 1! d i! '. r !log $ DLGGET (dlg% IDC_LISTBO(5% 8al" % 5) ) G ! !6 2!ri#g 0or !6a! i! '. r !log $ DLGGET (dlg% IDC_LISTBO(5% 2!r% 8al" ) #n these exa"&les, if no selection has been "ade b! the user, 2!r 'ill be a blan( string. #n the Pro&ertiesF)t!les box in the Resource Editor, /ist boxes can be s&ecified as sorted or unsorted. he default is sorted, 'hich causes /ist box ite"s to be sorted al&habeticall! starting 'ith A. #f a /ist box is sorted, before each callbac( is called or 'hen DLGMODAL returns, the ite"s in the /ist box are sorted in al&habetical order. he al&habetical sorting follo's the A).## collating sequence, and u&&ercase letters co"e before lo'ercase letters. For exa"&le, if the /ist box in the exa"&le abo$e 'ith the list HMoe,I H/arr!,I H.url!,I and H)he"&I 'ere sorted, before a callbac( or after DLGMODAL returned, index 6 'ould refer to H.url!,I index 7 to H/arr!,I index 8 to HMoe,I and index 9 to H)he"&.I For this reason, 'hen using sorted /ist boxes, indexes should not be counted on to be the sa"e before, during, and after a call to DLGMODAL. A .o"bo box is a co"bination of a /ist box and an Edit box. he user can "a(e a selection fro" the list that is then dis&la!ed in the Edit box &art of the control, or enter text directl! into the Edit box. (>ote that all dialog $alues a user enters are character strings, and !our a&&lication "ust inter&ret these strings as the data the! re&resent. For exa"&le, nu"bers entered b! the user are inter&reted b! !our a&&lication as character strings.) -ecause user in&ut can be gi$en in t'o 'a!s, selection fro" the /ist box &ortion or t!&ing into the Edit box &ortion directl!, !ou need to register t'o callbac( t!&es 'ith DLGSETSUB for a .o"bo box, dlg_2 l16a#g to handle a ne' list

selection b! the user, and dlg_"&da! to handle text entered b! the user directl! into the Edit box &ortion. For exa"&le+ r !log $ DlgS !S"7( dlg% IDC_COMBO5% U&da! Co'7o% dlg_2 l16a#g r !log $ DlgS !S"7( dlg% IDC_COMBO5% U&da! Co'7o% dlg_"&da! ) )

A .o"bo box list is created the sa"e 'a! a /ist box list is created, as described in the &re$ious section, but the user can select onl! one ite" fro" a .o"bo box at a ti"e. When the user selects an ite" fro" the list, Windo's auto"aticall! &uts the ite" into the Edit box &ortion of the .o"bo box. hus, there is no need, and no "echanis", to retrie$e the ite" list nu"ber of a selected ite". #f the user is t!&ing an entr! directl! into the Edit box &art of the .o"bo box, again Windo's auto"aticall! dis&la!s it and !ou do not need to. %ou can retrie$e the character string of the selected ite" or Edit box entr! 'ith the follo'ing state"ent+ ) R !"r#2 !6 16ara1! r 2!ri#g o0 !6 2 l 1! d i! ' or Edi! 7o> #!r; a2 2!r. r !log $ DLGGET (dlg% IDC_COMBO5% 2!r) %ou ha$e three choices for .o"bo box !&e in the )t!les tab of .o"bo box Pro&erties+ )i"&le, Dro& list, and Dro&Bdo'n. )i"&le and Dro& list are the sa"e, exce&t that a si"&le .o"bo box al'a!s dis&la!s the .o"bo box choices in a list, 'hile a dro& list .o"bo box has a dro&Bdo'n button and dis&la!s the choices in a dro&Bdo'n list, conser$ing screen s&ace. he Dro&Bdo'n t!&e is half'a! bet'een a .o"bo box and a /ist box and is described in the section U%ing Dro&*Do"n Li%t Bo!e%. o create a Dro&Bdo'n list box, choose a .o"bo box fro" the control toolbar &lace it in !our dialog. DoubleBclic( the left "ouse button on the .o"bo box to o&en the Pro&erties box. 0n the )t!les ab choose Dro&Bdo'n as the control t!&e. A Dro&Bdo'n list box has a dro&Bdo'n arro' to dis&la! the list. /i(e a .o"bo box, onl! one selection can be "ade at a ti"e in the list, but li(e a /ist -ox, the selected $alue cannot be edited. A Dro&Bdo'n list box ser$es the sa"e function as a /ist box exce&t for the disad$antage that the user can choose onl! a single selection, and the ad$antage that it ta(es u& less dialog screen s&ace. A Dro&Bdo'n list box has the sa"e control indexes as a .o"bo box 'ith the addition of another #> E1ER index to set or return the list nu"ber of the ite" selected in the list. For exa"&le+ INTEGER #"' ) R !"r#2 i#d > o0 !6 2 l 1! d i! '. r !log $ DLGGET (dlg% IDC_DROPDO,N5% #"'% DLG_STATE) With a )croll bar, the user deter"ines in&ut b! "ani&ulating the slide u& and do'n or right and left. %our a&&lication sets the range for the )croll bar, and thus can inter&ret a &osition of the slide as a nu"ber. #f !ou 'ant to dis&la! this nu"ber to the user, !ou need to send the nu"ber (as a character string) to a )tatic text or Edit -ox control. he )croll bar range al'a!s starts at 6. %ou set the u&&er li"it of the range b! setting the control index DLG_RANGE 'ith DLGSET or DLGSETINT. he default $alue is 633. For exa"&le+ LOGICAL r !log

r !log $ DLGSET (dlg% IDC_SCROLLBAR5% 353% DLG_RANGE) %ou get the slide &osition b! retrie$ing the control index DLG_POSITION 'ith DLGGET or DLGGETINT. For exa"&le+ INTEGER 2lid _&o2i!io# r !log $ DLGGET (dlg% IDC_SCROLLBAR5% 2lid _&o2i!io#% DLG_POSITION) %ou can also set the incre"ent ta(en 'hen the user clic(s on the arro' buttons of the )croll bar b! setting the control index DLG_SMALLSTEP. %ou set the incre"ent ta(en 'hen the user clic(s in the blan( area abo$e or belo' the slide in a $ertical )croll bar, or to the left or right of the slide in a hori,ontal )croll bar, b! setting the control index DLG_BIGSTEP. For exa"&le+ r !log $ DLGSET (dlg% IDC_SCROLLBAR5% F% DLG_SMALLSTEP) r !log $ DLGSET (dlg% IDC_SCROLLBAR5% 34% DLG_BIGSTEP) When the user selects the dialog*s 0= or .A>.E/ button, !our dialog &rocedure is exited and the dialog box is closed. DLGMODAL returns the control na"e (associated 'ith an integer identifier in !our include (.FD) file) of the control that caused it to exitC for exa"&le, IDO9 or IDCANCEL. #f !ou 'ant to exit !our dialog box on a condition other than the user selecting the 0= or .A>.E/ button, !ou need to include a call to the dialog subroutine DLGE+IT fro" 'ithin !our callbac( routine. For exa"&le+ SUBROUTINE E(ITSUB (dlg% >i!_7"!!o#_id% 1all7a1:!;& ) USE DIALOGM TYPE (DIALOG) dlg INTEGER >i!_7"!!o#_id% 1all7a1:!;& ... CALL DLGE(IT (dlg) he onl! argu"ent for DLGE+IT is the dialog deri$ed t!&e. he dialog box is exited after DLGE+IT returns control bac( to the dialog "anager, not i""ediatel! after calling DLGE+IT. hat is, if there are other state"ents follo'ing DLGE+IT 'ithin the callbac( routine that contains it, those state"ents are executed and the callbac( routine returns before the dialog box is exited. #f !ou 'ant DLGMODAL to return 'ith a $alue other than the control na"e of the control that caused the exit, (or J6 if DLGMODAL fails to o&en the dialog box), !ou can s&ecif! !our o'n return $alue 'ith the subroutine DLGSETRETURN. For exa"&le+ TYPE (DIALOG) dlg INTEGER al!r !"r# ... al!r !"r# $ FI< CALL DLGSETRETURN (dlg% al!r !"r#) CALL DLGE(IT(dlg) o a$oid confusion 'ith the default failure condition, use return $alues other than J6. #f !ou 'ant the user to be able to close the dialog fro" the s!ste" "enu or b! &ressing the E). (e!, !ou need a control that has the #D of IDCANCEL. When a s!ste" esca&e or close is &erfor"ed, it si"ulates &ressing the dialog button

'ith the #D IDCANCEL. #f no control in the dialog has the #D IDCANCEL, then the close co""and 'ill be ignored (and the dialog can not be closed in this 'a!). #f !ou 'ant to enable s!ste" close or E). to close a dialog, but don<t 'ant a cancel button, !ou can add a button 'ith the #D IDCANCEL to !our dialog and then re"o$e the $isible &ro&ert! in the button<s Pro&erties box. Pressing E). 'ill then acti$ate the default clic( callbac( of the cancel button and close the dialog. he gra&hics routines &ro$ided 'ith Fortran Po'er)tation set &oints, dra' lines, dra' text, change colors, and dra' sha&es such as circles, rectangles, and arcs. his section assu"es !ou ha$e read the o$er$ie' in 4sing Kuic(Win. his section uses the follo'ing ter"s+ he origin (&oint 3, 3) is the u&&erBleft corner of the screen or the client area (defined user area) of the child 'indo' being 'ritten to. he xBaxes and !B axes start at the origin. %ou can change the origin in so"e coordinate s!ste"s. he hori,ontal direction is re&resented b! the x-axis, increasing to the right. he $ertical direction is re&resented b! the y-axis, increasing do'n. )o"e gra&hics ada&ters offer a color palette that can be changed. )o"e gra&hics ada&ters (E1A and )E1A) allo' !ou to change the color that a color index refers to b! &ro$iding a color value that describes a ne' color. he color $alue indicates the "ix of red, green, and blue in a screen color. A color $alue is al'a!s an #> E1ER(9) nu"ber. he sections on dra'ing gra&hics are organi,ed as follo's+ Wor(ing 'ith 1ra&hics Modes Adding .olor 4nderstanding .oordinate )!ste"s

o dis&la! gra&hics, !ou need to set the desired gra&hics "ode using SET,INDO,CON(IG, and then call the routines needed to create the gra&hics. hese sections ex&lain each ste&+ .hec(ing the .urrent 1ra&hics Mode )etting the 1ra&hics Mode Writing a 1ra&hics Progra" Acti$ating a 1ra&hics Mode Dra'ing /ines on the )creen Dra'ing a )ine .ur$e Adding )ha&es

.all GET,INDO,CON(IG to get the child 'indo' settings. he M)F/#-.F23 "odule defines a deri$ed t!&e, "indo"con-ig, that GET,INDO,CON(IG uses as a &ara"eter+ TYPE ?i#do?1o#0ig INTEGER(3) #"'>&i> l2 INTEGER(3) #"';&i> l2 INTEGER(3) #"'! >!1ol2 ) N"'7 r o0 &i> l2 o# >Aa>i2 ) N"'7 r o0 &i> l2 o# ;Aa>i2 ) N"'7 r o0 ! >! 1ol"'#2 a8aila7l

INTEGER(3) #"'! >!ro?2 INTEGER(3) #"'1olor2 INTEGER(F) 0o#!2i* C+ARACTER(I4) !i!l INTEGER(3) 7i!2& r&i> l END TYPE ?i#do?1o#0ig

) ) ) ) )

N"'7 r o0 ! >! ro?2 a8aila7l N"'7 r o0 1olor i#d > 2 Si* o0 d 0a"l! 0o#! ?i#do? !i!l N"'7 r o0 7i!2 & r &i> l

-! default, a Kuic(Win child 'indo' is a scrollable text 'indo' ;93x9L3 &ixels, has 83 lines and L3 colu"ns, and a font si,e of Lx6;. Also b! default, a )tandard 1ra&hics 'indo' is Full )creen. %ou can change the $alues of 'indo' &ro&erties at an! ti"e 'ith )E W#>D0W.0>F#1, and retrie$e the current $alues at an! ti"e 'ith GET,INDO,CON(IG. 4se SET,INDO,CON(IG to configure the 'indo' for the &ro&erties !ou 'ant. -! assigning aJ6 $alue for numxpixels, numypixels, numtextcols, and numtextrows in the "indo"con-ig t!&e, !ou set the highest &ossible resolution a$ailable 'ith !our gra&hics dri$er. his causes )tandard 1ra&hics a&&lications to start in Full )creen "ode. #f !ou s&ecif! less than the largest gra&hics area, the a&&lication starts in a 'indo'. %ou can use A/ DE> ER to toggle bet'een Full )creen and 'indo'ed $ie's. #f !our a&&lication is a Kuic(Win a&&lication and !ou do not call SET,INDO,CON(IG, the child 'indo' defaults to a scrollable text 'indo' 'ith the di"ensions of ;93x9L3 &ixels, 83 lines, L3 colu"ns, and a font si,e of Lx6;. he nu"ber of colors de&ends on the $ideo dri$er used. #f SET,INDO,CON(IG returns '(ALSE', the $ideo dri$er does not su&&ort the o&tions s&ecified. he function then ad5usts the $alues in the 'indo'config deri$ed t!&e to ones that 'ill 'or( and are as close as &ossible to the requested configuation. %ou can then call SET,INDO,CON(IG again 'ith the ad5usted $alues, 'hich 'ill succeed. For exa"&le+ LOGICAL 2!a!"2'od TYPE (?i#do?1o#0ig) ?1 ?1.#"'>&i> l2 $ 5444 ?1.#"';&i> l2 $ B44 ?1.#"'! >!1ol2 $ A5 ?1.#"'! >!ro?2 $ A5 ?1.#"'1olor2 $ A5 ?1.!i!l $ .O& #i#g Ti!l .C ?1.0o#!2i* $ J444A444C ) 54 ( 53 2!a!"2'od $ SET,INDO,CONFIG(?1) IF (.NOT. 2!a!"2'od ) T+EN 2!a!"2'od $ SET,INDO,CONFIG(?1) #f !ou use )E W#>D0W.0>F#1, !ou should s&ecif! a $alue for each field (J6 or !our o'n nu"ber for nu"eric fields, and a . string for the title). .alling )E W#>D0W.0>F#1 'ith onl! so"e of the fields s&ecified can result in useless $alues for the other fields. /i(e "an! &rogra"s, gra&hics &rogra"s 'or( 'ell 'hen 'ritten in s"all units. 4sing discrete routines aids debugging b! isolating the functional co"&onents of the &rogra". he exa"&le &rogra" and its associated subroutines illustrate the ste&s in$ol$ed in initiali,ing, dra'ing, and closing a gra&hics &rogra". he )#>E &rogra" dra's a sine 'a$e. #ts &rocedures call "an! of the co""on gra&hics routines. he "ain &rogra", follo'ing, calls fi$e subroutines that carr! out the actual gra&hics co""ands. All of the subroutines are defined in this section.

) )

SINE.FK4 A Ill"2!ra! 2 7a2i1 gra&6i12 1o''a#d2. USE MSFLIB CALL gra&6i12'od () CALL dra?li# 2() CALL 2i# ?a8 () CALL dra?26a& 2() END

he )#>E &rogra"*s out&ut a&&ears in Figure 69.6. he )#>E routines are in the utorial subdirector! of )a"&les online as )#>E.F23., 1RAPA.F23, >EWM.F23, >EW%.F23, DRAW/#>E.F23, DRAW)#>E.F23, and DRAW)AAP.F23. he &ro5ect )#>E.MA= in the utorial subdirector! in )a"&les online 'as built as a )tandard 1ra&hics a&&lication. #f !ou call a gra&hics routine 'ithout setting a gra&hics "ode 'ith SET,INDO,CON(IG, Kuic(Win auto"aticall! sets the gra&hics "ode 'ith default $alues. )#>E selects and sets the gra&hics "ode in the subroutine gra&6i12'od , 'hich selects the highest &ossible resolution for the current $ideo dri$er. SUBROUTINE gra&6i12'od () USE MSFLIB LOGICAL 'od 2!a!"2 INTEGER(3) 'a>>% 'a>; TYPE (?i#do?1o#0ig) ';21r # COMMON 'a>>% 'a>; ) S ! 6ig6 2! r 2ol"!io# gra&6i12 'od . ';21r ';21r ';21r ';21r ';21r ';21r ';21r #.#"'>&i> l2$A5 #.#"';&i> l2$A5 #.#"'! >!1ol2$A5 #.#"'! >!ro?2$A5 #.#"'1olor2$A5 #.0o#!2i* $A5 #.!i!l $ . .C ) 7la#: #)

'od 2!a!"2$SET,INDO,CONFIG(';21r ) D ! r'i# !6 'a>i'"' di' #2io#2.

'od 2!a!"2$GET,INDO,CONFIG(';21r 'a>>$';21r #.#"'>&i> l2 A 5 'a>;$';21r #.#"';&i> l2 A 5 END

#)

Pixel coordinates start at ,ero, so, for exa"&le, a screen 'ith a resolution of ;93 hori,ontal &ixels has a "axi"u" xBcoordinate of ;82. hus, 'a>>Nthe highest a$ailable xB&ixel coordinateN"ust be 6 less than the total nu"ber of &ixels. he sa"e a&&lies to 'a>;. o re"ain inde&endent of the $ideo "ode set b! gra&6i12'od , t'o short functions con$ert an arbitrar! screen si,e of 6333x6333 &ixels to 'hate$er $ideo "ode is in effect. Fro" no' on, the &rogra" assu"es it has 6333 &ixels in each direction. o dra' the &oints on the screen, # ?> and # ?; "a& each &oint to their &h!sical (&ixel) coordinates+ ) NE,( A T6i2 0"#1!io# 0i#d2 # ? >A1oordi#a! 2.

INTEGER(3) FUNCTION # ?>( >1oord ) INTEGER(3) >1oord% 'a>>% 'a>; REAL(F) ! '&> COMMON 'a>>% 'a>; ! '&> $ 'a>> C 5444.4 ! '&> $ >1oord - ! '&> D 4.< # ?> $ ! '&> END ) ) NE,Y A T6i2 0"#1!io# 0i#d2 # ? ;A1oordi#a! 2. INTEGER(3) FUNCTION # ?;( ;1oord ) INTEGER(3) ;1oord% 'a>>% 'a>; REAL(F) ! '&; COMMON 'a>>% 'a>; ! '&; $ 'a>; C 5444.4 ! '&; $ ;1oord - ! '&; D 4.< # ?; $ ! '&; END %ou can set u& a si"ilar inde&endent coordinate s!ste" 'ith window coordinates, described in 4nderstanding .oordinate )!ste"s. )#>E next calls the subroutine dra?li# 2% 'hich dra's a rectangle around the outer edges of the screen and three hori,ontal lines that di$ide the screen into quarters. ()ee Figure 69.6.) ) ) DRA,LINES A T6i2 2"7ro"!i# 2 8 ral li# 2. SUBROUTINE dra?li# 2() USE MSFLIB E(TERNAL INTEGER(3) TYPE (>;1oord) COMMON Dra? !6 7o>. # ?>% # ?; 2!a!"2% # ?>% # ?;% 'a>>% 'a>; >; 'a>>% 'a>; dra?2 a 7o> a#d

) )

2 !2 ) !6 # ? origi# !o 4 0or > a#d <44 0or ;. S 2"7ro"!i# . ) Dra? !6 li# 2.

2!a!"2 $ RECTANGLE( LGBORDER% INT3(4)% INT3(4)% 'a>>% 'a>; ) CALL SETMIE,ORG( INT3(4)% # ?;( INT3( <44 ) )% >; ) ) T6i2 1o'' #! a0! r

CALL MOMETO( INT3(4)% INT3(4)% >; ) 2!a!"2 $ LINETO( # ?>( INT3( 5444 ))% INT3(4)) CALL SETLINESTYLE( INT3( JAABC )) CALL MOMETO( INT3(4)% # ?;( INT3( A3<4 ))% >; ) 2!a!"2 $ LINETO(# ?>( INT3( 5444 ))%# ?;( INT3( A3<4 ))) CALL SETLINESTYLE( INT3( JIIII )) CALL MOMETO(INT3(4)% # ?;( INT3( 3<4 ))% >; ) 2!a!"2 $ LINETO( # ?>( INT3( 5444 ))%# ?;( INT3( 3<4 ) ) ) END he first argu"ent to RECTANGLE is the fill flag, 'hich can be either .GBORDER or .G(ILLINTERIOR. .hoose .GBORDER if !ou 'ant a rectangle

of four lines (a border onl!, in the current line st!le), or .G(ILLINTERIOR if !ou 'ant a solid rectangle (filled in 'ith the current color and fill &attern). .hoosing the color and fill &attern is discussed in Adding .olor and Adding )ha&es. he second and third RECTANGLE argu"ents are the xB and !Bcoordinates of the u&&erBleft corner of the rectangle. he fourth and fifth argu"ents are the coordinates for the lo'erBright corner. -ecause the coordinates for the t'o corners are ( 4% 4 ) and ( 'a>>% 'a>; ), the call to RECTANGLE fra"es the entire screen. he &rogra" calls SET)IE,ORG to change the location of the $ie'&ort origin. -! resetting the origin to (3, :33) in a 6333x6333 $ie'&ort, !ou effecti$el! "a(e the $ie'&ort run fro" (3, B:33) at the to& left of the screen to (6333, :33) at the botto" right of the screen+ CALL SETMIE,ORG( INT3(4)% # ?;( INT3( <44 ) )% >; ) .hanging the coordinates illustrates the abilit! to alter the $ie'&ort coordinates to 'hate$er di"ensions !ou &refer. (Eie'&orts and the SET)IE,ORG routine are ex&lained in "ore detail in 4nderstanding .oordinate )!ste"s.) he call to SETLINEST/LE changes the line st!le fro" a solid line to a dashed line. A series of 6; bits tells the routine 'hich &attern to follo'. A H6I indicates a solid &ixel and H3I an e"&t! &ixel. herefore, 6666 6666 6666 6666 re&resents a solid line. A dashed line "ight loo( li(e 6666 6666 3333 3333 (long dashes) or 6666 3333 6666 3333 (short dashes). %ou can choose an! co"bination of ones and ,eros. An! #> E1ER(7) nu"ber in an! base is an acce&table in&ut, but binar! and hexadeci"al nu"bers are easier to en$ision as lineBst!le &atterns. #n the exa"&le, the hexadeci"al constant JAABC equals the binar! $alue 6363 6363 3366 6633. %ou could use the deci"al $alue 98:L3 5ust as effecti$el!. When dra'ing lines, first set an a&&ro&riate line st!le. hen, "o$e to 'here !ou 'ant the line to begin and call LINETO, &assing to it the &oint 'here !ou 'ant the line to end. he dra?li# 2 subroutine uses the follo'ing+ CALL SETLINESTYLE(INT3( JAABC ) ) CALL MOMETO( INT3(4)% # ?;( INT3( A3<4 ) )% >; ) d"''; $ LINETO( # ?>( INT3( 5444 ))% # ?;( INT3( A3<4 ))) MO)ETO &ositions an i"aginar! &ixel cursor at a &oint on the screen (nothing a&&ears on the screen), and LINETO dra's a line. When the &rogra" called SET)IE,ORG, it changed the $ie'&ort origin, and the initial !Baxis range of 3 to 6333 no' corres&onds to a range of B:33 to D:33. herefore, the negati$e $alue J7:3 is used as the !Bcoordinate of LINETO to dra' a line across the to& quarter of the screen, and the $alue of 7:3 is used as the !Bcoordinate to dra' a line across the botto" quarter of the screen. With the axes and fra"e in &lace, )#>E is read! to dra' the sine cur$e. he 2i# ?a8 routine calculates the x and ! &ositions for t'o c!cles and &lots the" on the screen+ ) ) ) SINE,AME A T6i2 2"7ro"!i# ?a8 . SUBROUTINE 2i# ?a8 () USE MSFLIB INTEGER(3) INTEGER(F) d"'';% # ?>% # ?;% lo1>% lo1;% i 1olor 1al1"la! 2 a#d &lo!2 a 2i#

REAL E(TERNAL ) ) PARAMETER

rad # ?>% # ?; ( PI $ B.5F5<K ) 21r #.

Cal1"la! a16 &o2i!io# a#d di2&la; i! o# !6 1olor $ J4444FF ) r d ) DO i $ 4% KKK% B rad $ ASIN( PI - i C 3<4.4 ) lo1> $ # ?>( i ) lo1; $ # ?;( INT3( rad - 3<4.4 ) ) d"''; $ SETPI(ELRGB( lo1>% lo1;% 1olor ) END DO END

SET0I+ELRGB ta(es the t'o location &ara"eters, lo1> and lo1;, and sets the &ixel at that &osition 'ith the s&ecified color $alue (red). After dra'ing the sine cur$e, )#>E calls dra?26a& 2 to &ut t'o rectangles and t'o elli&ses on the screen. he fill flag alternates bet'een .GBORDER and .G(ILLINTERIOR+ ) ) DRA,S+APES A Dra?2 !?o 7o> 2 a#d !?o lli&2 2.

) ) )

SUBROUTINE dra?26a& 2() USE MSFLIB E(TERNAL # ?>% # ?; INTEGER(3) d"'';% # ?>% # ?; Cr a! a 'a2:i#g (0ill) &a!! r#. INTEGER(5) diag'a2:(I)% 6or*'a2:(I) DATA diag'a2: C JKB% JCK% J=F% JB3% J<K% J3C% JK=% JFB C DATA 6or*'a2: C JFF% J44% JNF% JFE% J44% J44% J44% JCC C Dra? !6 r 1!a#gl 2.

H H H H ) ) ) H H H H

CALL SETLINESTYLE( INT3(JFFFF )) CALL SETFILLMAS9( diag'a2: ) d"''; $ RECTANGLE( LGBORDER%# ?>(INT3(<4))%# ?;(INT3(AB3<))% # ?>(INT3(344))%# ?;(INT3(AF3<))) d"''; $ RECTANGLE( LGFILLINTERIOR%# ?>(INT3(<<4))% # ?;(INT3(AB3<))%# ?>(INT3(N44))%# ?;(INT3(AF3<))) Dra? !6 lli&2 2.

CALL SETFILLMAS9( 6or*'a2: ) d"''; $ ELLIPSE( LGBORDER%# ?>(INT3(<4))%# ?;(INT3(B3<))% # ?>(INT3(344))%# ?;(INT3(F3<))) d"''; $ ELLIPSE( LGFILLINTERIOR%# ?>(INT3(<<4))% END *# ?;(INT3(B3<))%# ?>(INT3(N44))%# ?;(INT3(F3<)))

he call to SETLINEST/LE resets the line &attern to a solid line. 0"itting this routine causes the first rectangle to a&&ear 'ith a dashed border, because the dra?li# 2 subroutine called earlier changed the line st!le to a dashed line. ELLI0SE dra's an elli&se using &ara"eters si"ilar to those for RECTANGLE. #t, too, requires a fill flag and t'o corners of a bounding rectangle. (Figure 67.2 in .ha&ter 67, 4sing Kuic(Win, sho's ho' an elli&se uses a bounding rectangle.) (igure 12'3 Bounding Rectangle

he .G(ILLINTERIOR constant fills the sha&e 'ith the current fill &attern. o create a &attern, &ass the address of an LBb!te arra! to SET(ILLMAS4. #n dra?26a& 2, the diag'a2: arra! is initiali,ed 'ith the &attern sho'n in able 69.6. Table 12'1 Bit &attern Bit No' O ! ! o ! o o ! o ; o ! ! o ! o o ! : o o ! ! o ! o o (ill 0attern% )alue in diag5a%k 9 ! o o ! ! o ! o 8 o ! o o ! ! o ! 7 o o ! o o ! ! o 6 ! o o ! o o ! ! 3 ! ! o o x o o ! diag'a2:(5) diag'a2:(3) diag'a2:(B) diag'a2:(F) diag'a2:(<) diag'a2:(=) diag'a2:(N) diag'a2:(I) $ $ $ $ $ $ $ $ JKB JCK J=F JB3 J<K J3C JK= JFB

he Fortran Po'er)tation Kuic(Win /ibrar! su&&orts color gra&hics. he nu"ber of total a$ailable colors de&ends on the current $ideo dri$er and $ideo ada&ter !ou are using. he nu"ber of a$ailable colors !ou use de&ends on the gra&hics functions !ou choose. he different color "odes and color functions are discussed and de"onstrated in the follo'ing sections+ .olor Mixing E1A .olor Palette 4sing ext .olors

#f !ou ha$e a E1A "achine, !ou are restricted to dis&la!ing at "ost 7:; colors at a ti"e. hese 7:; colors are held in a &alette. %ou can choose the &alette colors fro" a range of 7;7,699 colors (7:;=), but onl! 7:; at a ti"e. )o"e dis&la! ada&ters ("ost )E1As) are ca&able of dis&la!ing all of the 7:;= colors and so"e (true color dis&la! ada&ters) of dis&la!ing 7:; P 7:; P 7:; @ 6;.O "illion colors. #f !ou use a &alette, !ou are restricted to the colors a$ailable in the &alette. #n order to access all colors a$ailable on !our s!ste", !ou need to s&ecif! an ex&lict RedB1reenB-lue (R1-) $alue, not a &alette index. When !ou select a color index, !ou s&ecif! one of the colors in the s!ste"*s &redefined &alette. SETCOLOR, SETB4COLOR, and SETTE+TCOLOR set the current color, bac(ground color, and text color to a &alette index. SETCOLORRGB, SETB4COLORRGB, and SETTE+TCOLORRGB set the colors to a color $alue chosen fro" the entire a$ailable range. When !ou select a color $alue, !ou s&ecif! a le$el of intensit! 'ith a range of 37:: for each of the red, green, and blue color $alues. he long integer that defines a color $alue consists of 8 b!tes (79 bits) as follo's+ MSB LSB BBBBBBBB GGGGGGGG RRRRRRRR 'here R, G, and B re&resent the bit $alues for red, green, and blue intensities. o "ix a light red (&in(), turn red all the 'a! u& and "ix in so"e green and blue+

54444444 54444444 55555555 #n hexadeci"al notation, this nu"ber equals JI4I4FF. %ou can use the function+ i $ SETCOLORRGB (JI4I4FF) to set the current color to this $alue. %ou can also &ass deci"al $alues to this function. =ee& in "ind that 6 (binar! 33333336, hex 36) re&resents a lo' color intensit! and that 7:: (binar! 66666666, hex FF) equals full color intensit!. o create &ure !ello' (633B&ercent red &lus 633B&ercent green) use this line+ i $ SETCOLORRGB( J44FFFF ) For 'hite, turn all of the colors on+ i $ SETCOLORRGB( JFFFFFF) For blac(, set all of the colors to 3+ i $ SETCOLORRGB( J444444) R1- $alues for exa"&le colors are in the follo'ing table. Table 12'3 RGB Color )alue%

ColorRGB )alueColorRGB )alue -lac( Q333333 -right White QFFFFFF Dull Red Q3333L3 -right Red Q3333FF Dull 1reen Q33L333 -right 1reen Q33FF33 Dull %ello' Q33L3L3 -right %ello' Q33FFFF Dull -lue QL33333 -right -lue QFF3333 Dull Magenta QL333L3 -right Magenta QFF33FF Dull urquoise QL3L333 -right urquoise QFFFF33 Dar( 1ra! QL3L3L3 /ight 1ra! Q.3.3.3 #f !ou ha$e a ;9=Bcolor "achine and !ou set an R1- color $alue that is not equal to one of the ;9= &reset R1- color $alues, the s!ste" a&&roxi"ates the requested R1- color to the closest a$ailable R1- $alue. he sa"e thing ha&&ens on a E1A "achine 'hen !ou set an R1- color that is not in the &alette. (%ou can re"a& !our E1A color &alette to different R1- $alues. )ee E1A .olor Palette.) >ote, ho'e$er, that though !our gra&hics are dra'n 'ith an a&&roxi"ated color, if !ou retrie$e the color 'ith GETCOLORRGB, GETB4COLORRGB, or GETTE+TCOLORRGB, the color !ou s&ecified is returned, not the actual color used. his is because the SETCOLORRGB functions do not execute an! gra&hics, the! si"&l! set the color and the a&&roxi"ation is "ade 'hen the dra'ing is "ade (b! ELLI0SE or ARC, for exa"&le). GET0I+ELRGB and GET0I+ELSRGB do return the a&&roxi"ated color actuall! used, because SET0I+ELRGB and SET0I+ELSRGB actuall! set a &ixel to a color on the screen and the a&&roxi"ation, if an!, is "ade at the ti"e the! are called. A E1A "achine is ca&able of dis&la!ing at "ost 7:; colors at a ti"e. #n Kuic(Win, E1A can dis&la! 7:; colors 'ith a resolution of 873x733 &ixels, but can dis&la! 7 or 6; colors at higher resolutions (u& to ;93x9L3 &ixels). he nu"ber of colors !ou select for !our E1A &alette de&ends on !our a&&lication,

and is set b! setting the wc.numcolors $ariable in the "indo"con-ig deri$ed t!&e to 7, 6;, or 7:; 'ith SET,INDO,CON(IG. An R1- color $alue "ust be in the &alette to be accessible to !our E1A gra&hic dis&la!s. %ou can change the default colors and custo"i,e !our color &alette b! using REMA00ALETTERGB to change a &alette color index to an! R1- color $alue. he follo'ing exa"&le re"a&s the color index 6 (default blue color) to the &ure red color $alue gi$en b! the R1- $alue Q3333FF. After this is executed, 'hate$er 'as dis&la!ed as blue 'ill a&&ear as red+ USE MSFLIB INTEGER(F) 2!a!"2 2!a!"2 $ REMAPPALETTERGB( 5% J4444FF )

) R a22ig# 1olor i#d > 5 ) !o RGB r d

REMA0ALL0ALETTERGB re"a&s one or "ore color indexes si"ultaneousl!. #ts argu"ent is an arra! of R1- color $alues that are "a&&ed into the &alette. he first color nu"ber in the arra! beco"es the ne' color associated 'ith color index 3, the second 'ith color index 6, and so on. At "ost 78; indexes can be "a&&ed, because 73 indexes are reser$ed for s!ste" use. #f !ou request an R1- color that is not in the &alette, the color selected fro" the &alette is the closest a&&roxi"ation to the R1- color requested. #f the R1- color 'as &re$iousl! &laced in the &alette 'ith REMA00ALETTERGB or REMA0ALL0ALETTERGB, then that exact R1- color is a$ailable. Re"a&&ing the &alette has no effect on ;9=Bcolor "achines, )E1A, or trueBcolor "achines, unless !ou li"it !ourself to a &alette b! using color index functions such as SETCOLOR. 0n a E1A "achine, if !ou re"a& all the colors in !our &alette and dis&la! that &alette in gra&hics, !ou cannot then re"a& and si"ultaneousl! dis&la! a second &alette. For instance, in E1A 7:;Bcolor "ode, if !ou re"a& all 7:; &alette colors and dis&la! gra&hics in one child 'indo', then o&en another child 'indo', re"a& the &alette and dis&la! gra&hics in the second child 'indo', !ou are atte"&ting to dis&la! "ore than 7:; colors at one ti"e. he "achine cannot do this, so 'hiche$er child 'indo' has the focus 'ill a&&ear correct, 'hile the one 'ithout the focus 'ill change color. Note Machines that su&&ort "ore than 7:; colors 'ill not be able to do ani"ation b! re"a&&ing the &alette. Windo's 2: and Windo's > create a logical &alette that "a&s to the $ideo hard'are &alette. 0n $ideo hard'are that su&&orts a &alette of 7:; colors or less, re"a&&ing the &alette "a&s o$er the current &alette and redra's the screen in the ne' colors. 0n large hard'are &alettes that su&&ort "ore than 7:; colors, re"a&&ing is done into the unused &ortion of the &alette. #t does not "a& o$er the current colors nor redra' the screen. hus, on "achines 'ith large &alettes ("ore than 7:; colors), the technique of changing the screen through re"a&&ing, called &alette ani"ation, cannot be used. )ee the Win32 SD !anual for "ore infor"ation. )!"bolic constants (na"es) for the default color nu"bers are su&&lied in the gra&hics "odules. he na"es are selfBdescri&ti$eC for exa"&le, the color nu"bers for blac(, !ello', and red are re&resented b! the s!"bolic constants .BLAC4, ./ELLO,, and .RED. All of the E1A dis&la! "odes o&erate 'ith an! E1A (analog) "onitor. .olors a&&ear as shades of gra! on co"&atible analog "onochro"e "onitors. SETTEXTCOLORRG! )or SETTEXTCOLOR* and SET!(COLORRG! )or SET!(COLOR* set the foreground and bac!ground colors for text output. /ll use a single

argument specifying the color value )or color index* for text displayed with O TTEXT and )RITE. +or the color index functions% colors are represented by the range 9:;8. (ndex values in the range of 8<:;8 access the same colors as those in the range of 9:8=. "ou can retrieve the current foreground and bac!ground color values with GETTEXTCOLORRG! and GET!(COLORRG! or the color indexes with GETTEXTCOLOR and GET!(COLOR. 7se SETTEXTPOSITION to move the cursor to a particular row and column. O TTEXT and )RITE print the text at the current cursor location. )e$eral different coordinate s!ste"s are su&&orted b! the Fortran Po'er)tation Kuic(Win /ibrar!. ext coordinates 'or( in ro's and colu"nsC &h!sical coordinates ser$e as an absolute reference and as a starting &lace for creating custo" 'indo' and $ie'&ort coordinates. .on$ersion routines "a(e it si"&le to con$ert bet'een different coordinate s!ste"s. he coordinate s!ste"s are de"onstrated and discussed in the follo'ing sections+ ext .oordinates 1ra&hics .oordinates Real .oordinates )a"&le Progra"

he text "odes use a coordinate s!ste" that di$ides the screen into ro's and colu"ns as sho'n in Figure 69.8. (igure 12'6 Te!t Screen Coordinate%

ext coordinates use the follo'ing con$entions+ >u"bering starts at 6. An L3Bcolu"n screen contains colu"ns 6JL3. he ro' is al'a!s listed before the colu"n.

#f the screen dis&la!s 7: ro's and L3 colu"ns (as in Figure 69.8), the ro's are nu"bered 6J7: and the colu"ns are nu"bered 6JL3. he textB&ositioning routines, such as SETTE+T0OSITION and SCROLLTE+T,INDO,, use ro' and colu"n coordinates. hree coordinate s!ste"s describe the location of &ixels on the screen+ &h!sical coordinates, $ie'&ort coordinates, and 'indo' coordinates. #n all three coordinate s!ste"s, the xBcoordinate is listed before the !Bcoordinate. he next three sections describe each coordinate s!ste" in detail+ Ph!sical .oordinates Eie'&ort .oordinates Windo' .oordinates

Ph!sical coordinates are integers that refer to &ixels in a 'indo'*s client area. -! default, nu"bering starts at 3, not 6. #f there are ;93 &ixels, the! are nu"bered 3J;82. )u&&ose !our &rogra" calls SET,INDO,CON(IG to set u& a client area containing ;93 hori,ontal &ixels and 9L3 $ertical &ixels. Each indi$idual &ixel is referred to b! its location relati$e to the xBaxis and !Baxis, as sho'n in Figure 69.9. (igure 12'2 0#7%ical Coordinate%

he u&&erBleft corner is the origin. he xB and !Bcoordinates for the origin are al'a!s (3, 3). Ph!sical coordinates refer to each &ixel directl! and are therefore integers (that is, the 'indo'*s client area cannot dis&la! a fractional &ixel). #f !ou use $ariables to refer to &ixel locations, declare the" as integers or use t!&eB con$ersion routines 'hen &assing the" to gra&hics functions. For exa"&le+ ISTATUS $ LINETO( INT3(REAL_>)% INT3(REAL_;)) #f a &rogra" uses the default di"ension of a 'indo', the viewport (dra'ing area) is equal to ;93x9L3. SET)IE,ORG changes the location of the $ie'&ort*s origin. %ou &ass it t'o integers, 'hich re&resent the x and ! &h!sical screen coordinates for the ne' origin. %ou also &ass it an !7coord t!&e that the routine fills 'ith the &h!sical coordinates of the &re$ious origin. For exa"&le, the follo'ing line "o$es the $ie'&ort origin to the &h!sical screen location (:3, 633)+ TYPE (>;1oord) origi# CALL SETMIE,ORG(INT3(<4)% INT3(544)% origi#) he effect on the screen is illustrated in Figure 69.:. (igure 12'8 Origin Coordinate% C#anged b7 SET)IE,ORG

he nu"ber of &ixels hasn*t changed, but the coordinates used to refer to the &oints ha$e changed. he xBaxis no' ranges fro" J:3 to D:L2 instead of 3 to ;82. he !Baxis no' co$ers the $alues J633 to D8O2. All gra&hics routines that use $ie'&ort coordinates are affected b! the ne' origin, including MO)ETO, LINETO, RECTANGLE, ELLI0SE, 0OL/GON, ARC, and 0IE. For exa"&le, if !ou call RECTANGLE after relocating the $ie'&ort origin and &ass it the $alues (3, 3) and (93, 93), the u&&erBleft corner of the rectangle 'ould a&&ear :3 &ixels fro" the left edge of the screen and 633 &ixels fro" the to&. #t 'ould not a&&ear in the u&&erBleft corner of the screen. SETCLI0RGN creates an in$isible rectangular area on the screen called a clipping region. %ou can dra' inside the cli&&ing region, but atte"&ts to dra' outside the region fail (nothing a&&ears outside the cli&&ing region). he default cli&&ing region occu&ies the entire screen. he Kuic(Win /ibrar! ignores an! atte"&ts to dra' outside the screen. %ou can change the cli&&ing region b! calling SETCLI0RGN. For exa"&le, su&&ose !ou entered a screen resolution of 873x733 &ixels. #f !ou dra' a diagonal line fro" (3, 3) to (862, 622), the u&&erBleft to the lo'erBright corner, the screen loo(s li(e Figure 69.;. (igure 12'9 Line Dra"n on a (ull Screen

%ou could create a cli&&ing region b! entering+

CALL SETCLIPRGN(INT3(54)% INT3(54)% INT3(B4K)% INT3(5IK)) With the cli&&ing region in effect, the sa"e LINETO co""and 'ould &ut the line sho'n in Figure 69.O on the screen. he dashed lines indicate the outer bounds of the cli&&ing region and do not actuall! &rint on the screen. (igure 12': Line Dra"n ,it#in a Cli&&ing Region

he $ie'&ort is the area of the screen dis&la!ed, 'hich "a! be onl! a &ortion of the 'indo'*s client area. Eie'&ort coordinates re&resent the &ixels 'ithin the current $ie'&ort. SET)IE,0ORT establishes a ne' $ie'&ort 'ithin the boundaries of the &h!sical client area. A standard $ie'&ort has t'o distinguishing features+ he origin of a $ie'&ort is in the u&&erBleft corner. he default cli&&ing region "atches the outer boundaries of the $ie'&ort. SET)IE,0ORT has the sa"e effect as SET)IE,ORG and SETCLI0RGN co"bined. #t s&ecifies a li"ited area of the screen in the sa"e "anner as SETCLI0RGN, then sets the $ie'&ort origin to the u&&erBleft corner of the area. Functions that refer to coordinates on the clientBarea screen and 'ithin the $ie'&ort require integer $alues. Ao'e$er, "an! a&&lications need floatingB&oint $aluesNfor frequenc!, $iscosit!, "ass, and so on. SET,INDO, allo's !ou to scale the screen to al"ost an! si,e. #n addition, 'indo'Brelated functions acce&t doubleB&recision $alues. Windo' coordinates use the current $ie'&ort as their boundaries. A 'indo' o$erla!s the current $ie'&ort. 1ra&hics dra'n at 'indo' coordinates be!ond the boundaries of the 'indo'Nthe sa"e as being outside the $ie'&ortNare cli&&ed. For exa"&le, to gra&h 67 "onths of a$erage te"&eratures on the &lanet Eenus that range fro" J:3 to D9:3, add the follo'ing line to !our &rogra"+ 2!a!"2 $ SET,INDO,(.TRUE.% 5.4D4% A<4.4D4% 53.4D4% F<4.4D4) he first argu"ent is the in$ert flag, 'hich &uts the lo'est ! $alue in the lo'erB left corner. he "ini"u" and "axi"u" x- and !Bcoordinates follo'C the deci"al &oint "ar(s the" as floatingB&oint $alues. he ne' organi,ation of the screen is sho'n in Figure 69.L. (igure 12'; ,indo" Coordinate%

Ranuar! and Dece"ber &lot on the left and right edges of the screen. #n an a&&lication li(e this, nu"bering the x-axis fro" 3.3 to 68.3 &ro$ides so"e &adding s&ace on the sides and i"&ro$es a&&earance. #f !ou next &lot a &oint 'ith SET0I+EL<, or dra' a line 'ith LINETO<,, the $alues are auto"aticall! scaled to the established 'indo'. To u%e "indo" coordinate% "it# -loating*&oint $alue% 1 )et a gra&hics "ode 'ith SET,INDO,CON(IG.

3 4se SET)IE,0ORT to create a $ie'&ort area. his ste& is not necessar! if !ou &lan to use the entire screen. 6 .reate a realBcoordinate 'indo' 'ith SET,INDO,, &assing a LOGICAL in$ert flag and four DOUBLE 0RECISION xB and !Bcoordinates for the "ini"u" and "axi"u" $alues. 2 Dra' gra&hics sha&es 'ith RECTANGLE<, and si"ilar routines. Do not confuse RECTANGLE (the $ie'&ort routine) 'ith RECTANGLE<, (the 'indo' routine for dra'ing rectangles). All 'indo' functions end 'ith an underscore ( < ) and the letter ,. RealBcoordinate gra&hics gi$e !ou flexibilit! and de$ice inde&endence. For exa"&le, !ou can fit an axis into a s"all range (such as 6:6.7: to 6:6.9:) or into a large range (J:3333.3 to DL3333.3), de&ending on the t!&e of data !ou gra&h. #n addition, b! changing the 'indo' coordinates, !ou can create the effects of ,oo"ing in or &anning across a figure. he 'indo' coordinates also "a(e !our dra'ings inde&endent of the co"&uter*s hard'are. 0ut&ut to the $ie'&ort is inde&endent of the actual screen resolution. he &rogra" REA/1.F23 sho's ho' to create "ulti&le 'indo'Bcoordinate sets, each in a se&arate $ie'&ort, on a single screen. REA/1.F23 and the t'o subroutines it calls, AREE1.F23 and 1R#D)AAP.F23, are in the utorial subdirector! in )a"&les online. ) ) REALG.FK4 A Ill"2!ra! 2 1oordi#a! gra&6i12.

) )

USE MSFLIB LOGICAL 2!a!"2'od TYPE (?i#do?1o#0ig) ';21r # COMMON ';21r # S ! !6 21r # !o !6 7 2! r 2ol"!io# a#d 'a>i'"' #"'7 r o0 a8aila7l 1olor2. ';21r #.#"'>&i> l2 $ A5 ';21r #.#"';&i> l2 $ A5 ';21r #.#"'! >!1ol2 $ A5 ';21r #.#"'! >!ro?2 $ A5 ';21r #.#"'1olor2 $ A5 ';21r #.0o#!2i* $ A5 ';21r #.!i!l $ . .C 2!a!"2'od $ SET,INDO,CONFIG(';21r #) IF(.NOT. 2!a!"2'od ) 2!a!"2'od $ SET,INDO,CONFIG(';21r #) 2!a!"2'od $ GET,INDO,CONFIG( ';21r CALL !6r gra&62() END # )

he "ain bod! of the &rogra" is $er! short. #t sets the 'indo' to the best resolution of the gra&hics dri$er (b! setting the first four fields toJ6) and the "axi"u" nu"ber of colors (b! setting #"'1olor2 toJ6). he &rogra" then calls the !6r gra&62 subroutine that dra's three gra&hs. )ee the &rogra" out&ut in Figure 69.2. (igure 12'= REALG 0rogra5 Out&ut

he grid26a& subroutine, 'hich dra's the gra&hs, uses the sa"e data in each case. Ao'e$er, the &rogra" uses three different coordinate 'indo's. he t'o $ie'&orts in the to& half are the sa"e si,e in &h!sical coordinates, but ha$e different 'indo' si,es. Each 'indo' uses different "axi"u" and "ini"u" $alues. #n all three cases, the gra&h area is t'o units 'ide. he 'indo' in the u&&erBleft corner has a range in the xBaxis of four units (9 units 'ide)C the 'indo' in the u&&erBright corner has a range in the xBaxis of six units, 'hich "a(es the gra&h on the right a&&ear s"aller. #n t'o of the three gra&hs, one of the lines goes off the edge, outside the cli&&ing region. he lines do not intrude into the other $ie'&orts, because defining a $ie'&ort creates a cli&&ing region. Finall!, the gra&h on the botto" in$erts the data 'ith res&ect to the t'o gra&hs abo$e it. he next section describes and discuss the subroutine in$o(ed b! REA/1.F23+ Dra'ing the 1ra&hs he "ain &rogra" calls !6r gra&62, 'hich &rints the three gra&hs.

SUBROUTINE !6r gra&62() USE MSFLIB INTEGER(3) 2!a!"2% 6al0>% 6al0; INTEGER(3) >?id!6% ;6 ig6!% 1ol2% ro?2 TYPE (?i#do?1o#0ig) ';21r # COMMON ';21r # CALL CLEARSCREEN( LGCLEARSCREEN ) >?id!6 $ ';21r #.#"'>&i> l2 ;6 ig6! $ ';21r #.#"';&i> l2 1ol2 $ ';21r #.#"'! >!1ol2 ro?2 $ ';21r #.#"'! >!ro?2 6al0> $ >?id!6 C 3 6al0; $ (;6 ig6! C ro?2) - ( ro?2 C 3 ) Fir2! ?i#do? CALL SETMIE,PORT( INT3(4)% INT3(4)% 6al0> A 5% 6al0; A 5 ) CALL SETTE(T,INDO,( INT3(5)% INT3(5)% ro?2 C 3% 1ol2 C 3 ) 2!a!"2 $ SET,INDO,( .FALSE.% A3.4_I% A3.4_I% 3.4_I% 3.4_I) ) T6 3.4_I #o!a!io# 'a: 2 !6 2 1o#2!a#!2 REAL(I) CALL grid26a& ( ro?2 C 3 ) 2!a!"2 $ RECTANGLE( LGBORDER%INT3(4)%INT3(4)%6al0>A5%6al0;A5) S 1o#d ?i#do? CALL SETMIE,PORT( 6al0>% INT3(4)% >?id!6 A 5% 6al0; A 5 ) CALL SETTE(T,INDO,( INT3(5)% (1ol2C3) D 5% ro?2C3% 1ol2) 2!a!"2 $ SET,INDO,( .FALSE.% AB.4D4% AB.4D4% B.4D4% B.4D4) ) T6 B.4D4 #o!a!io# 'a: 2 !6 2 1o#2!a#!2 REAL(I) CALL grid26a& ( ro?2 C 3 ) 2!a!"2 $ RECTANGLE_,( LGBORDER% AB.4_I%AB.4_I%B.4_I% B.4_I) ) T6ird ?i#do? CALL SETMIE,PORT( 4% 6al0;% >?id!6 A 5% ;6 ig6! A 5 ) CALL SETTE(T,INDO,( (ro?2 C 3 ) D 5% 5_3% ro?2% 1ol2 ) 2!a!"2 $ SET,INDO,( .TRUE.% AB.4_I% A5.<_I% 5.<_I% 5.<_I) CALL grid26a& ( INT3( (ro?2 C 3) D MOD( ro?2% INT3(3)))) 2!a!"2 $ RECTANGLE_,( LGBORDER% AB.4_I% A5.<_I% 5.<_I% 5.<_I) END

) ) )

) ) )

Although the screen is initiall! clear, !6r gra&62 "a(es sure b! calling the CLEARSCREEN routine to clear the 'indo'+ CALL CLEARSCREEN( LGCLEARSCREEN ) he .GCLEARSCREEN constant clears the entire 'indo'. 0ther o&tions include .G)IE,0ORT and .G,INDO,, 'hich clear the current $ie'&ort and the current text 'indo', res&ecti$el!. After assigning $alues to so"e $ariables, !6r gra&62 creates the first 'indo'+

CALL SETMIE,PORT( INT3(4)% INT3(4)% 6al0> A 5% 6al0; A 5) CALL SETTE(T,INDO,( INT3(5)% INT3(5)% ro?2 C 3% 1ol2 C 3) 2!a!"2 $ SET,INDO,( .FALSE.% A3.4_I% A3.4_I% 3.4_I% 3.4_I) he first instruction defines a $ie'&ort that co$ers the u&&erBleft quarter of the screen. he next instruction defines a text 'indo' 'ithin the boundaries of that border. Finall!, the third instruction creates a 'indo' 'ith both x and ! $alues ranging fro" J7.3 to 7.3. he '(ALSE' constant causes the !Baxis to increase fro" to& to botto", 'hich is the default. he _I notation identifies the constants as REA/(L). >ext, the function grid26a& inserts the grid and &lots the data, and a border is added to the 'indo'+ CALL grid26a& ( ro?2 C 3 ) 2!a!"2 $ RECTANGLE( LGBORDER%INT3(4)%INT3(4)%6al0>A5%6al0;A5) his is the standard RECTANGLE routine, 'hich ta(es coordinates relati$e to the $ie'&ort, not the 'indo'. he t'o other 'indo's are si"ilar to the first. All three call the grid26a& function, 'hich dra's a grid fro" location (J6.3, J6.3) to (6.3, 6.3). he grid a&&ears in different si,es because the coordinates in the 'indo's $ar!. he second 'indo' ranges fro" (J8.3, J8.3) to (8.3, 8.3), and the third fro" (J8.3, J 6.:) to (6.:, 6.:), so the si,es change accordingl!. he third 'indo' also contains a 'TRUE' in$ersion argu"ent. his causes the !B axis to increase fro" botto" to to&, instead of to& to botto". As a result, this gra&h a&&ears u&side do'n 'ith res&ect to the other t'o. After calling grid26a& , the &rogra" fra"es each 'indo', using a state"ent such as the follo'ing+ 2!a!"2 $ RECTANGLE_,( LGBORDER% AB.4_I% A5.<_I% 5.<_I% 5.<_I) he first argu"ent is a fill flag indicating 'hether to fill the rectangle*s interior or 5ust to dra' its outline. he re"aining argu"ents are the x and ! coordinates for the u&&erBleft corner follo'ed b! the x and ! coordinates for the lo'erBright corner. RECTANGLE ta(es integer argu"ents that refer to the $ie'&ort coordinates. RECTANGLE<, ta(es four doubleB&recision floatingB&oint $alues referring to 'indo' coordinates. he grid26a& subroutine then &lots the data on the screen. ) ) GRIDS+APE A T6i2 2"7ro"!i# &lo!2 da!a 0or REALG.FK4

SUBROUTINE grid26a& ( #"'1 ) USE MSFLIB INTEGER(3) INTEGER(F) C+ARACTER(I) REAL(I) TYPE (?i#do?1o#0ig) TYPE (?>;1oord) TYPE (r11oord) COMMON Da!a 0or !6 gra&6/ #"'1% i% 2!a!"2 rg71olor% old1olor 2!r 7a#a#a2(35)% > ';21r # ?>; 1"r&o2 ';21r #

) ) ) H H H H ) ) )

DATA 7a#a#a2 C A4.B% A4.3% A4.33F% A4.5% A4.<% 4.35% 3.K% 4.B% 4.3% 4.4% A4.II<% A5.5% A4.B% A4.3%

4.445% 4.44<% 4.5F% 4.4% A4.K% A4.5B% 4.B5 C Pri#! 1olor d ?ord2 o# !6 21r #. #.#"'1olor2A5

) ) )

IF(';21r #.#"'1olor2 .LT. #"'1) #"'1 $ ';21r DO i $ 5% #"'1 CALL SETTE(TPOSITION( i% INT3(3)% 1"r&o2 ) rg71olor $ 53--i A5 rg71olor $ MODULO(rg71olor% JFFFFFF) old1olor $ SETTE(TCOLORRGB( rg71olor ) ,RITE ( 2!r% '(II)' ) rg71olor CALL OUTTE(T( 'Color ' CC 2!r ) END DO Dra? a do"7l r 1!a#gl aro"#d !6 gra&6.

old1olor $ SETCOLORRGB( J4444FF ) ) 0"ll r d 2!a!"2 $ RECTANGLE_,( LGBORDER% A5.44_I% A5.44_I% 5.44_I%5.44_I) ) 1o#2!a#!2 'ad REAL(I) 7; a&& #di#g _I 2!a!"2 $ RECTANGLE_,( LGBORDER% A5.43_I% A5.43_I% 5.43_I% 5.43_I) ) ) Plo! !6 &oi#!2. ) > $ A4.K4 DO i $ 5% 5K old1olor $ SETCOLORRGB( J44FF44 ) ) 0"ll gr # CALL MOMETO_,( >% A5.4_I% ?>; ) 2!a!"2 $ LINETO_,( >% 5.4_I ) CALL MOMETO_,( A5.4_I% >% ?>; ) 2!a!"2 $ LINETO_,( 5.4_I% > ) old1olor $ SETCOLORRGB( JFF4444 ) ) 0"ll 7l" CALL MOMETO_,( > A 4.5_I% 7a#a#a2( i )% ?>; ) 2!a!"2 $ LINETO_,( >% 7a#a#a2( i D 5 ) ) > $ > D 4.5 END DO CALL MOMETO_,( 4.K_I% 7a#a#a2( i )% ?>; ) 2!a!"2 $ LINETO_,( 5.4_I% 7a#a#a2( i D 5 ) ) old1olor $ SETCOLORRGB( J44FFFF ) ) ; llo? END he routine na"es that end 'ith <, 'or( in the sa"e 'a! as their $ie'&ort equi$alents, exce&t that !ou &ass doubleB&recision floatingB&oint $alues instead of integers. For exa"&le, !ou &ass #> E1ER(7) to LINETO, but REA/(L) $alues to LINETO<,.

After !ou create $arious gra&hics ele"ents, !ou can use the fontBoriented routines to &olish the a&&earance of titles, headings, co""ents, or labels. 4sing Fonts fro" the 1ra&hics /ibrar! describes in "ore detail ho' to &rint text in $arious fonts 'ith font routines. he Microsoft Fortran Po'er)tation 1ra&hics /ibrar! includes routines that &rint text in $arious si,es and t!&e st!les. hese routines &ro$ide control o$er the a&&earance of !our text and add $isual interest to !our screen dis&la!s. his section assu"es !ou ha$e read Dra'ing 1ra&hics Ele"ents and that !ou understand the general ter"inolog! it introduces. %ou should also be fa"iliar 'ith the basic &ro&erties of both the SET,INDO,CON(IG and MO)ETO routines. Also, re"e"ber that gra&hics &rogra"s containing gra&hics routines "ust be built as Kuic(Win or )tandard 1ra&hics a&&lications. he &ro5ect t!&e is set in Microsoft De$elo&er )tudio 'hen !ou select >e' fro" the File "enu, then Pro5ect Wor()&ace, then Kuic(Win or )tandard 1ra&hics fro" the Pro5ect !&e dro&Bdo'n list. 1ra&hics a&&lications can also be built 'ith the FMW or FMWs co"&iler o&tion. Font t!&es and the use of fonts are described in these sections+ A$ailable !&efaces 4sing Fonts )A0WF0> .F23 Exa"&le

/ font is a set of text characters of a particular si'e and style. / typeface )or type style* refers to the style of the displayed text>/rial% for example% or $imes 4ew Roman. Type size measures the screen area occupied by individual characters. $he term comes from the printer&s lexicon% but uses screen pixels as the unit of measure rather than the traditional points. +or example% ? ourier 8@ AB denotes the ourier typeface% with each character occupying a screen area of 8@ vertical pixels by A hori'ontal pixels. $he word ?font%B therefore% implies both a typeface and a type si'e. $he Cuic!-in 0ibrary&s font routines use all -indows operating system installed fonts. $he first type of font used is a bitmap )or raster-map* font. 5itmap fonts have each character in a binary data map. Each bit in the map corresponds to a screen pixel. (f the bit eDuals 8% its associated pixel is set to the current screen color. 5it values of 9 appear in the current bac!ground color. $he second type of font is called a $rue$ype font. Some screen fonts loo! different on a printer% but $rue$ype fonts print exactly as they appear on the screen. $rue$ype fonts may be bitmaps or soft fonts )fonts that are downloaded to your printer before printing*% depending on the capabilities of your printer. $rue$ype fonts are scalable and can be si'ed to any height. (t is recommended that you use $rue$ype fonts in your graphics programs. Each type of font has advantages and disadvantages. 5itmapped characters appear smoother on the screen because of the predetermined pixel mapping. However% they cannot be scaled. "ou can scale $rue$ype text to any si'e% but the characters sometimes don&t loo! Duite as solid as the bitmapped characters on the screen. 7sually this screen effect is hardly noticable% and when printed% $rue$ype fonts are as smooth or smoother than bitmapped fonts. $he bitmapped typefaces come in preset si'es measured in pixels. $he exact si'e of any font depends on screen resolution and display type. Kuic(Win*s font routines can use all the Windo's o&erating s!ste" installed fonts. o use fonts in !our &rogra", !ou "ust+

6. #nitiali,e the fonts. 7. )elect a current font fro" the initiali,ed fonts. 8. Dis&la! font text 'ith OUTGTE+T. )ee the follo'ing sections+ #nitiali,ing Fonts )etting the Font and Dis&la!ing ext

A &rogra" that uses fonts "ust first organi,e the fonts into a list in "e"or!, a &rocess called initiali,ing. he list gi$es the co"&uter infor"ation about the a$ailable fonts. #nitiali,e the fonts b! calling the INITIALI>E(ONTS routine. USE MSFLIB INTEGER(3) #"'0o#!2 #"'0o#!2 $ INITIALIOEFONTS() #f the co"&uter successfull! initiali,es one or "ore fonts, INITIALI>E(ONTS returns the nu"ber of fonts initiali,ed. #f the function fails, it returns a negati$e error code. -efore a &rogra" can dis&la! text in a &articular font, it "ust (no' 'hich of the initiali,ed fonts to use. SET(ONT "a(es one of the initiali,ed fonts the current (or Hacti$eI) font. SET(ONT has the follo'ing s!ntax+ SET(ONT(options) he function*s argu"ent consists of letter codes that describe the desired font+ t!&eface, character height and 'eight in &ixels, fixed or &ro&ortional, and attributes such as bold or italic. hese o&tions are discussed in detail in the SET(ONT entr! in the "eference. For exa"&le+ USE MSFLIB INTEGER(3) i#d >% #"'0o#!2 #"'0o#!2 $ INITIALIOEFONTS () i#d > $ SETFONT('!''Co!!ag ''65I?54') sets the t!&eface to .ottage, the character height to 6L &ixels and the 'idth to 63 &ixels. he follo'ing exa"&le sets the t!&eface to Arial, the character height to 69, 'ith &ro&ortional s&acing and italics (the &i codes)+ i#d > $ SETFONT('!''Arial''65F&i') #f SET(ONT successfull! sets the font, it returns the font*s index nu"ber. #f the function fails, it returns a negati$e integer. .all GRSTATUS to find the source of the &roble"C its return $alue indicates 'h! the function failed. #f !ou call SET(ONT before initiali,ing fonts, a runBti"e error occurs. SET(ONT u&dates the font infor"ation 'hen it is used to select a font. GET(ONTIN(O can be used to obtain infor"ation about the currentl! selected font. SET(ONT sets the user fields in the -ontin-o T/0E (a T/0E defined in M)F/#-.M0D), and GET(ONTIN(O returns the userBselected $alues. he follo'ing user fields are contained in -ontin-o+ TYPE 0o#!i#0o INTEGER(3) INTEGER(3) !;& a21 #! ) 5 $ !r" !;& % 4 $ 7i! 'a& ) Pi> di2! 0ro' !o& !o 7a2 li#

INTEGER(3) INTEGER(3) INTEGER(3) C+ARACTER(B3) END TYPE 0o#!i#0o

&i>?id!6 &i>6 ig6! a8g?id!6 0a1 #a'

) ) ) )

C6ara1! r ?id!6 i# &i> l2% 4$&ro& C6ara1! r 6 ig6! i# &i> l2 A8 rag 16ara1! r ?id!6 i# &i> l2 Fo#! #a'

o find the &ara"eters of the current font, call GET(ONTIN(O. For exa"&le+ USE MSFLIB TYPE (0o#!i#0o) 0o#! INTEGER(3) i% #"'0o#!2 #"'0o#!2 $ INITIALIOEFONTS() i $ SETFONT('!''Arial') i $ GETFONTINFO(0o#!) ,RITE (-%-) 0o#!.a8g?id!6% 0o#!.&i>6 ig6!% 0o#!.&i>?id!6 After !ou initiali,e the fonts and "a(e one the acti$e font, !ou can dis&la! the text on the screen. To di%&la7 te!t on t#e %creen a-ter %electing a -ont 1 )elect a starting &osition for the text 'ith MO)ETO. 3 0&tionall!, set a text dis&la! angle 'ith SETGTE+TROTATION. 6 )end the text to the screen (in the current font) 'ith OUTGTE+T. MO)ETO "o$es the current gra&hics &oint to the &ixel coordinates &assed to it 'hen it is in$o(ed. his beco"es the starting &osition of the u&&erBleft corner of the first character in the text. SETGTE+TROTATION can set the text*s orientation in oneBdegree incre"ents. he &rogra" )A0WF0> .F23 in the utorial subdirector! in )a"&les online dis&la!s text in the fonts a$ailable on !our s!ste". (0nce the screen fills 'ith text, &ress E> ER to dis&la! the next screen.) An abbre$iated $ersion follo's. )A0WF0> calls SET(ONT to s&ecif! the t!&eface. MO)ETO then establishes the starting &oint for each text string. he &rogra" sends a "essage of sa"&le text to the screen for each font initiali,ed+ ) A77r 8ia! d 8 r2io# o0 S+O,FONT.FK4. USE MSFLIB INTEGER(3) TYPE (>;1oord) TYPE (0o#!i#0o) C+ARACTER(=) ) gr2!a!% #"'0o#!2%i#d>% 1"rr_6 ig6! >;! 0 2!r ) < 16ar2 0or 0o#! #"' ) ('a>. i2 B3N=N)% 5 0or '#'

I#i!iali*a!io#. #"'0o#!2$INITIALIOEFONTS() IF (#"'0o#!2.LE.4) PRINT -%.INITIALIOEFONTS rror. IF (GRSTATUS().NE.LGRO9) PRINT -%'INITIALIOEFONTS GRSTATUS rror.' CALL MOMETO (4%4%>;!) gr2!a!$SETCOLORRGB(JFF4444) gr2!a!$FLOODFILLRGB(4% 4% J44FF44) gr2!a!$SETCOLORRGB(4) G ! d 0a"l! 0o#! 6 ig6! 0or 1o'&ari2o# la! r. gr2!a! $ SETFONT('#5') gr2!a! $ GETFONTINFO(0) 1"rr_6 ig6! $ 0.&i>6 ig6! Do# i#i!iali*i#g% 2!ar! di2&la;i#g 0o#!2. DO i#d>$5%#"'0o#!2 ,RITE(2!r%54)i#d>

gr2!a!$SETFONT(2!r) IF (gr2!a!.LT.5) T+EN CALL OUTGTE(T('S !Fo#! rror.') ELSE gr2!a!$GETFONTINFO(0) gr2!a!$SETFONT('#5') CALL OUTGTE(T(0.0a1 #a' (/l #_!ri'(0.0a1 #a' ))) CALL OUTGTE(T(' ') ) Di2&la; 0o#!. gr2!a!$SETFONT(2!r) CALL OUTGTE(T('ABCDEFGa71d 0g53BF<)PJLQ') END IF ) Go !o # >! li# . IF (0.&i>6 ig6! .GT. 1"rr_6 ig6!) 1"rr_6 ig6!$0.&i>6 ig6! CALL GETCURRENTPOSITION(>;!) CALL MOMETO(4%INT3(>;!.;1oordD1"rr_6 ig6!)%>;!) END DO 54 FORMAT ('#'%I<.<) END

Você também pode gostar