- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following code compiles at the command line "ifort /winapp fortran.f90 /link ComCtl32.Lib" without any errors at all. A grey bar appears at the top of the window as my list-control but I can'tfigure out how toaddtext to the column or even if the view-list control initialized properly. I believe the problem is somewhere in the InitListViewColumns FUNCTION. Maybe I am passing an address when it expects a value or vice versa. I can't figure it out. I'm not totally sure if the InitListViewColumns is even the problem. Please Help. I've been at this for days.
CODE THAT DOES COMPILE WITHOUT ERRORS AND KINDA WORKS!:
!****************************************************************
INTEGER FUNCTION WinMain( hInstance, hPrevInstance, lpszCmdLine, nCmdShow )
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_WinMain@16' :: WinMain
USE IFWIN
INTEGER FUNCTION WinMain( hInstance, hPrevInstance, lpszCmdLine, nCmdShow )
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_WinMain@16' :: WinMain
USE IFWIN
INTEGER hInstance, hPrevInstance, nCmdShow, lpszCmdLine
type (T_WNDCLASS) wc
type (T_MSG) mesg
type (T_MSG) mesg
INTEGER hWnd, iRet, ghInstance
COMMON /globdata/ ghInstance
COMMON /globdata/ ghInstance
!/********************** Prototypes **************************/
INTERFACE
INTEGER FUNCTION MainWndProc ( hwnd, mesg, wParam, longParam )
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_MainWndProc@16' :: MainWndProc
INTEGER hwnd, mesg, wParam, longParam
END FUNCTION
END INTERFACE
!/******************** END Prototypes ************************/
INTERFACE
INTEGER FUNCTION MainWndProc ( hwnd, mesg, wParam, longParam )
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_MainWndProc@16' :: MainWndProc
INTEGER hwnd, mesg, wParam, longParam
END FUNCTION
END INTERFACE
!/******************** END Prototypes ************************/
IF( hPrevInstance .eq. 0 ) THEN
wc%style = IOR ( CS_VREDRAW, CS_HREDRAW )
wc%lpfnWndProc = LOC ( MainWndProc )
wc%cbClsExtra = 0
wc%cbWndExtra = 0
wc%hInstance = hInstance
wc%hIcon = LoadIcon ( hInstance, IDI_APPLICATION)
wc%hCursor = LoadCursor( NULL, IDC_ARROW )
wc%hbrBackground = GetStockObject ( WHITE_BRUSH )
wc%lpszMenuName = 0
wc%lpszClassName = LOC ( "Generic_Class_Name" )
wc%lpfnWndProc = LOC ( MainWndProc )
wc%cbClsExtra = 0
wc%cbWndExtra = 0
wc%hInstance = hInstance
wc%hIcon = LoadIcon ( hInstance, IDI_APPLICATION)
wc%hCursor = LoadCursor( NULL, IDC_ARROW )
wc%hbrBackground = GetStockObject ( WHITE_BRUSH )
wc%lpszMenuName = 0
wc%lpszClassName = LOC ( "Generic_Class_Name" )
iRet = RegisterClass( wc )
END IF
END IF
ghInstance = hInstance
hWnd = CreateWindowEx ( 0, &
"Generic_Class_Name", &
"Generic_App_Name", &
INT(WS_OVERLAPPEDWINDOW), &
CW_USEDEFAULT, &
CW_USEDEFAULT, &
CW_USEDEFAULT, &
CW_USEDEFAULT, &
NULL, &
NULL, &
ghInstance, &
NULL &
)
"Generic_Class_Name", &
"Generic_App_Name", &
INT(WS_OVERLAPPEDWINDOW), &
CW_USEDEFAULT, &
CW_USEDEFAULT, &
CW_USEDEFAULT, &
CW_USEDEFAULT, &
NULL, &
NULL, &
ghInstance, &
NULL &
)
iRet = ShowWindow (hWnd, SW_SHOWNORMAL)
DO WHILE ( GetMessage (mesg, NULL, 0, 0) .NEQV. .FALSE. )
iRet = TranslateMessage ( mesg )
iRet = DispatchMessage ( mesg )
END DO
iRet = TranslateMessage ( mesg )
iRet = DispatchMessage ( mesg )
END DO
WinMain = mesg.wParam
END FUNCTION WinMain
!****************************************************************
INTEGER FUNCTION MainWndProc ( hWnd, mesg, wParam, lParam )
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_MainWndProc@16' :: MainWndProc
USE IFWIN
INTEGER hWnd, mesg, wParam, lParam
INTEGER hWndListView, iRet
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_MainWndProc@16' :: MainWndProc
USE IFWIN
INTEGER hWnd, mesg, wParam, lParam
INTEGER hWndListView, iRet
SELECT CASE ( mesg )
CASE ( WM_CREATE )
hWndListView = CreateListView ( hWnd )
iRet = InitListViewColumns ( hWndListView )
CASE ( WM_DESTROY )
CALL PostQuitMessage( 0 )
CASE DEFAULT
MainWndProc = DefWindowProc ( hWnd, mesg, wParam, lParam )
END SELECT
CASE ( WM_CREATE )
hWndListView = CreateListView ( hWnd )
iRet = InitListViewColumns ( hWndListView )
CASE ( WM_DESTROY )
CALL PostQuitMessage( 0 )
CASE DEFAULT
MainWndProc = DefWindowProc ( hWnd, mesg, wParam, lParam )
END SELECT
END FUNCTION MainWndProc
!****************************************************************
!****************************************************************
INTEGER FUNCTION CreateListView ( hWnd )
USE IFWIN
USE comctl32
USE IFWIN
USE comctl32
INTEGER hWnd
INTEGER iRet
INTEGER iRet
TYPE (T_RECT) rcl
TYPE (T_INITCOMMONCONTROLSEX) iccex
TYPE (T_INITCOMMONCONTROLSEX) iccex
iccex%dwSize = sizeof ( iccex )
iccex%dwICC = INT ( ICC_LISTVIEW_CLASSES )
iccex%dwICC = INT ( ICC_LISTVIEW_CLASSES )
iRet = InitCommonControlsEx ( iccex )
IF ( iRet == .FALSE. ) THEN
i = MessageBox ( NULL, "InitCommonControlsEx", NULL, MB_OK )
END IF
i = MessageBox ( NULL, "InitCommonControlsEx", NULL, MB_OK )
END IF
iRet = GetClientRect ( hWnd, rcl )
IF ( iRet == 0 ) THEN
i = MessageBox( NULL, "GetClientRect", NULL, MB_OK )
END IF
i = MessageBox( NULL, "GetClientRect", NULL, MB_OK )
END IF
CreateListView = CreateWindow( &
WC_LISTVIEW, &
"", &
IOR (IOR ( LVS_REPORT, WS_CHILD ), WS_VISIBLE ), &
0, &
0, &
(rcl%right - rcl%left), &
(rcl%bottom - rcl%top), &
hWnd, &
INT(9001), &
ghInstance, &
NULL)
WC_LISTVIEW, &
"", &
IOR (IOR ( LVS_REPORT, WS_CHILD ), WS_VISIBLE ), &
0, &
0, &
(rcl%right - rcl%left), &
(rcl%bottom - rcl%top), &
hWnd, &
INT(9001), &
ghInstance, &
NULL)
IF ( CreateListView == NULL ) THEN
i = MessageBox ( NULL, "CreateWindow", NULL, MB_OK )
END IF
i = MessageBox ( NULL, "CreateWindow", NULL, MB_OK )
END IF
END FUNCTION CreateListView
!****************************************************************
INTEGER FUNCTION InitListViewColumns ( hWndListView )
USE IFWIN
INTEGER hWndListView
INTEGER iRet
USE IFWIN
INTEGER hWndListView
INTEGER iRet
type (T_LVCOLUMN) lvc
lvc%mask = IOR ( IOR ( LVCF_FMT, LVCF_WIDTH), LVCF_TEXT)
lvc%cx = 1000
lvc%fmt = INT ( LVCFMT_LEFT )
lvc%pszText= LOC("SubItem1"c )
lvc%cx = 1000
lvc%fmt = INT ( LVCFMT_LEFT )
lvc%pszText= LOC("SubItem1"c )
iRet = SendMessage ( hWndListView, INT ( LVM_INSERTCOLUMN ), 1, LOC(lvc) )
lvc%pszText= LOC ( "SubItem2"C )
END FUNCTION InitListViewColumns
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
IMPLICIT NONE is your friend:
Code:
INTEGER FUNCTION MainWndProc ( hWnd, mesg, wParam, lParam ) !DEC$ ATTRIBUTES STDCALL, ALIAS : '_MainWndProc@16' :: MainWndProc USE IFWIN INTEGER hWnd, mesg, wParam, lParam INTEGER hWndListView, iRet INTEGER, EXTERNAL:: CreateListView
Without explicit declaration of CreateListView, the return value is REAL, and INTEGER<->REAL typecasts screw the value ofhWndListView.
My style isto put such codes in MODULEs (one module per window) with IMPLICIT NONE on the top -- it helps the organization and avoids such mistakes.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks that did it. Works perfect now.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page