Delphi Tray Programming Combat

Source: Internet
Author: User
Tags function prototype

Many people think that Delphi is a RAD tool, including me in school when the Delphi also biased, now out of the "ivory Tower", involving a wide range of problems encountered, and slowly also have their own little experience. In fact, Delphi is based on the Object Pascal Language development tool, that is, Delphi is essentially a language tool, and is the real object-oriented. The following example I give is a tray with Delphi implementation of a small program. The program is short and clear, and I will explain the key parts in detail. Just like Mr. JJ to peel off the MFC layer by layer, today I have a "Sunding".

In the Delphi involves the system programming aspect to invoke the API function without exception, in the Shellapi.pas unit has to use the API function prototype.

Practical Walkthrough:

A Create a new application: File->new Applicaton defines a message constant in the interface section: const wm_nid=wm_user+1000; The system provides custom messages for users starting with Wm_user.

Two Define a global variable: Notifyicon:tnotifyicondata,notifyicon is a very important variable, the whole program is basically around the variable in the turn. Tnotifyicondata is a record type, hold down the CTRL key, and double-click the Tnotifyicondata to enter the Shellapi.pas cell. (Note: In Delphi, this is a very good source code analysis method, the source code to explain everything, you want to know the inside of the program, the best way is to analyze the source code!) The following assignment statement appears:

Tnotifyicondata = Tnotifyicondataa, which means that tnotifyicondata and tnotifyicondataa are the same data types, and then look down:

TNotifyIconDataA = _NOTIFYICONDATAA,意思与刚才的一样,再往下看:
type
_NOTIFYICONDATAA = record
cbSize: DWORD;
Wnd: HWND;
uID: UINT;
uFlags: UINT;
uCallbackMessage: UINT;
hIcon: HICON;
szTip: array [0..63] of AnsiChar;
end;

This is really "long-awaited began to come out, still hold pipa half cover." It is now clear that the global variable NotifyIcon that we have just defined is actually a variable of record type containing 7 components, which is equivalent to a struct variable in C + + (C + + programmers should be more familiar with it). Here we explain each of the 7 parts of the record type individually.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.