<?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 Trouble with GetWindowText in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794477#M34425</link>
    <description>...and a probelm that turns up with the posted program is that the frequently-called function PadStrFor in XFLOGM.F90 can overrun the buffer if the 'expected' trailing null character char(0) is not present when the function looks for it in the supplied string in order to pad it with blanks out to the end of the string. You need to change the function code to stop searching when you have reached the end of the supplied string. &lt;BR /&gt;&lt;BR /&gt;The present code fails in that case by assuming that the second part of the test&lt;BR /&gt;&lt;BR /&gt;i .le. len(str0.and. str(i:i) .ne. char(0)&lt;BR /&gt;&lt;BR /&gt;will not be executed if i exceeds len(str), which it will do because of the i=i+1.&lt;BR /&gt;(This has been discussed in a recent thread). The attached code is better as it exits the WHILE loop as soon as i exceeds len(str) and prevents the code trying to access str(i:i) when i exceeds the strings length.&lt;BR /&gt;&lt;BR /&gt;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!&lt;BR /&gt;!! PadStrFor&lt;BR /&gt;!!&lt;BR /&gt;!! Pads out a null terminated string (C string to F90 string)&lt;BR /&gt;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!&lt;BR /&gt;&lt;BR /&gt; recursive subroutine PadStrFor( str )&lt;BR /&gt; character*(*), intent(inout) :: str&lt;BR /&gt; integer i, lstr&lt;BR /&gt; ! scan up to the terminating null&lt;BR /&gt; i = 1&lt;BR /&gt; lstr=len(str)&lt;BR /&gt; do while( i .le. lstr.and. str(i:i) .ne. char(0) )&lt;BR /&gt; i = i + 1&lt;BR /&gt; if(i.gt.lstr) exit&lt;BR /&gt; end do&lt;BR /&gt; ! pad the rest with blanks&lt;BR /&gt; do while( i .le. lstr )&lt;BR /&gt; str(i:i) = ' '&lt;BR /&gt; i = i + 1&lt;BR /&gt; end do&lt;BR /&gt; end subroutine PadStrFor&lt;BR /&gt;&lt;BR /&gt;P.S.&lt;BR /&gt;GetWindowText help says "If the function succeeds, the return value is the length, in characters, of the 
copied string, &lt;SPAN style="text-decoration: underline;"&gt;&lt;B&gt;not including the terminating null character.&lt;/B&gt;&lt;/SPAN&gt;" (my emphasis). So any terminating null character is ignored by this function during the copy to the user-supplied buffer. Clearly, if there is no terminating null character, the function may copy some rubbish to the user-supplied buffer, up to the end of the buffer holding the window's text.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 12 Jul 2011 08:51:43 GMT</pubDate>
    <dc:creator>anthonyrichards</dc:creator>
    <dc:date>2011-07-12T08:51:43Z</dc:date>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794453#M34401</link>
      <description>&lt;P&gt;I am attempting to read the text of a button in order to transfer it to another. The text of the first, IDCANCEL, is set in the resource file as Cancel without the inverted commas. When I use the command to read the text into the character*20 ButtonStr:&lt;/P&gt;&lt;P&gt;lBtnStr = GetWindowText(hButton, ButtonStr, 20) ! Get Button text.&lt;/P&gt;&lt;P&gt;The return value of lBtnStr is 19, rather than the expected 6.&lt;/P&gt;&lt;P&gt;The 7th to 20th characters of ButtonStr are not uniform blanks, do not contain any nulls = char(0) but do contain the occasional alphanumeric character.&lt;/P&gt;&lt;P&gt;When subsequently written into another button, it is treated as being of length 19, not 6, which ruins the centering.&lt;/P&gt;&lt;P&gt;Other WinAPIs are no better or worse, with GetWindowTextLength returning 280 and GetDlgItemText 19.&lt;/P&gt;&lt;P&gt;Any ideas please?&lt;BR /&gt;&lt;BR /&gt;Llynisa&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2011 11:37:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794453#M34401</guid>
      <dc:creator>llynisa</dc:creator>
      <dc:date>2011-07-07T11:37:03Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794454#M34402</link>
      <description>How are you setting the text for IDCANCEL? It sounds like thetext for IDCANCELis improperly terminated.</description>
      <pubDate>Thu, 07 Jul 2011 18:00:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794454#M34402</guid>
      <dc:creator>Anonymous66</dc:creator>
      <dc:date>2011-07-07T18:00:53Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794455#M34403</link>
      <description>Maybe you have leading/trailing blanks that are inserted in the string. Try:&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;lBtnStr = TRIM (ADJUSTL (GetWindowText(hButton, ButtonStr, 20)))&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 07 Jul 2011 18:05:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794455#M34403</guid>
      <dc:creator>Michael_J_Slater__In</dc:creator>
      <dc:date>2011-07-07T18:05:27Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794456#M34404</link>
      <description>Thanks for replying.&lt;BR /&gt;The text is set by using the control wizard to generate the button- it is not possible to use C strings in setting the text of controls using the control wizard, although I would have liked tohave doneso. A sort of solution is to use the command:&lt;BR /&gt;&lt;BR /&gt;lRet = DlgSet (XDlg, IDCANCEL, 'Cancel'C)&lt;BR /&gt;&lt;BR /&gt;immediately after the initialisation of the dialogue.&lt;BR /&gt;&lt;BR /&gt;lBtnStr = TRIM(ADJUSTL(GetWindowText(hButton, ButtonStr, 20)&lt;BR /&gt;&lt;BR /&gt;returns 19 as before. The trouble is a series of non-displaying characters with the occasional alphanumeric character that follow Cancel in the string.&lt;BR /&gt;&lt;BR /&gt;Llynisa</description>
      <pubDate>Thu, 07 Jul 2011 19:09:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794456#M34404</guid>
      <dc:creator>llynisa</dc:creator>
      <dc:date>2011-07-07T19:09:41Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794457#M34405</link>
      <description>Llynisa,&lt;BR /&gt;I don't know whythe string isn't automatically being null terminated, but yousolve this issue by adding a null at the end of the string yourself.&lt;BR /&gt;&lt;BR /&gt;Simply change your code to set the text for IDCANCEL to the following:&lt;BR /&gt;lRet = DlgSet (XDlg, IDCANCEL, 'Cancel&lt;STRONG&gt;\0&lt;/STRONG&gt;'C)&lt;BR /&gt;&lt;BR /&gt;Annalee&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Jul 2011 19:51:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794457#M34405</guid>
      <dc:creator>Anonymous66</dc:creator>
      <dc:date>2011-07-07T19:51:26Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794458#M34406</link>
      <description>Annalee,&lt;BR /&gt;&lt;BR /&gt;Well, thanks - I think that you have provided the clue to the answer - if when using thecontrol wizard one enters the button text of IDCANCEL exactly as:&lt;BR /&gt;&lt;BR /&gt;Cancel\0'C&lt;BR /&gt;&lt;BR /&gt;that solves the problem. In my 50th year of Fortran (and other) programming, I never realised that one could produce a C stringby that method - I have always used 'Cancel'C or 'Cancel'//char(0). So I keep on learning in my dotage.&lt;BR /&gt;&lt;BR /&gt;Thanks again&lt;BR /&gt;&lt;BR /&gt;Llynisa&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Jul 2011 21:13:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794458#M34406</guid>
      <dc:creator>llynisa</dc:creator>
      <dc:date>2011-07-07T21:13:42Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794459#M34407</link>
      <description>There are several ways to get a NUL-terminated string. Some of them are extensions, some are standard. By default, string literals are NOT NUL-terminated in Fortran.&lt;BR /&gt;&lt;BR /&gt;The way I would recommend is to concatenate a NUL chararacter. You can use CHAR(0) but I prefer to use the named constant C_NULL_CHAR from intrinsic module ISO_C_BINDING. This is portable and standard-confortming. Just remember to use TRIM if the value might have trailing blanks.&lt;BR /&gt;&lt;BR /&gt;You can use the 'string'C syntax, which is an extension in the Intel compilers and not guaranteed to be portable.&lt;BR /&gt;&lt;BR /&gt;Last, the method Annalee mentioned requires that the option /assume:bscc be in effect. This is not the default and I have a personal bias against code that requires a compile option. It is, of course, an extension.</description>
      <pubDate>Thu, 07 Jul 2011 21:59:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794459#M34407</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-07-07T21:59:53Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794460#M34408</link>
      <description>&lt;P&gt;Lynisa,&lt;/P&gt;&lt;P&gt;Steve is absolutely right. You are much better off concatenating the null character to the end of your string in your code rather than having it as a part of the string you type in.&lt;/P&gt;&lt;P&gt;'\0' always works with the 'string'C syntax as far as I'm aware, but the /assume:bscc option is necessary when using it or other \escapes in standard Fortran stings.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2011 03:43:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794460#M34408</guid>
      <dc:creator>Anonymous66</dc:creator>
      <dc:date>2011-07-08T03:43:40Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794461#M34409</link>
      <description>Yes, that's correct. The escapes work in ''C strings, but those are also NUL terminated by default. If you're using variables, and not quoted string literals, concatenation is the right approach.</description>
      <pubDate>Fri, 08 Jul 2011 12:06:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794461#M34409</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-07-08T12:06:23Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794462#M34410</link>
      <description>You refer to a 'control wizard' which is used to generate the button.&lt;BR /&gt;In my experience, the resource editor supplied with Visual Studio is the one developed for C++ and so being C-based, it always makes text strings in static text, button controls etc. null terminated when using it to add controls to a dialog. So I do not understand how it can be responsible for generating non-null-terminated strings on your controls. If, after creation, you are subsequently changing the text using SETTEXT messages within your program and supply a non-null-terminated string, then that might be the source of your problem.</description>
      <pubDate>Fri, 08 Jul 2011 13:16:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794462#M34410</guid>
      <dc:creator>anthonyrichards</dc:creator>
      <dc:date>2011-07-08T13:16:56Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794463#M34411</link>
      <description>&lt;P&gt;Steve, Annalee,&lt;/P&gt;&lt;P&gt;Thanks for setting things straight on C strings. However, I must withdraw my statement in my last post that I could set a C string using the control wizard  I was writing in haste late in the evening.&lt;/P&gt;&lt;P&gt;No matter how I try, I cannot get a C string set by the control wizard. so my problem moves on to being solved by either resetting the buttton text using eg:&lt;/P&gt;&lt;P&gt;lRet = DlgSet (XDlg, IDCANCEL, 'Cancel'C)&lt;/P&gt;&lt;P&gt;or by working out how to read the button text correctly when it is not a C string.&lt;/P&gt;&lt;P&gt;If this were a one-off problem I would reset the button text, but my reading statement is in a subroutine that I expect to use on a considerable number of buttons in several programs. Hence I am really looking for a fool-proof way to read a button text without a null but with a variety of unwanted characters following the useful parts.&lt;/P&gt;&lt;P&gt;Llynisa&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2011 13:32:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794463#M34411</guid>
      <dc:creator>llynisa</dc:creator>
      <dc:date>2011-07-08T13:32:00Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794464#M34412</link>
      <description>Pleae can you give more details concerning the 'control wizard' to which you refer?</description>
      <pubDate>Fri, 08 Jul 2011 14:02:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794464#M34412</guid>
      <dc:creator>anthonyrichards</dc:creator>
      <dc:date>2011-07-08T14:02:15Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794465#M34413</link>
      <description>&lt;P&gt;Tony,&lt;/P&gt;&lt;P&gt;These posts seem to have got out of order.&lt;/P&gt;&lt;P&gt;Yes, sorry, I should have called it the resource editior, but whats turning up on the buttons are not C-strings unless I reset them, which I have not, as you can see in the code I sent you the other day. Is it anything to do with my still using CVF6.6C2?&lt;/P&gt;&lt;P&gt;Still puzzled&lt;/P&gt;&lt;P&gt;Llynisa aka BearofLittleBrain&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2011 14:23:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794465#M34413</guid>
      <dc:creator>llynisa</dc:creator>
      <dc:date>2011-07-08T14:23:39Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794466#M34414</link>
      <description>Ah, good old 6.6C! I have that as well (but I start new projects using Intel Composer now).&lt;BR /&gt;Can you post your resource .RC and .H header file so that I can see how it displays on my version?&lt;BR /&gt;&lt;BR /&gt;I attach screen shot of a debug run of a simple dialog where I press an 'Apply' button which then gets the text from the 'Exit' button. A syou can see the returned string length is 4 and the memory displayed at the location of the string shows no nasty characters after the fourth one.&lt;BR /&gt;&lt;BR /&gt;(just watched Atlantis launch for the last time - great TV pictures from NASA).</description>
      <pubDate>Fri, 08 Jul 2011 15:49:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794466#M34414</guid>
      <dc:creator>anthonyrichards</dc:creator>
      <dc:date>2011-07-08T15:49:17Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794467#M34415</link>
      <description>Well, I am still puzzled as to why we get different results and hope that someone can point out my errr/stupidity&lt;BR /&gt;&lt;BR /&gt;Files attached.&lt;BR /&gt;</description>
      <pubDate>Sun, 10 Jul 2011 11:21:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794467#M34415</guid>
      <dc:creator>llynisa</dc:creator>
      <dc:date>2011-07-10T11:21:53Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794468#M34416</link>
      <description>Why do your buttons have the BS_OWNERDRAW style? What happens if you remove that style?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 10 Jul 2011 12:56:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794468#M34416</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2011-07-10T12:56:03Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794469#M34417</link>
      <description>Removing BS_OWNERDRAW has no effect except that I can't redraw the button. GetWindowText returns 19 as before. I attach an image of what it looks like if I don't get the correct length of button text. As you may see, I am trying to colour pushbuttons, and although it is a rather simplified solution, it seems to be working well except for the text length bug.</description>
      <pubDate>Sun, 10 Jul 2011 19:43:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794469#M34417</guid>
      <dc:creator>llynisa</dc:creator>
      <dc:date>2011-07-10T19:43:30Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794470#M34418</link>
      <description>I can't open my own .bmp file when I click on it in my last post, so am repeating it as .jpg&lt;BR /&gt;</description>
      <pubDate>Sun, 10 Jul 2011 19:51:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794470#M34418</guid>
      <dc:creator>llynisa</dc:creator>
      <dc:date>2011-07-10T19:51:32Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794471#M34419</link>
      <description>In 
my experience, Windows will not let you run an EXE where command buttons
 have been given the BS_OWNERDRAW style, even if you can select 
Ownerdraw from the Properties sheets.</description>
      <pubDate>Sun, 10 Jul 2011 19:59:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794471#M34419</guid>
      <dc:creator>anthonyrichards</dc:creator>
      <dc:date>2011-07-10T19:59:53Z</dc:date>
    </item>
    <item>
      <title>Trouble with GetWindowText</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794472#M34420</link>
      <description>Tony,&lt;BR /&gt;&lt;BR /&gt;Yes, you are quite right on that normally, but if one adds Jugoslav's XFLogm one &lt;STRONG&gt;can&lt;/STRONG&gt; run them, as shown in his DlgTest program in his XEffort examples. I did not need to add the whole of his XEffort for this, just XFLogm.&lt;BR /&gt;&lt;BR /&gt;If I can crack this one, I hope to persuade you to reissue your Knowledge Base article How to customize dialog box colors using subclassing with my additions to colour the buttons.&lt;BR /&gt;&lt;BR /&gt;Llynisa aka BearofLittleBrain</description>
      <pubDate>Sun, 10 Jul 2011 20:42:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Trouble-with-GetWindowText/m-p/794472#M34420</guid>
      <dc:creator>llynisa</dc:creator>
      <dc:date>2011-07-10T20:42:42Z</dc:date>
    </item>
  </channel>
</rss>

