Wednesday, November 30, 2005

[Delphi] Avoid Auto Generated Accelerator Key in ActionList

To my greate pleasure, my coursework, a PL/x compiler, is basically completed. It can now compile/run a program prints all prime numbers within 1-100.

Then, I plan to build a proper IDE for it. I get two powerful tools -- SyncEdit and ActionManager. SyncEdit is an open-source VCL component, I guess whether such apps like Ultra-Edit use this component. ActionMananger is a better choice than ActionList + ToolBar + Menu. ActionManager behaves just the same as MS Office Toobars/Menus. All the stuffs are based on actions and item on display can be customized. For example, add/remove buttons on toolbar or menu, hide/show toolbar, re-arrange toolbars...

One problem I met with is the auto-generated accelerator-key provided by delphi. If I don't define a (&*) key in the caption property of an TAction object, Delphi will provide one in alphabit-reverse sequence. That's annoying sometimes.

However, I find out a way to get away from them: append a '&' char at the end of each action caption.

Tuesday, November 29, 2005

Take Care When Changing FormStyle in Delphi

A new bug from my assessment-tool project pops up this morning. I wrote a Hotkey Configuration Component which enables the users to define their preferred hotkey mode for certain provided functions. On the other hand, there is an 'Always on Top' menu item in the main form. I found that every time I changed the formStyle between 'fsAlwaysOnTop' and 'fsNormal' all my registered hotkeys were inactivated.

Then I refer to the VCL Help, it says in the document:

TCustomForm.FormStyle
Note: It is not advisable to change FormStyle at runtime.


And then, I made a experiment to see why it's 'not advisable'. I guess that would be problems with Handle of form.

ShowMessage(IntToStr(Handle);
if Self.FormStyle <> fsStayOnTop then
Self.FormStyle := fsStayOnTop
else
Self.FormStyle := fsNormal;
ShowMessage(IntToStr(Handle);


Yes, when FormStyle property is changed, the Handle of the form will be re-allocated. As a result, all hotkey message(WM_HOTKEY) were not received by the form with new handle.

My solution for this bus is to deactivate all hotkeys before changing FormStyle and then re-activate them after the change.

But, I still wonder whether there are yet any other traps here.

Monday, November 28, 2005

Hello Blogger

Hello World!
My name is Cai Shao Ting. I'm a senior student in Computer Science Technology in East China Normal University. I'm interested in programming and I open this blog to meet friends sharing the same interest with me.

I've been programming on Delphi 7 for about 2 years. I have 2 social project experience. One is VisualBasic+MSAccess application for information management of public physics lab. The other one is Delphi+MySQL MIS application for the local Sanitation bureau.

Currently, I'm working on 2 projects.
One is the course work for "Compiler Principle Practice". The goal is to implement a simple PL/x language compiler. I've completed the programe parser, compiler and the virtual machine. Next, I will design a proper IDE for the compiler and try extend the language in such aspects as grammer definition and error checking.
Another one is a Delphi project which is component-framework application for assessment of ERP software. The project aims at designing a flexible tool for creating computer-based examination and tranning. In this version, our assessment target is Microsoft Axapta. Our team has established a framework for our goal. My work concerns more on then component part. We learnt a lot from the VCL framework of Delphi, so I implemented a set of similar components such as Property Editor and Object Inspector. There is also a standard interface between the communication between our customized controls and the framework. From the very beginning, our project manager just intended to implement a compact version of Delphi.
Now the first version is going to be released, so we are now busy with testing.
Though this is not my first project, but I think this is the most formal one among others.

As you can see, I prefer Delphi as my first weapon. However, I don't resist any other programming language or IDEs. I'm in favor of programming as that a kind of magical work in my mind, in addition, I'm curiosity at any programe languages. Most of my school work are implemented under Visual C++ 6.0. Regarding browser-based applications, I uses Jbuilder on Jsp/Servlet. I've always been looking for a chance to step into the .Net world. But it has not come yet.

This blog will record my progress and I think this would be a good chance to practise my written English. Also, I'll be glad to talk with any of you who are interested in my study and project.