<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: A Dialog Box in a DLL in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930852#M14773</link>
    <description>Unfortunately, time-zone difference makes this discussion lasting &lt;BR /&gt;for days. It looks as if I leave my job about at the same time when &lt;BR /&gt;you start yours :-(. &lt;BR /&gt; &lt;BR /&gt;The fragment from DlgModal I posted yesterday is syntactically OK &lt;BR /&gt;(I tested it) and I think it does the job. You just have to be more &lt;BR /&gt;careful when editing. DlgModal already exists in DFLOGM; just &lt;BR /&gt;add lines &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt; 
use dfwin 
integer:: hModule 
character(len=20):: szModuleName="dgbox.dll"C 
&lt;/PRE&gt; &lt;BR /&gt;  &lt;BR /&gt;and replace the if-block in the original DlgModal with &lt;BR /&gt;the if-block in the above code.  &lt;BR /&gt;DialogBox is not part of the DFLOGM module; it is a system &lt;BR /&gt;(API) function which can be accessed by putting USE DFWIN &lt;BR /&gt;as the first line of FUNCTION or MODULE. &lt;BR /&gt; &lt;BR /&gt;If you still cannot solve the problem, please post first 4-5  &lt;BR /&gt;error messages you get - and/or please leave your e-mail so &lt;BR /&gt;I could send you the working DFLOGM.  &lt;BR /&gt; &lt;BR /&gt;Regards &lt;BR /&gt;Jugoslav</description>
    <pubDate>Thu, 14 Dec 2000 22:02:58 GMT</pubDate>
    <dc:creator>Jugoslav_Dujic</dc:creator>
    <dc:date>2000-12-14T22:02:58Z</dc:date>
    <item>
      <title>A Dialog Box in a DLL</title>
      <link>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930843#M14764</link>
      <description>I am using DF 5.0.  I have a problem to call a simple Dialog Box written in DLL from VB.  It can be compiled, but can not be called by VB.  (just shutdown the VB project). It appears DlgInit can not initialize the Dialog box.  Maybe in version 6.x, one can use DlgInitWithResourcehandle, but in version 5.0D, there is no such function.  From reference manual, I found Dlginit is compatible with Window Dll.  My example below is working perfectly in QuickWin, but not in DLL.  Can anyone help?  &lt;BR /&gt; &lt;BR /&gt;subroutine dgbox1()   &lt;BR /&gt;use dfwin   &lt;BR /&gt;use dflogm   &lt;BR /&gt;implicit none  &lt;BR /&gt;!dec$ attributes dllexport, alias : "dgbox1" :: dgbox1   &lt;BR /&gt;!DEC$OBJCOMMENT LIB:"USER32.LIB"    &lt;BR /&gt;include 'resource.fd'   &lt;BR /&gt;type (dialog) dlg  &lt;BR /&gt;logical retlog   &lt;BR /&gt;integer retint   &lt;BR /&gt;retlog = DlgInit(idd_box,dlg)   &lt;BR /&gt;if (.not. retlog) then  &lt;BR /&gt;write (*,*) "Error: dialog not found"   &lt;BR /&gt;endif   &lt;BR /&gt;retint = dlgmodal(dlg)   &lt;BR /&gt;call dlguninit(dlg)   &lt;BR /&gt;end  &lt;BR /&gt;Also I used resource editor to created a Dialog and my VB codes are  &lt;BR /&gt;Declare sub dgbox1 lib "dgbox.dll" () in Module and  &lt;BR /&gt;call dgbox in Form</description>
      <pubDate>Fri, 08 Dec 2000 05:39:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930843#M14764</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2000-12-08T05:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: A Dialog Box in a DLL</title>
      <link>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930844#M14765</link>
      <description>Um, the only place I'd expect DFLOGM to fail is DlgModal, &lt;BR /&gt;not DlgInit. Having taken a look into DlgInit, the only place &lt;BR /&gt;that might fail is call to .cpp routine DlgGetRes. Its equivalent &lt;BR /&gt;in Fortran is: &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt; 
LOGICAL FUNCTION DlgGetRes(ID,lpDlgRsrc) 
 
USE DFWIN 
 
INTEGER:: hRsrc, hGlob 
INTEGER:: lpDlgRsrc 
 
hrsrc = FindResource( NULL, ID, RT_DIALOG ); 
 
IF (hrsrc == NULL) THEN 
   DlgGetRes=.FALSE. 
   RETURN 
END IF 
 
hGlob = LoadResource( NULL, hrsrc ) 
 
IF (hGlob == NULL) THEN 
   DlgGetRes=.FALSE. 
   RETURN 
END IF 
 
lpDlgRsrc = LockResource( hGlob ) 
 
END FUNCTION 
&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;The documentation for FindResource says that, quote, &lt;BR /&gt; &lt;BR /&gt;"hModule - A handle to the module whose executable file contains the resource. A value of NULL specifies the module handle associated with the image file that the operating system used to create the current process. " &lt;BR /&gt; &lt;BR /&gt;It's not very clear, but it looks that the NULL in FindResource call &lt;BR /&gt;specifies that the resource should be looked for in calling VB program, &lt;BR /&gt;not in DLL itself.  &lt;BR /&gt; &lt;BR /&gt;If you're brave enough - and if it's important - I'd suggest that you &lt;BR /&gt;try to fix the problem by tweaking DFLOGM a little (my favourite sport :-)). &lt;BR /&gt; &lt;BR /&gt;&lt;P&gt;1) Copy DFLOGM.f90 from DevStudio/DF/Include into your project directory.  Add it to the project. &lt;/P&gt; &lt;BR /&gt;&lt;P&gt;2) Add the above code somewhere inside MODULE DFLOGM. Rename it &lt;BR /&gt; to, say, DlgGetRes1.&lt;/P&gt; &lt;BR /&gt;&lt;P&gt;3) Change the following lines in DlgInit from &lt;/P&gt; &lt;BR /&gt;&lt;PRE&gt; 
	type (DialogResource) dlgres, dlgres2 
                ... 
	if ( .not. DlgGetRes( id, dlgres ) ) then 
                ... 
                dlgres=dlgres2 
&lt;/PRE&gt; &lt;BR /&gt;to &lt;BR /&gt;&lt;PRE&gt; 
	type (DialogResource) dlgres, dlgres2 
                pointer(pdlgres,dlgres) 
                pointer(pdlgres2,dlgres2) 
               ... 
	if ( .not. DlgGetRes1( id, pdlgres) ) then 
               ... 
               pdlgres2=pdlgres 
&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;4) Add the following code at the beginning of DlgGetRes1: &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt; 
integer hModule 
hModule=GetModuleHandle('MyDllName.dll') 
&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;replace NULLs in calls to FindResource and LoadResource with &lt;BR /&gt;hModule. &lt;BR /&gt; &lt;BR /&gt;5) Compile the DLL &amp;amp; prey. In any case, try to debug carefully and &lt;BR /&gt;step into all functions in DFLOGM. I'm 99% sure I screwed up something &lt;BR /&gt;in the explanation above. The basic idea was to replace the DlgGetRes &lt;BR /&gt;with the one that searches for resource in DLL, not in calling VB exe... &lt;BR /&gt;Perhaps the last piece of code (involving GetModuleHandle) could have &lt;BR /&gt;been written more ellegantly, but right now I can't recall the way to &lt;BR /&gt;get the name of "this" module (exe or dll). Perhaps renaming of MODULE DFLOGM into something else will be necessary (I don't know the default search rules for modules). Even if this succeeds, you might have a problem later in DlgModal, since it calls GetHwndQQ(QWIN$FRAMEWINDOW), but then... post another message. &lt;BR /&gt; &lt;BR /&gt;Regards &lt;BR /&gt; &lt;BR /&gt;Jugoslav &lt;BR /&gt; &lt;BR /&gt;P.S. Try to enclose the posted code in &lt;PRE&gt; and &lt;/PRE&gt; HTML tags (replace ['s with &amp;lt;'s)... Forum software... sigh.</description>
      <pubDate>Sat, 09 Dec 2000 02:17:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930844#M14765</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2000-12-09T02:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: A Dialog Box in a DLL</title>
      <link>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930845#M14766</link>
      <description>Jugoslav, thanks for the help.  I need to study your approach.  But I think DlgInit is the problem.  Try this  &lt;BR /&gt;subroutine dgbox() &lt;BR /&gt;use dfwin &lt;BR /&gt;use dflogm &lt;BR /&gt;!dec$ attributes dllexport, alias: "dgbox" :: dgbox &lt;BR /&gt;!dec$objcomment lib: "user32.lib" &lt;BR /&gt;logical retlog &lt;BR /&gt;integer retint &lt;BR /&gt;type(dialog) dlg &lt;BR /&gt;retlog = dlginit(idd_box, dlg) &lt;BR /&gt;if (.not. retlog) then &lt;BR /&gt;retlog = AllocConsole() &lt;BR /&gt;write(*,*) "Error, resource not found" &lt;BR /&gt;retlog = FreeConsole &lt;BR /&gt;else &lt;BR /&gt;retlog = dlgmodal(dlg) &lt;BR /&gt;endif &lt;BR /&gt;end subroutine dgbox &lt;BR /&gt; &lt;BR /&gt;You can see it DlgInit = false.</description>
      <pubDate>Sat, 09 Dec 2000 04:14:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930845#M14766</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2000-12-09T04:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: A Dialog Box in a DLL</title>
      <link>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930846#M14767</link>
      <description>Jugoslav, it does not work when I tried your approach.  I can not even compiled the code.  I got error message like Error: This statement is invalid in an INTERFACE block. &lt;BR /&gt;  hModule = GetModuleHandle('MyDllName.dll') &lt;BR /&gt;Is there any other way to do this.  I wish someone from Compaq can give an answer.</description>
      <pubDate>Tue, 12 Dec 2000 09:10:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930846#M14767</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2000-12-12T09:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: A Dialog Box in a DLL</title>
      <link>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930847#M14768</link>
      <description>Well, I did say "if you're brave enough" :-). And, as I promised, I did &lt;BR /&gt;screwed up something in the code. Finally, I did actually try to &lt;BR /&gt;modify DFLOGM.  &lt;BR /&gt; &lt;BR /&gt;Apparently, you inserted the DlgGetRes1 into INTERFACE section, &lt;BR /&gt;not into module itself. Let's start from the beginning... so, re-copy &lt;BR /&gt;original DFLOGM.f90, and do _only_ these two modifications: &lt;BR /&gt; &lt;BR /&gt;Add the following DlgGetRes1 &lt;I&gt;immediately before&lt;/I&gt; line &lt;BR /&gt;"END MODULE DFLOGM" (at the end of file): &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt; 
LOGICAL FUNCTION DlgGetRes1(ID,DlgRsrc)    
 
USE DFWIN    
 
CHARACTER(LEN=20)::  szModuleName='dgbox.dll'C 
INTEGER:: ID, hRsrc, hGlob, hModule 
TYPE(DialogResource):: DlgRsrc 
 
hModule=GetModuleHandle(LOC(szModuleName)) 
 
hrsrc = FindResource( hModule, ID, RT_DIALOG );    
IF (hrsrc == NULL) THEN   
   DlgGetRes1=.FALSE.   
   RETURN   
END IF    
 
hGlob = LoadResource( hModule, hrsrc )    
IF (hGlob == NULL) THEN   
   DlgGetRes1=.FALSE.   
   RETURN   
END IF    
DlgRsrc%ptr = LockResource( hGlob )    
DlgGetRes1 = DlgRsrc%ptr .NE. 0 
 
END FUNCTION DlgGetRes1 
&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;And only replace call to DlgGetRes (in DlgInit) with &lt;BR /&gt;call to DlgGetRes1. (Do not insert POINTER declarations etc.). &lt;BR /&gt;Now, recompile and try. It would be a good idea to put a &lt;BR /&gt;breakpoint at first line of DlgGetRes1 and watch return values &lt;BR /&gt;of functions, especially hModule.  &lt;BR /&gt; &lt;BR /&gt;I &lt;I&gt;did not&lt;/I&gt; find time to try it with DLL - it &lt;BR /&gt;works in an .exe... I just think it should work in the DLL &lt;BR /&gt;also. Of course, the method is not universal, since it depends &lt;BR /&gt;on value of szModuleName (i.e. name of the dll itself)...  &lt;BR /&gt; &lt;BR /&gt;Regards &lt;BR /&gt;Jugoslav</description>
      <pubDate>Wed, 13 Dec 2000 01:19:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930847#M14768</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2000-12-13T01:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: A Dialog Box in a DLL</title>
      <link>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930848#M14769</link>
      <description>Jugoslav, following the procedures you provided, it passed compile, and it seems DlgInit is initializing, but the Dialog Box is still not shown up.  I guess it is what you talked erlier that DlgModal is a problem.  Anyway to fix it?  I really appreciate your time and help.</description>
      <pubDate>Wed, 13 Dec 2000 08:04:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930848#M14769</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2000-12-13T08:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: A Dialog Box in a DLL</title>
      <link>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930849#M14770</link>
      <description>What is the return value of DlgModal? Is it -1? If so, perhaps the problem is similar to the previous one: DialogBox tries to locate the resource in VB caller, not in Dll itself. Try adding the following lines in DlgModal: &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt; 
  recursive function DlgModal ( dlg, hwndParent ) result  
  use dfwin 
  integer hModule 
  character*20::    szModuleName='dgbox.dll'C 
... 
  hModule=GetModuleHandle(LOC(szModuleName)) 
  if ( DialogBox (hModule, MAKEINTRESOURCE(dlg % dlgid), hwndParent, LOC(DlgProc) ) .eq. -1 ) then 
    r=-1 
    else 
      r = dlg % retval 
    end if 
... 
&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;(Replace existing if (DlgDoModal...else...endif with the above block.)  &lt;BR /&gt; &lt;BR /&gt;Also, find the body of DlgProc function and add the following line immediately after "recursive function DlgProc(..." &lt;BR /&gt; &lt;BR /&gt;!DEC$ATTRIBUTES STDCALL:: DlgProc &lt;BR /&gt; &lt;BR /&gt;I hope that would finally fix the thing. &lt;BR /&gt; &lt;BR /&gt;Regards &lt;BR /&gt; &lt;BR /&gt;Jugoslav</description>
      <pubDate>Wed, 13 Dec 2000 20:45:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930849#M14770</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2000-12-13T20:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: A Dialog Box in a DLL</title>
      <link>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930850#M14771</link>
      <description>Something was wrong when compile it.  I got 58 error messages.  I could not find Dialogbox defined anywhere in Dflogm.f90.  Is that a problem?  I tried several ways but got nowhere.  I still need your kind help.  Thanks</description>
      <pubDate>Thu, 14 Dec 2000 05:21:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930850#M14771</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2000-12-14T05:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: A Dialog Box in a DLL</title>
      <link>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930851#M14772</link>
      <description>BTW, the return value is -1</description>
      <pubDate>Thu, 14 Dec 2000 05:22:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930851#M14772</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2000-12-14T05:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: A Dialog Box in a DLL</title>
      <link>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930852#M14773</link>
      <description>Unfortunately, time-zone difference makes this discussion lasting &lt;BR /&gt;for days. It looks as if I leave my job about at the same time when &lt;BR /&gt;you start yours :-(. &lt;BR /&gt; &lt;BR /&gt;The fragment from DlgModal I posted yesterday is syntactically OK &lt;BR /&gt;(I tested it) and I think it does the job. You just have to be more &lt;BR /&gt;careful when editing. DlgModal already exists in DFLOGM; just &lt;BR /&gt;add lines &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt; 
use dfwin 
integer:: hModule 
character(len=20):: szModuleName="dgbox.dll"C 
&lt;/PRE&gt; &lt;BR /&gt;  &lt;BR /&gt;and replace the if-block in the original DlgModal with &lt;BR /&gt;the if-block in the above code.  &lt;BR /&gt;DialogBox is not part of the DFLOGM module; it is a system &lt;BR /&gt;(API) function which can be accessed by putting USE DFWIN &lt;BR /&gt;as the first line of FUNCTION or MODULE. &lt;BR /&gt; &lt;BR /&gt;If you still cannot solve the problem, please post first 4-5  &lt;BR /&gt;error messages you get - and/or please leave your e-mail so &lt;BR /&gt;I could send you the working DFLOGM.  &lt;BR /&gt; &lt;BR /&gt;Regards &lt;BR /&gt;Jugoslav</description>
      <pubDate>Thu, 14 Dec 2000 22:02:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930852#M14773</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2000-12-14T22:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: A Dialog Box in a DLL</title>
      <link>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930853#M14774</link>
      <description>Here is the error:  &lt;BR /&gt;dflogm.lib(dflogm.obj) : error LNK2005: _DFLOGM_mp_LOG2INT@4 already defined in Dflogm.obj  &lt;BR /&gt;dflogm.lib(dflogm.obj) : error LNK2005: _DFLOGM_mp_STRFOR2C@12 already defined in Dflogm.obj  &lt;BR /&gt;dflogm.lib(dflogm.obj) : error LNK2005: _DFLOGM_mp_STRC2FOR@4 already defined in Dflogm.obj  &lt;BR /&gt;dflogm.lib(dflogm.obj) : error LNK2005: _DFLOGM_mp_PADSTRFOR@8 already defined in Dflogm.obj  &lt;BR /&gt;  &lt;BR /&gt;I really appreciate if you can e-maol me the DFLOmG.f90.  My e-mail address is  &lt;BR /&gt;  &lt;BR /&gt;rshen@hotmail.com</description>
      <pubDate>Fri, 15 Dec 2000 03:27:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/A-Dialog-Box-in-a-DLL/m-p/930853#M14774</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2000-12-15T03:27:55Z</dc:date>
    </item>
  </channel>
</rss>

