• Welcome to Valhalla Legends Archive.
 

Pascal MFC Library

Started by Yegg, October 09, 2005, 10:10 PM

Previous topic - Next topic

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.

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.


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.

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.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

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?

MyndFyre

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.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

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.

Kp

Quote from: Yegg on October 11, 2005, 06:11 PMBut 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.

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.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Yegg


Kp

Quote from: Yegg on October 11, 2005, 08:11 PM
Quote from: Yegg on October 10, 2005, 08:23 PM
Actually I decided to not use MFC.

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.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

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.