- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
use ifwin
use iflogm
use kernel32
implicit double precision (a-h,o-z)
type (t_memorystatus) mymemory
include 'resource.fd'
type (dialog) dlg
logical lret
integer iret
character*256 itram_c, dlg_text
c
call globalmemorystatus(mymemory)
itram=mymemory.dwtotalphys/1048576
c
write (*,*) itram
if(.not.dlginit(idd_dialog1,dlg))then
write (*,*) "error: resource not found"
else
write(itram_c, *) itram
dlg_text = "total physical ram : "//trim(adjustl(itram_c))
+ //" mb"
lret = dlgset( dlg, idc_static1, dlg_text )
c iret = dlgmodal(dlg)
iret = dlgmodeless(dlg)
call dlguninit(dlg)
endif
do icount=1,100000
print *, icount
enddo
end
do while( GetMessage (mesg, NULL, 0, 0) )
end do
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My intent was to allow the program to go on running even after the modeless dialog was shown. The close button in the attached project (modeless.zip)will be used to close the modeless dialog butshould not affect the running program. The modeless dialog was initiated to present some information whilethe program was running.From the code below, the program halted when the modeless dialog was shown and "Ctrl-C" is required to terminate the program which wasn't the intent. How do I go about it?
================================================
program running
use ifwin
use iflogm
use kernel32
implicit double precision (a-h,o-z)
type (t_memorystatus) mymemory
include 'resource.fd'
type (dialog) dlg
type (t_msg) mesg
logical lret
integer iret
character*256 itram_c, dlg_text
c
call globalmemorystatus(mymemory)
itram=mymemory.dwtotalphys/1048576
c
write (*,*) itram
if(.not.dlginit(idd_dialog1,dlg))then
write (*,*) "error: resource not found"
else
write(itram_c, *) itram
lret = dlginit(idd_dialog1,dlg)
dlg_text = "Total physical ram : "//trim(adjustl(itram_c))
+ //" MB"
lret = dlgset( dlg, idc_static1, dlg_text )
c iret = dlgmodal(dlg)
iret = dlgmodeless(dlg)
do while( GetMessage (mesg, NULL, 0, 0) )
if (dlgisdlgmessage(mesg) .eqv. .false.) then
lret = TranslateMessage( mesg )
ret = DispatchMessage( mesg )
end if
end do
call dlguninit(dlg)
endif
do icount=1,100000
print *, icount
enddo
c
================================================
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following is an edited version of your code, which does what you want by adding a callback routine to deal with the IDCLOSE button and send a WM_QUIT message to the dialog's message queue (I use CVF, so actually had to changeUSE IFWIN to USE DFWIN and USE IFLOGM to USE DFLOGM to test it, but I assume if it works under CVF, it will work with IVF)
(P.S. I note that IDCLOSE does not occur in RESOURCE.FD, so it must be a globally defined value. I always like to define my own values, so that I retain full control and know which 'CLOSE' button I am dealing with at any time.)
Code:
program running use ifwin use iflogm use kernel32 implicit double precision (a-h,o-z) type (t_memorystatus) mymemory include 'resource.fd' type (dialog) dlg type (t_msg) mesg logical lret integer iret character*256 itram_c, dlg_text c Define callback routine as EXTERNAL external DialogQuit c call globalmemorystatus(mymemory) itram=mymemory.dwtotalphys/1048576 c write (*,*) itram if(.not.dlginit(idd_dialog1,dlg))then write (*,*) "error: resource not found" else write(itram_c, *) itram lret = dlginit(idd_dialog1,dlg) dlg_text = "Total physical ram : "//trim(adjustl(itram_c)) + //" MB" lret = dlgset( dlg, idc_static1, dlg_text ) c iret = dlgmodal(dlg) c c Assign a callback routine DialogQuit to the CLOSE button c lret = DlgSetSub(dlg, IDCLOSE,DialogQuit) iret = dlgmodeless(dlg) do while( GetMessage (mesg, NULL, 0, 0) ) if (dlgisdlgmessage(mesg) .eqv. .false.) then lret = TranslateMessage( mesg ) ret = DispatchMessage( mesg ) end if end do call dlguninit(dlg) endif do icount=1,100000 print *, icount enddo c end c************************************************************ c c Callback subroutine DialogQuit c Function: To post a WM_QUIT message to the dialog's c message queue when the CLOSE button is pressed c c********************************************************** SUBROUTINE DialogQuit( dlg, id, callbacktype ) !DEC$ ATTRIBUTES DEFAULT :: DialogQuit use user32 use iflogm implicit none include 'resource.fd' type (dialog) dlg integer id, callbacktype, lret if (id.eq.IDCLOSE) then Call PostQuitMessage(0) return endif ! END SUBROUTINE DialogQuit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
By the way, the simple problem you have could easily be done using MessageBox (which requires
null (i.e. CHAR(0) )-terminated strings for the message and the message box title..
For example
lret =MessageBox( null,TRIM(ADJUSTL(dlg_text))//char(0), 'Memory Status'c, MB_OK)
Message Edited by anthonyrichards on 03-20-200603:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
By changing the elapsed time programmed for the timer, you can control the time the dialog is displayed. I note that, although the dialog is automatically exited and the later computations proceed ok (i.e.the printing of 1000 lines), the dialog box window remains visible until the printing ceases, when it finally disappears.
before the DlgUninit statement makes the window disappear immediately....
Message Edited by anthonyrichards on 03-21-200603:55 AM
Message Edited by anthonyrichards on 03-21-200606:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
===========================================
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Message Edited by anthonyrichards on 03-22-200601:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot! The program is working as intended. I will try to figure out why I keep getting the following warningmessages:
================================================
C:Documents and SettingshongshDesktopModelessModeless.f90(99) : Warning: The data type of the actual argument does not match the definition. [1001]
C:Documents and SettingshongshDesktopModelessModeless.f90(99) : Warning: The data type of the actual argument does not match the definition. [0]
================================================
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
...and you will probably find that the parameter BN_CLICKED is defined = 0, so the messages are probably that these parameters are by default INTEGER*4, whereas MAKEWPARAM expects INTEGER*2 arguments....
You could try using MAKEWPARAM( INT2(IDC_CLOSE),INT2(BN_CLICKED) ) and see if this works and makes the warnings go away...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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