
Introduction
There is one problem if you have designed a dialog and you want to share it
with other people. For example: I thinking about creating a typical "Tip of the
Day" dialog able to read in a xml file. I wanted to share it with anyone who
needs it. The problem was: How can I distribute the code without messing around
with multiple resource scripts. I searched the Internet for a while and found
some information about the Windows API. It was rather easy, but it had some
nasty things you needed to look out for. Example all data had to be aligned at
DWORD boundaries. I found out is was really hard to create a dialog
without the dialog editor, so I wrote a small tool capable of parsing a resource
script and export a dialog from it. I packet those two things together and the
Resourceless Dialog Toolkit was born.
Using the code
I have spent a few hours to create documentation and a tutorial, so I'm
giving you a small class showing you how the code works.
class CSampleDlg: public CResourcelessDlg<CSampleDlg>,
public CWinDataExchange<CSampleDlg>
{
public:
BEGIN_MSG_MAP(CSampleDlg)
MSG_WM_INITDIALOG(OnInitDialog)
CHAIN_MSG_MAP(CResourcelessDlg<CSampleDlg>)
END_MSG_MAP()
BEGIN_DDX_MAP(CSampleDlg)
END_DDX_MAP()
void CreateDlg()
{
CreateDlgTemplate("About", DS_SETFONT|DS_MODALFRAME
|WS_CAPTION|WS_SYSMENU,
0, 0, 0, 186, 138, 8, "MS Sans Serif", "", "");
AddStatic("Dialog Extractor v1.0", 0, 0, 60, 20, 67, 8, IDC_STATIC);
AddStatic(IDR_MAINFRAME, SS_ICON, 0, 20, 20, 20, 20, 18);
AddButton("", 0 | BS_GROUPBOX, 0, 7, 7, 172, 103, IDC_STATIC);
AddStatic("(c) Copyright 2004", 0, 0, 60, 30, 58, 8, IDC_STATIC);
AddStatic("By: Trilobyte-Solutions", 0, 0, 60, 41, 70, 8, IDC_STATIC);
AddStatic("Updates and additional information about"
" this program can be found at
the Trilobyte Solutions website.", 0, 0, 60, 59, 113, 26, IDC_STATIC);
AddStatic("www.Trilobyte-Solutions.nl", 0, 0, 60, 94, 84, 8, IDC_STATIC);
AddButton("OK", 0|BS_DEFPUSHBUTTON, 0, 67, 117, 50, 14, IDOK);
}
LRESULT OnInitDialog(HWND, LPARAM)
{
DoDataExchange(false);
CenterWindow(GetParent());
return IDOK;
}
};
As you see it is really easy to use the code. More information can be
found in the documentation and tutorial inside the toolkit.
If you want to know more about the underlaying technique. Look one of the
following items up in the MSDN: DLGTEMPLATE,
DLGITEMTEMPLATE, CreateDialogIndirectParam and
DialogBoxIndirectParam. If there are enough request, I will write a
article about the Windows dialog API.
The Tip of the Day dialog
The dialog I told you about earlier in this article is not ready yet. At the
end of the next week it probably will be ready.
History
The code is version 1.0. The tool is version 1.1, there were some bugs found.
Additional Information
For additional information, questions and bug report, visit my website: http://www.trilobyte-solutions.nl/, or contact me at bertwillems@trilobyte-solutions.nl.
| You must Sign In to use this message board. |
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
 |
What do you mean with "there is no source code"? In the Toolkit there are two source files. The only reason I did not include the source code of the Dialog Extractor was that most people don't need it. The source code can be downloaded from my website. Look at the post "Source code of the Resource extractor?" for the direct download link.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
It is a bit confusing since it doesn't work quite the way it does with "normal" articles. I too went hunting trying to find the source code without realizing the toolkit had installed it. It would probably be helpful to include an explanation in your article (including telling them where the required header file is located so they can move it to where they need it). The "How to Use the Code" section you include in the ResourcelessDlg.htm would be useful here. Also, while you did add a link to the extractor code in your comments, it would be helpful to have that at the top of your article. Your tool blew up for me on the first .rc I tried it on (worked on the second), so I'll need to debug/fix it before I can use it. I couldn't find it on your web site because your site doesn't support large fonts, and critical links don't appear on my screen.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
1) Download the installer in CodeProject. http://www.codeproject.com/wtl/resourcelessdialogtoolkit/resourcelessdialogtoolkitinst.zip 2) Install the tool 3) Open explorer, and look the source in C:\Program Files\Trilobyte-Solutions\Resourceless Dialog Toolkit\Include
Thanks
Rodrigo Pinho Pereira de Souza
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Some bugs were found in this tool. The bugs are fixed, this article will be updated soon. The fixed toolkit can be downloaded from my website. If you have Dialog Extractor v1.1 you have the newest version.
Trilobyte
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I really like the idea of being able to export a dialog this way, no fuss about copy/pasting into rc files.
Too bad you didn't provide the source code of the resource extractor. As it is now, it crashes on some simple rc files.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
The file is not loaded:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /var/www/html/download.php on line 113 Access denied for user: 'ts@localhost.localdomain' (Using password: YES)
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Sorry about that, My website is under construction at the momement. If you want the file please send me an e-mail.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
1) Download the installer in CodeProject. http://www.codeproject.com/wtl/resourcelessdialogtoolkit/resourcelessdialogtoolkitinst.zip 2) Install the tool 3) Open explorer, and look the source in C:\Program Files\Trilobyte-Solutions\Resourceless Dialog Toolkit\Include
Thanks
Rodrigo Pinho Pereira de Souza
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
actualy you can "copy&paste" from .rc file dialog declaration (also needed constants be declared).
the idea of .rc is the same
---------------------------- never stop coding.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Basically this method enables you to reuse your dialogs without having to manually copy/paste and defining id's in the rc and resource.h files in each project you want to use the dialog.
So no, it is not needed, but it can be a great timesaver and really helps in writing code fit for distribution.
If you write international programs, this method can also help in writing dialogs for different languages, as the text of the controls can be set in the language you desire, without having to maintain multiple resource files and using satellite dlls for each language. The drawback is ofcourse that the layout of the controls must possibly be changed to allow for a translated text that doesn't fit in the control or overlaps other controls. In combination with a layout manager, this can be solved.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Another possible use would be a general purpose static library that needs to call a dialog. Normally, you would need to not only link to the library, but also include the .rc and matching .h file -- which of course would pull in the resource whether you needed it in the current application or not. By using this, the static library is self contained, and the data for the dialog is only pulled into the application that links to the function that puts up a dialog.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
If you write international programs, this method can also help in writing dialogs for different languages, as the text of the controls can be set in the language you desire, without having to maintain multiple resource files and using satellite dlls for each language.
You write that like it's a bad thing to have multiple resource files and satellite DLLs...
Just wait until you're on a large project with external localization, and you tell them that to update the dialogs they need Visual Studio licenses.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I am working on a large project which must support over 10 languages. Currently we are using satellite dll's. Our resource file is translated by an external translation company, which has the tools to read and modify them.
So, in that respect I agree with you, for large projects with several languages, separate resource files and satellite dll's have their uses.
However, my point was not to critisize the use of satellite dll's, but to comment on the alternative presented here, namely, a way of creating dialogs without the need for a resource file. For example, combine this with an external text file which has a key-value pair of resource id and text string (one file for each language you want to support), together with a flexible layout manager for the controls on your dialogs, and you have a nice alternative to satellite dll's.
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
|