<tdalign="right"valign="center"><imgsrc="logo32.png"align="right"width="64"height="32"border="0"></td></tr></table><h1align=center>Using TQt Standard Dialogs</h1>
[ <ahref="motif-walkthrough-2.html">Previous: Preparing to Migrate the User Interface</a> ]
[ <ahref="motif-walkthrough.html">Home</a> ]
[ <ahref="motif-walkthrough-4.html">Next: Using Custom TQDialogs</a> ]
<p> We start by using two of the <ahref="dialogs.html">TQt Standard
we create a TQMotifWidget, passing <tt>xmMainWindowWidgetClass</tt> as the <em>widgetclass</em> argument. We can now use the <ahref="qmotifwidget.html#motifWidget">TQMotifWidget::motifWidget</a>()
function to access the Motif widget. The shell widget is created
automatically by TQMotifWidget. We use <tt>XtParent()</tt> to access it.
The top-level window is now a TQMotifWidget, which means we can use it
as the parent for the TQt Standard Dialogs.
<p><pre></pre>
<p><h2> Replacing the <em>Open</em> and <em>Save As</em> Dialogs
</h2>
<aname="1"></a><p> First, we completely remove all use of the existing Motif file
selection dialog. We remove the <tt>Xm/FileSB.h</tt> include, the global <tt>file_dialog</tt> variable, and the code to create the dialog. We also
remove the <tt>PresentFDialog()</tt> callback function. None of this code
need to wrap more C header files and global variables in an <tt>extern "C"</tt> block.
<p>
<p><pre></pre>
<p> We need to forward declare the <tt>NewPage()</tt>, <tt>DeletePage()</tt>, <tt>EditPage()</tt> and <tt>SaveIt()</tt> functions so that the compiler generates
the correct symbols for these functions.
<p><pre></pre>
<p> We need to fix a single invalid pointer cast.
<p><pre></pre>
<p> And we need to change the variable named <em>new</em> to <em>newstr</em> in the <tt>Trim()</tt> function.
<p> We can now change the <tt>DeletePage()</tt> function to use
<p> The code for <tt>DeletePage()</tt> looks like this:
<p><pre></pre>
<p> At this point in the code, the page should be deleted. The code to do
this is in the <tt>DoDeletePage()</tt> function. We move the contents of <tt>DoDeletePage()</tt> to this point and remove the <tt>DoDeletePage()</tt> function
completely.
<p> Next, we change <tt>todo.cpp</tt> to pass the top-level <ahref="qmotifwidget.html">TQMotifWidget</a> as the
<tt>client_data</tt> tot he <tt>DeletePage()</tt> function.
<p>
<p><pre></pre>
<p> The <em>IO Error</em> dialog is created and used in <tt>io.c</tt>. We need to
migrate this file to C++. We rename it to <tt>io.cpp</tt>, modify the
project file and regenerate the <tt>Makefile</tt>.