Valhalla Legends Forums Archive | General Programming | Pascal MFC Library

AuthorMessageTime
Yegg
I've started a new project that will help make GUI programming with the MFC much easier, quicker, and of course less code. This was necessary for my use, but I figured why not create it for everyone? What I am creating is a DLL (mfc.dll) designed to create Windows GUI applications "the easy way". The DLL will include all widgets (or controls in Windows terminology) possible. I want my DLL to provide the user with the power of creating a GUI application through MFC without needing any knowledge of how MFC even works. I don't want to go on and on too much, so anyways, while I continue working on it. Here is some sample code (in Pascal) on how the DLL works.

[code]program WindowsApp;

procedure SetWindowProps(title, bgcolor, wcursor, ticon :pchar; hpos, vpos, width, height :integer); stdcall; external 'MFC';
procedure RegisterWindow; stdcall; external 'MFC';
procedure CreateWindow; stdcall; external 'MFC';
procedure StartMessages; stdcall; external 'MFC';

begin
  SetWindowProps('mfc app', 'lightgrey', 'cross', 'winlogo', 0, 0, 400, 400);
  RegisterWindow;
  CreateWindow;
  StartMessages;
end.[/code]

Incase you don't already know, this code imports 4 procedures. The first one IS necessary. The first argument 'mfc app' is the window title. The second is the background color, the third is the cursor type, the fourth is the "system" icon type. I havn't created a feature to load in custom icons since I've started this project just today, but it currently has two values. 'console' and 'winlogo'. The 5th and 6th arguments are the window positions. The first 0 should be recognized as horizontal, the second as vertical. And the last two arguments are the width and height (in that order) of the window. The next 3 functions register the window class, create the class, and then a procedure to start waiting for window "messages" is called. All 4 of these functions are needed to run the application. I am working on adding everything else MFC contains (that I feel is necessary). For instance, functions to create a button and its properties. Anyways, enough said. I would like to hear your comments on my project and possibly some suggestions.
October 10, 2005, 3:10 AM
Kp
May I be the first to point out that you're creating a wrapper around a wrapper around a widget set?  I suppose if you're not too concerned about code size or speed that's OK, but it seems like a bad idea to me. :)  Of course, anything involving MFC is a bad idea.
October 11, 2005, 12:35 AM
Yegg
Actually I decided to not use MFC. I decided to stick with just the traditional method of creating a Windows GUI. So the DLL will still be designed for the developement of a Windows GUI, however the library it is using will not be MFC. Also, what exactly do you mean by the code size and the speed? As of now the code size is not a problem and I've ran the application that is using the DLL on 3 different computers, one using WindowsME, two using Win2000 Pro. The application runs just as fast as any other application would run, I'm not quite sure what you mean by it being a bad idea. Or would this be a problem if I were using MFC?
October 11, 2005, 1:23 AM
Myndfyr
No.  See, MFC is just an object-oriented wrapper around the Windows API.  Thus, to be calling objects and methods of MFC from Pascal seems redundant; just make the calls directly to the Windows API to avoid code bloat, extra stub function calls, etc.
October 11, 2005, 5:31 AM
Yegg
But the point of this DLL is to simplify the use of MFC. Thus providing the user with simple functions that do the work for them, instead of them having to type out all of the code themselves, or having to learn the library if they do not know it.
October 11, 2005, 11:11 PM
Kp
[quote author=Yegg link=topic=12999.msg130716#msg130716 date=1129072280]But the point of this DLL is to simplify the use of MFC. Thus providing the user with simple functions that do the work for them, instead of them having to type out all of the code themselves, or having to learn the library if they do not know it.[/quote]

This may be a bit of a side trip, but could you explain why this could possibly be a good thing?  When last I looked at it, MFC wasn't a good idea to use, so it seems rather counterproductive to invest effort in letting people use it.
October 11, 2005, 11:55 PM
Yegg
[quote author=Yegg link=topic=12999.msg130653#msg130653 date=1128993804]
Actually I decided to not use MFC.
[/quote]
October 12, 2005, 1:11 AM
Kp
[quote author=Yegg link=topic=12999.msg130737#msg130737 date=1129079461]
[quote author=Yegg link=topic=12999.msg130653#msg130653 date=1128993804]
Actually I decided to not use MFC.
[/quote]
[/quote]

Yes, I saw that.  However, you used present tense in the post I quoted, which made it seem like you hadn't completely abandoned the idea.  Besides, even if you had abandoned it, I'd still like to know what drove you to pursue it in the first place.
October 13, 2005, 12:30 AM
Yegg
Well I figured that by creating a DLL to do the work of creating a Windows GUI for the user, people who did not currently know or understand the library could use this DLL without having to learn the actual coding themselves. Anyways, I've decided to drop the project, in the long run it probably wouldn't be much help anyways.
October 13, 2005, 12:48 AM

Search