- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am having some trouble finding any example Fortran QuickWin code. I have programmed in Fortran for many years but have stayed blissfully ignorant of Windows programming. I have been asked to add a progress bar to a console application. What I am looking for is a VERY basic first example / tutorial / introduction to dealing with windows in Fortran. Any help would be greatly appreciated.
Thanks,
David Bradley
bradley@tess-inc.com
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Simple QuickWin example follows:
[cpp]print *, "Hello, world!"
end[/cpp]
The thing about QuickWin is that you can take an ordinary Fortran "console" application, build it as a QuickWin application, and you have an instant "Windows look and feel". You can then add functionality (menus, graphics, dialogs, etc.) as you desire.
A few QuickWin samples ship with the compiler. Calendar is probably the simplest. Others show advanced techniques.
Let me suggest, though, that you look at Jugoslav Dujic's free xeffort library. A progress bar can be added to most applications without too much effort.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here's an example I whipped up tonight based on an MSDN sample. It consists of a module with three routines, one to create a progress bar, one to set the position in percent done and one to remove it, plus a test program that uses the module.
In this example, the progress bar is always placed along the bottom of the foreground window and has no other content. Using a dialog box with a progress bar control, and maybe a string that you update with the numerical percent done, is also possible (different coding technique.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have started looking at using a progress bar but found these two examples no longer available. Should I be looking somewhere else or can they be restored?
Neels
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A MSDN C example is at http://msdn.microsoft.com/en-us/library/windows/desktop/hh298373(v=vs.85).aspx converting to fortran would only yake a few minutes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually you have prompted me as I need a progress bar, I made a test routine below based on the MSDN sample.
![fortran]
subroutine msdn_progress_bar_use_example()
use ifqwin
use ifwin
implicit none
integer l1
type(T_RECT) :: rcClient ! ! Client area of parent window.
integer(4) :: cyVScroll; ! Height of scroll bar arrow.
integer(handle) :: hwndPB ! Handle of progress bar.
integer(bool) :: bret
integer(LRESULT) :: ires
integer(LONG_PTR) :: lParam_range !or whatever 16 bits max as range is lower part of 32 bit value
!stuff we need to supply.....
integer(handle) :: hwndParent ! handle of parent window
integer(UINT_PTR) :: step = 1
integer(LONG_PTR) :: range_min =0, range_max=100
lParam_range=ishft(range_max,16) + range_min !hi word, low word 16bit + 16bit
! Ensure that the common control DLL is loaded
!InitCommonControls() !required for windows 95 or ealier
hwndParent = GETHWNDQQ (QWIN$FRAMEWINDOW ) !make the qwin frame window the parent of the progress bar
! Base the height of the progress bar on the height of a scroll bar arrow.
bret = GetClientRect(hwndParent, rcClient)
cyVScroll = GetSystemMetrics(SM_CYVSCROLL)
!create a progress bar along the bottom of the client area of the parent window.
hwndPB = CreateWindowEx(0, PROGRESS_CLASS, NULL, &
ior(WS_CHILD, WS_VISIBLE), rcClient%left,&
rcClient%bottom - cyVScroll, &
rcClient%right, cyVScroll, &
hwndParent, 0, 0, NULL)
!FUNCTION SendMessage(hWnd,Msg,wParam,lParam) ! sendmessage interface for ref user32.f90
! integer(LRESULT) :: SendMessage ! LRESULT
! integer(HANDLE) hWnd ! HWND hWnd
! integer(UINT) Msg ! UINT Msg
! integer(UINT_PTR) wParam ! WPARAM wParam
! integer(LONG_PTR) lParam ! LPARAM lParam
!END FUNCTION
! Set the range and increment of the progress bar.
ires = SendMessage(hwndPB, PBM_SETRANGE, 0, lParam_range)
ires = SendMessage(hwndPB, PBM_SETSTEP, step, 0)
do l1=1,range_max/step
call sleep(10000*step/range_max) !simulate doing somthing for 10s
! Advance the current position of the progress bar by the increment.
ires = SendMessage(hwndPB, PBM_STEPIT, 0, 0);
enddo
bret = DestroyWindow(hwndPB)
end subroutine msdn_progress_bar_use_example
!![/fortran]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks that will help. I want to display it in a dialog box and was planning to use GetDlgItem but it is not listed in the online help.
Neels
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That should work on a dialog I would think the first item in the dioalog structure is dlg%hwnd which is the handle of the dialog to use as the parent.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes thanks, it is mostly described in the following thread:
http://software.intel.com/en-us/forums/topic/274479
I still wonder why GetDlgItem is not in the IVF help files or am I looking in the wrong place?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
getdlgitem is not a quickwin command it is a window api call (see mdsn) so you will need to have "use ifwin" but when you do in quickwin something like retl4 = dlginit(IDD_DIALOG_CALCS,mydlg) then the returned data "mydlg" has the handle you need in mydlg%hwnd (look at it in the debugger)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I know it is not a QuickWin command. I have used the process as described in the link in my previous post without success.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I split the code I posted above into 3 utilities INIT ( creates the control and sets min,max,step) DESTROY and STEP (source attached), I added in an iflogm dialog and it works fine:
[fortran]
RETL4 = DLGINIT(IDD_DIALOG,DLG) ! create an iflogm dialog
RETL4 = DLGSETSUB (DLG, IDD_DIALOG , mycallback) ! create callback for init/destroy events
subroutine mycallback(DLG,ID,CBtype)
if(id.eq.IDD_DIALOG) then
if (cbtype.eq.DLG_INIT) then
! note that dlg%hwnd is NOT set until dlginit is called
call cc_progress_bar_init(hwndPB,dlg%hwnd,0,100,10)
elseif(cbtype.eq.DLG_DESTROY) then
call cc_progress_bar_destroy(hwndPB)
endif
elseif(ID.eq. id_another_control)
elseif(ID.eq. id_yet_another_control)
else
endif
end subroutine mycallback
!and somewhere in my dialog callbacks that do stuff
call cc_progress_bar_step(hwndPB) ! increment the progress bar by step
[/fortran]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks. Is there a specific reason you do not use the resource editor to create the progress bar and then just use GetDlgItem to get its handle?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The method used can create a progress bar for a dialog, a window or a stand along progress bar window if you change the parent parameters. If you get the handle via getglgitem you can attach it to some other resource in a dialog but I haven't tried that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have tried many options but nothing I do get it to work. I start the progress bar as follows:
[fortran]
write(66,*)
hWpb = GetDlgItem(dlg%hWnd, IDC_Progress_CdMap)
write(66,*)'hWpb = ',hWpb
write(66,*)
write(66,*)'NumLiftPoints = ',NumLiftPoints
iRes = SendMessage(hWpb, PBM_SetRange, 0, NumLiftPoints)
write(66,*)'Previous Range ',ires
iRes = SendMessage(hWpb, PBM_SetPos, 0, 0)
write(66,*)'Previous Position ',ires
iRes = SendMessage(hWpb, PBM_SetStep, 1, 0)
write(66,*)'Previous StepValue ',ires
write(66,*)
[/fortran]
and then increment the progress bar in another callback where the calculations are done:
[fortran]
Res = SendMessage(hWpb, PBM_StepIt, 0, 0)
write(66,*)'Previous Position ',i,res
[/fortran]
and get the following results:
hWpb = 1508468
NumLiftPoints = 12
Previous Range 1
Previous Position 12
Previous StepValue 1
and in the calculation the position is incremented by 1 in each loop.
Help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the call PBM_SetRange the last parameter NumLiftPoints should be a 32 bit integer and this has min and max as low and high words... Some examples are posted hight up the topic.
[fortran]lParam_range=ishft(range_max,16) + range_min !hi word, low word 16bit + 16bit[/fortran] or something simillar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, I now have it working. Had to study some on hi and low words etc. Wish Intel would add a wrapper for this as part of the dialog and qwin options.

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