Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Multiple Column List Box

tomballard
Beginner
1,288 Views
Does anyone have experience with setting up a multiple column list box within a dialog box. I would like to be able to scroll all the rows of the list box with a single scroll bar.

Also, has anyone tried to incorporate an Excel spread sheet into a dialog box? This would be a superior alternative to a multi-column list box since the cells could then contain formulas, etc.
0 Kudos
14 Replies
Jugoslav_Dujic
Valued Contributor II
1,288 Views
Tom, I replied to a similar question recently here (re multi-column), but I'm in a hurry now to -- search for LB_SETTABSTOPS.

Jugoslav
0 Kudos
Intel_C_Intel
Employee
1,288 Views
Recently I wrote it by means of width of the column this way:
Select Case (id)
Case (IDC_SPIN_COLUMN)
lret = DlgGet (dlg,IDC_SPIN_COLUMN,Number_of_Column)
Write (Snumber_of_Column,'(I4)') Number_of_Column
lret = DlgSet (dlg,IDC_EDIT_COLUMN,TRIM(ADJUSTL(Snumber_of_Column)))
Case (IDC_EDIT_COLUMN)
lret = DlgGet (dlg,IDC_EDIT_COLUMN,Snumber_of_Column)
Read (Snumber_of_Column,*,Iostat = Iret) Number_of_Column
if (Iret.eq.0) then
Number_of_Column = MIN0(Number_of_Column,11)
Write (Snumber_of_Column,'(I4)') Number_of_Column
lret = DlgSet (dlg,IDC_EDIT_COLUMN,TRIM(ADJUSTL(Snumber_of_Column)))
lret = DlgSet (dlg,IDC_SPIN_COLUMN,Number_of_Column,DLG_POSITION)
end if
end select

! Set the Width of Column within ListBox
Width_of_Column = INT4(300 / Number_of_Column)
lret = DlgSendCtrlMessage (Dlg,IDC_LIST_LIST, &
LB_SETCOLUMNWIDTH,Width_of_Column,0)
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,288 Views
Let me clarify -- "Multi-column" list boxes (LBS_MULTICOLUMN+LB_SETCOLUMNWIDTH) are not what most people expect. A multi-column list-box just wraps when the bottom is reached, i.e. it looks like File Open dialog in default ("List" mode) and it cannot even have vertical scrollbar. On the other hand, people usually want something like Explorer in "Details" view -- several spreadsheet-like columns with different items in each columns. That can be most closely emulated with LBS_USETABSTOPS+LB_SETTABSTOPS list boxes; not perfect but close.

Jugoslav
0 Kudos
tomballard
Beginner
1,288 Views
Thanks for the help jugoslavdujic. Have you any experience with actually using an Excel spread sheet in a dialog box? We do a lot of FE work here and the spread sheet has become a necessary tool for many classes types of modeling. For instance, it would be nice to have the capability of generating coordinates as a calculated values of the previous rows, etc.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,288 Views
No, I don't. You could probably insert it as an ActiveX control, but that's beyond my knowledge. Also, there are bunch of grid controls on the net (see e.g. BabyGrid which is free and has simple API interface) but most don't have spreadsheet functionality -- they just provide grid... and some are quite expen$ive.

Jugoslav
0 Kudos
Intel_C_Intel
Employee
1,288 Views
BabyGrid looks very interesting. Can anyone provide a sample of how to use it from Fortran?

Thanks,

Gabriel
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,288 Views
Frankly, I just downloaded it, skimmed over documentation, concluded it might be interesting and "returned it to the shelf". So, I can offer only general guidelines.

In resource editor, insert a "custom control". In its properties, type class name ("BABYGRID"). I don't see any specific styles so the default 0x50010000 (=WS_VISIBLE|WS_CHILD|WS_TABSTOP) should be OK.

Somewhere at your app startup, call RegisterGridClass.

To add rows, columns & items, well, read the documentation. Usually, it will be in form (SendMessage(GetDlgItem(hDlg, IDC_GRID), BGM_XXX, x, y)). The dialog will be most easily handled with Win32 code (DialogBox+DialogProc). It's not so complicated as it may look at the first glance, although it is a bit less elegant than DFLOGM. See e.g. DF98SAMPLESADVANCEDWIN32OWNCOMBOB sample. Probably a BabyGrid could be tweaked into a DFLOGM-handled dialog as well, but you'll end up with the same or bigger amount of code -- you'll have to use SendMessage for all grid handling anyway, and handle BGN_ messages separately.

Jugoslav
0 Kudos
tomballard
Beginner
1,288 Views
I downloaded the project file for BabyGrid and opened it up in Developer Studio. The resource editor gives me an error: windows.h not found... I realize that windows.h is the standard windows header file and I also realize that it is now comprised of several other header files. Can someone direct me to a copy of windows.h so I can at least open the resource editor for the BabyGrid project.
0 Kudos
Steven_L_Intel1
Employee
1,288 Views
Should be in Program FilesMicrosoft Visual StudioVC98INCLUDE CVF does supply this, but may not add the VC98INCLUDE folder to the Tools..Options..Directories..Include Files list.

Steve
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,288 Views
You'll need BabyGrid.h translated to Fortran anyway. I've spent few minutes to do it for you & test it (just to display it). Attached (I didn't include the .lib so that I don't violate any license agreement).

Jugoslav
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,288 Views
P.S. I forgot "use BabyGridTy" within module BabyGrid in BabyGridM.f90. Not essential, but more convenient to use.
0 Kudos
david_jones
Beginner
1,288 Views
... you seem to have attached the wrong file.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,288 Views
Really? I see... that's very good, because the one I meant to attach was full of s**t :-). Well, here's finally a working version based on last BabyGrid (it's mixed-language so you'll need VC++ to compile it, but you can insert the .lib if you have it).

Jugoslav
0 Kudos
tomballard
Beginner
1,288 Views
Thank jugoslavdujic. Everything seems to be working now.


0 Kudos
Reply