With Windows 3.1 (win16), the DLL function/procedure names ignore the case.
With Windows 95 (win32), the function/procedure names are case-sensitive.
The SendMessage api definition is shown in various languages/compilers in order to demonstrate the api syntax variations.
Visual Basic 6.0
In order to improve readability (i.e. to get rid of the horizontal scroll bar), the Declare statements are presented here as folded. Notice that in a program, the entire Declare statement must be on a single line and that Private will be required is some cases. (In VB 6, the line continuation character - space, underscore, return - can be used to fold the Declare statement to multiple lines.)
The Windows API declarations (function prototypes), types, and constants are defined in
Additional help is available in vb4dll.txt (very good). However, I could not find a similar VB 6 file.
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, ByVal wMsg As Long, _ ByVal wParam As Long, lParam As Any) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, ByVal wMsg As Long, _ ByVal wParam As Long, lParam As Long) As Long Private Sub Combo1_GotFocus () Const CB_SHOWDROPDOWN = &H14F Dim Tmp Tmp = SendMessage(Combo1.hWnd, CB_SHOWDROPDOWN, 1, ByVal 0&) End Sub
Private Declare Function LockWindowUpdate Lib "User32" _ (ByVal hWnd As Long) As Long LockWindowUpdate List1.hWnd ' lock the window to prevent redrawing For x=1 to 500 List1.AddItem "Item " & CStr(x) Next x LockWindowUpdate 0 ' unlock display
You don't have to specify pointers (references), Access automatically converts variables for you. For example, just use String where a null terminated string should be used.
There is no equivalent for the Delphi nil pointer.
There is no mechanism to pass a pointer to a function using MS Access 97. Later versions use the AddressOf operator.
Unfortunately the examples (if you're lucky enough to find them) are in C!
None of the commands appear to be linked to associated examples. However, if you use the navigation buttons, the following clipboard examples (in C) are available.
Delphi programs access the Windows API by adding either WinTypes and WinProcs or, starting with Delphi 2.0, adding just Windows to the Uses clause.
By default, my Delphi programs have a Uses Windows, therefore I tried (attached to a button)
OpenClipboard(null); // should be nil in Delphi, null in c++ CloseClipboard;
The help explicitly says that the OpenClipboard parameter is either a Windows handle or Null. Yea, right. I tried empty parentheses and no parentheses. It wouldn't compile.
However, the following works.
OpenClipboard(0); // 0 means no window CloseClipboard;
With Delphi 5, from the menu select Help / Window SDK.
The trick is that the Windows documentation assumes c++ - as a result, the c++ null values must be coded as nil in Delphi.
All the parameter types used in the help can be used as is because they are defined in the windows unit.
interface type THandle = Integer; // These types match what is in help UINT = Integer; HWND = Integer; WPARAM = Longint; LPARAM = Longint; LRESULT = Longint; const user32 = 'user32.dll'; // The following was folded to improve readability // and should work either way function SendMessage(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; implementation function SendMessage; external user32 name 'SendMessageA';
LRESULT SendMessage( HWND hwnd, // handle of destination window UINT uMsg, // message to send WPARAM wParam, // first message parameter LPARAM lParam // second message parameter );
I could not find a way to define Windows API calls in a DPR file. Therefore, I defined them in a PAS (unit) file.
Notice that I was searching for the smallest executable. The programs which used Clipbrd.pas only required me to write one line of code, while the other 3 testcases required 30 lines of code.
|Test Case||exe Size||Version||exe Size||Version|
|Form with Clipbrd.pas||170 K||2.0|
|Just Clipbrd.pas||165 K||2.0||291 K||5.0|
|Button on Form||157 K||2.0|
|Just Windows.pas||14 K||2.0|
|Just Wins.pas||14 K||2.0||17 K||5.0|
LRESULT SendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
SendMessage(predoc->hwndRE, EM_SETTARGETDEVICE, (WPARAM) predoc->hdcTarget, (LPARAM) xWidth);