Previous: GraphModeType To the Table of Content Next: Graphic result constants

- 4.37.1.9 -
Standard Units
Graph Unit
Graph Unit Types, Constants and Variables

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: GraphModeType To the Table of Content Next: Graphic result constants
GraphModeType Table of Content Graphic result constants

- 4.37.1.9 -