Previous: 4.37.1.8. GraphModeType To the Table of Contents Next: 4.37.1.10. Graphic result constants
4.37.1.8. GraphModeType Table of Contents 4.37.1.10. Graphic result constants

- 4.37.1.9. -
Table of Contents
4. Standard Units
4.37. Graph - Graph unit
4.37.1. Graph Unit Types, Constants, and Variables
4.37.1.9. GraphWndProc


4.37.1.9. GraphWndProc

Targets: Win32 only


Graph Unit

A function variable that processes the system messages sent to the graphical window.

Declaration:
var GraphWndProc: ^function (
                  Window: HWND;
                  Mess,
                  WParam,
                  LParam: LongInt): LongInt := nil;
Remarks:
Assign your own callback function to the GraphWndProc variable to process any message sent to the graphical window.

Example:
uses
  CRT, Windows, Messages, Graph;
{ Draws a message box }
procedure ShowBox;
begin
  SetFillColor(Random(256));
  Bar3D(200, 180, 440, 280, 0, FALSE);
  SetTextJustify(CenterText, CenterText);
  SetColor(clBlack);
  OutTextXY(321, 231, 'Click Here');
  SetColor(clWhite);
  OutTextXY(320, 230, 'Click Here');
end;

{ A custom message handler}
function MyWndProc(Window: HWND; Mess, WParam, LParam: LongInt): LongInt;
begin
  if (Mess = WM_LBUTTONDOWN) then
    if (LOWORD(lParam) > 200) and
       (LOWORD(lParam) < 440) and
       (HIWORD(lParam) > 180) and
       (HIWORD(lParam) < 280) then
      ShowBox
    else
      Beep(0, 0);
end;

 { Main program }
begin
  GraphWndProc := @MyWndProc;  // Install a custom message handler
  SetSVGAMode(640, 480, 8, 0); // Set desired video mode
  ShowCursor(TRUE);            // A custom message handler
  ShowBox;                     // Show a message box
  ReadKey;                     // Wait for any key
end.



Previous: 4.37.1.8. GraphModeType To the Table of Contents Next: 4.37.1.10. Graphic result constants
4.37.1.8. GraphModeType Table of Contents 4.37.1.10. Graphic result constants

- 4.37.1.9. -