Software Archive
Read-only legacy content
17061 Discussions

Dialog Combo Box - Setting Initial Value from Drop List

wiland
Beginner
916 Views
I have a Dialog Combo Box (type Drop List) that I am using to set a color preference. The listbox items are entered under the Data tab in Combo Box properties. I use the statement logstatus=dlgset(dlg,iprefc,color) to set the initial color. While the color does seem to be set to the correct color (based on my testing), the combo box appears blank when it first appears. I cannot get this dlgset command to initialize the box when it first appears. It is always blank. I can create a callback subroutine with the same dlgset command which will cause the color to appear in the combo box.

Is there some reason the dlgset command will not initialize the combo box (I am using version 6.0.B3 of the compiler)?

I tried to send an a sample test program to vf-support@compaq.com but it was returned as undeliverable. Is this address no longer valid?

Thank you,
Bruce Wiland
0 Kudos
9 Replies
Steven_L_Intel1
Employee
916 Views
The address is still valid - please try again. If it fails, please send the complete bounce error to fortran@compaq.com.

I would suggest upgrading to at least 6.1A, if not 6.5 - 6.0B3 is quite old at this point.

Steve
0 Kudos
Jugoslav_Dujic
Valued Contributor II
916 Views
As far as I know, versions of DFLOGM (more precisely, dflogm.lib) up from 6.0 do recognize items as entered in "Data" tab, but do not handle them correctly; for example, DLG_NUMITEMS property is not correctly set (it will return 0 for DlgGet) and I'm not sure about whether the DlgSet as in your example would work correctly. I don't know what's the situation in newer versions. To be on the safe side, it's better to fill in the combo programmatically. I usually do it by declaring a CHARACTER, PARAMETER array:

 
 
CHARACTER(*), PARAMETER:: sItem(4)=(/ & 
'Black', & 
'Blue ', & 
'Red  ', & 
'Green' /) 
 
iSt=DlgSet(Dlg, IDC_COMBO_COLOR, 4, DLG_NUMITEMS) 
DO i=1,4 
    iSt=DlgSet(Dlg, IDC_COMBO_COLOR, sItem(i), i) 
END DO 


Jugoslav
0 Kudos
wiland
Beginner
916 Views
Steve,

I had 6.1A but had never upgraded to it. I just applied the upgrade to 6.1A and the same problem exists. Can you address the issue that Jugoslav Dujic makes in his reply (that items in the Data tab are not handled correctly)? Would this problem be fixed in 6.5. I would prefer not to spend the money for the upgrade right now if the problem is not corrected.

Bruce
0 Kudos
Steven_L_Intel1
Employee
916 Views
I see you successfully sent us your problem report - I forwarded it to our DFLOGM expert (Leo) for response.

I'll point out that the cost of upgrading will go up after July 31, when the $149 Programmer's Paradise offer expires.

Steve
0 Kudos
Intel_C_Intel
Employee
916 Views
Hi Bruce,

The problem appears to still be there in our current code. I will investigate it further. For now, I have a workaround for you. Add the following line before your call to DlgModal:

logstatus=dlgsetsub(dlg,ipref,setdefcol) !sets color to default when called

This will cause "setdefcol" to be called immediately before the dialog box is displayed. It is a DLGINIT callback. Why would this work and the DlgSet a few statements before not work? The reason is that the actual dialog box, as far as Windows is concerned, is not created until the call to DlgModal. Prior to that, the Dialog procedures save the information that you specify in DlgSet calls for use when the dialog box is created. In the DLGINIT callback, the dialog box exists and settings that you make in DlgSet calls are sent to Windows right away. The problem probably has to do with the sequence of Windows API calls made by the Dialog procedures, e.g., it is setting the default, but then a later call is wiping it out.

Leo
0 Kudos
wiland
Beginner
916 Views
Leo,

Your workaround works, but only if I want to initialize to the default each time. I want to initialize to the last chosen preference. Setting the values externally seems to work properly as Jugoslav suggested even though setting the values in the Data tab does not. I created a subroutine as follows:

    subroutine definecolors(dlg,inum)  
    use dflogm  
    logical logstatus  
    INCLUDE 'resource.FD'  
    TYPE (dialog) dlg  
    integer(4) i4status  
    logstatus=dlgset(dlg,iprefc,15,DLG_NUMITEMS)    
    logstatus=dlgset(dlg,inum,'black', 1)    
    logstatus=dlgset(dlg,inum,'bright blue', 2)    
    logstatus=dlgset(dlg,inum,'bright cyan', 3)    
    logstatus=dlgset(dlg,inum,'bright green', 4)    
    logstatus=dlgset(dlg,inum,'bright magenta', 5)    
    logstatus=dlgset(dlg,inum,'bright red', 6)    
    logstatus=dlgset(dlg,inum,'bright yellow', 7)    
    logstatus=dlgset(dlg,inum,'dark blue', 8)    
    logstatus=dlgset(dlg,inum,'dark cyan', 9)    
    logstatus=dlgset(dlg,inum,'dark green', 10)    
    logstatus=dlgset(dlg,inum,'dark magenta', 11)    
    logstatus=dlgset(dlg,inum,'dark red', 12)    
    logstatus=dlgset(dlg,inum,'dark yellow', 13)    
    logstatus=dlgset(dlg,inum,'light gray', 14)    
    logstatus=dlgset(dlg,inum,'dark gray', 15)    
    return  
    end  


I then put a call to this subroutine before the line that sets the preferred color:

    call definecolors(dlg,iprefc)  
    logstatus=dlgset(dlg,iprefc,color) !sets preferred color  


The example I sent you is actually an abbreviated version of what is in the application I am programming. There are a number of other colors I need to set, so I call this definecolors subroutine for each drop down list:

    call definecolors(dlg,iprefc)  
    logstatus=dlgset(dlg,iprefc,color) !sets preferred color  
    call definecolors(dlg,iprefc2)  
    logstatus=dlgset(dlg,iprefc2,color2) !sets preferred color 2  
    call definecolors(dlg,iprefc3)  
    logstatus=dlgset(dlg,iprefc3,color3) !sets preferred color 3  
    etc.  


However, it would be nice if the entering the data in the Combo Box "Data" tab worked properly.

Thanks,

Bruce W.
0 Kudos
david_jones
Beginner
916 Views
Have you tried using the optional fourth argument of dlgset to get more control of what is going on? I have been using the following calls successfully for some time now
RET = DLGSET(DLG,IDC_COMBO1,IX,DLG_STATE)
RET = DLGSET(DLG,IDC_COMBO2,IY,DLG_STATE)
RET = DLGSET(DLG,IDC_COMBO3,I3,DLG_STATE)
RET = DLGSET(DLG,IDC_COMBO4,I4,DLG_STATE)
This form was essentially copied from some of the on-line help files I think.

David Jones
0 Kudos
wiland
Beginner
916 Views
David,

Yes, I have tried using the optional fourth argument (dlg_state). It did not help. The problem is with entering the listbox items under the "Data" tab in the Combo Box properties. As pointed out in previous discussion, if the items are entered programmatically, everything seems to work. There is apparently a problem with using the "Data" tab to enter the list items. Compaq technical support is aware of the problem and is looking into it.

Bruce
0 Kudos
david_jones
Beginner
916 Views
Bruce,
this is strange, since I seem to be doing exactly what you want to do; ie. entering the options via the data tab. Perhaps we have different option set under properties. The items I have in a checked condition are:

General: visible, tab stop

Styles: sort, vertical scroll with Type=drop list and Owner draw=No

I don't recall having to do anything special to get this to work. The date on the subroutine file is June 2000, so it was working with whatever version was extant then and even earlier.
0 Kudos
Reply