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

Create List-View Control?

intelandmicrosoft
1,268 Views
Could someone give me an example of how to create a list-view control? Here is what I have so far which does not work. This function is suppose to create a list view control and return it's handle. I plan on putting it inWM_CREATE.
INTEGER FUNCTION CreateListView(hWnd)
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_WinMain@16' :: WinMain
USE IFWIN
INTEGER hWnd
INTEGERiRet

type (T_RECT) rcl
type (T_INITCOMMONCONTROLSEX) iccex

iccex%dwSize = sizeof(iccex)
iccex%dwICC = ICC_LISTVIEW_CLASSES
iRet= InitCommonControlsEx(iccex)
iRet = GetClientRect(hWnd, rcl)

CreateListView= CreateWindow (WC_LISTVIEW, &
"", &
IOR(IOR(IOR(WS_VISIBLE, LVS_REPORT), &
LVS_EDITLABELS), WS_CHILD), &
0, &
0, &
rcl%right - rcl%left, &
rcl%bottom - rcl%top, &
hWnd, &
NULL, &
ghInstance, &
NULL)
END FUNCTION
0 Kudos
6 Replies
Jugoslav_Dujic
Valued Contributor II
1,268 Views
a) Definition of WC_LISTVIEW is defect in DFWINTY.f90 -- it's missing terminating char(0). Instead, use "SysListView32"C.
b) Your DEC$ATTRIBUTES line is spurious (but it's not related to the list view problem)
Otherwise, I don't see anything obviously wrong -- if it still doesn't work, what's the return value of GetLastError?
Jugoslav
0 Kudos
Steven_L_Intel1
Employee
1,268 Views
I filed a bug report on this problem. I'm astonished nobody's noticed this before.... It looks as if all the character constants in DFWINTY (and IFWINTY) are like this.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,268 Views
FWIW, these constantsweremissing for quite some time (as far as I recall, they may have been introduced in 6.5 or so), so I got used to spelling them out as literals.I don't recall what's in N. Lawrence's book though.
Jugoslav
0 Kudos
intelandmicrosoft
1,268 Views
I figured out my problem is the comctrl32 dll. It's not loading up properly before I try to create the List-View Control.
TYPE (T_INITCOMMONCONTROLSEX) iccex
iccex%dwSize = sizeof(iccex)
iccex%dwICC = ICC_LISTVIEW_CLASSES
NOW comctl32.f90 lists two ways to preloading the necassary com dll
1) SUBROUTINE InitCommonControls
2) FUNCTION InitCommonControlsEx
I can't get either subroutine or function to work? It will say unresolved external _InitCommonControls?
So i try the following and get it to compile subing in random numbers for ??? until it compiles. By the way is there a better way to get the ??? number besides random guessing?I'm guessing it hase something to do with the size of the variables passed in and returned?
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_InitCommonControls@???' :: InitCommonControls
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_InitCommonControlsEx@???' :: InitCommonControlsEx
Now when it does finally compile, the program crashes right away and still says com module not found, but when I compile I dolink against the com dll by adding /link ComCtl32.Lib to ifort?
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,268 Views
Yes, you have to add "comctl32.lib" to the list in Project/Settings/Link.
But you should not mess with "subing in random numbers for ??? until it compiles." Where did you substitute "???" ? If you USEd DFWIN or COMCTL32, you have included the correct prototype for InitCommonControls* -- youonly had to add the correct library.
For your information, the numberbehind @ is, generally, equalto 4*number of arguments. Thus, itis _InitCommonControls@0 and _InitCommonControlsEx@4. If there are string arguments which don't have !DEC$ATTRIBUTES REFERENCE attribute, thereis anadditional hidden argument per string argument. DECORATE attribute in the interfaceblock tells the compiler to calculate the decoration automatically (take a look yourself e.g. at ...DF98IncludeUSER32.f90).
Jugoslav
0 Kudos
Steven_L_Intel1
Employee
1,268 Views
The constants will get their trailing NULs added in a future update - possibly the next one but if not, the one after that.
0 Kudos
Reply