Quelltext /~heha/messtech/pasmex.zip/DLGDEMO.PAS

library dlgdemo; {$N+,E-} {MATLAB setzt ohnehin Koprozessor voraus}
{$R dlgdemo}
{$D Pascal MEX Dialog Demo}
{$K+,W-,X+}

uses pasmex,WinProcs,WinTypes,Win31,strings;
type
 PDialogData=^TDialogData;
 TDialogData=record
  Number1,Number2: Double;
  Checkmark: Bool;
  RadioList: Word;
 end;

function EnumWindowsProc(Wnd:HWnd; lParam:LongInt):Bool; export;
 var
  ParentWndP: ^HWnd absolute lParam;
  S: array[0..31]of Char;
 const
  WindowTitle='Luftmessplatz';
 begin
  EnumWindowsProc:=true;
  GetClassName(Wnd,S,sizeof(S));
  if lstrcmpi(S,'figure8358')=0 then begin
   GetWindowText(Wnd,S,sizeof(S));
   if strLIComp(S,WindowTitle,lstrlen(WindowTitle))=0 then begin
    ParentWndP^:=Wnd;
    EnumWindowsProc:=false;
   end;
  end;
 end;

function DialogProc(Wnd:HWnd; Msg,wParam:Word; lParam:LongInt):Bool;
  export;
 var
  S: array[0..31]of Char;
  DD: PDialogData absolute lParam;
  E1,E2: Integer;
 begin
  DialogProc:=false;
  case Msg of
   WM_InitDialog: begin
    SetWindowLong(Wnd,DWL_User,lParam);
    Str(DD^.Number1:3:3,S); SetDlgItemText(Wnd,101,S);
    Str(DD^.Number2:3:3,S); SetDlgItemText(Wnd,102,S);
    CheckDlgButton(Wnd,103,Word(DD^.Checkmark));
    CheckDlgButton(Wnd,104+DD^.RadioList,1);
   end;

   WM_Command: case wParam of
    ID_OK: begin
     lParam:=GetWindowLong(Wnd,DWL_User);
     GetDlgItemText(Wnd,101,S,sizeof(S)); Val(S,DD^.Number1,E1);
     GetDlgItemText(Wnd,102,S,sizeof(S)); Val(S,DD^.Number2,E2);
     if (E1<>0) or (E2<>0) or (DD^.Number2<0) then begin
      MessageBox(Wnd,'Fehler in Zahlenwerten!',nil,MB_OK);
     end else begin
      DD^.Checkmark:=Bool(IsDlgButtonChecked(Wnd,103));
      DD^.RadioList:=0;
      for E1:=104 to 107 do begin {4 aufeinanderfolgende Buttons}
       if IsDlgButtonChecked(Wnd,E1)=1 then break; {Gecheckter Button}
       Inc(DD^.RadioList);
      end;
      EndDialog(Wnd,1);
     end;
    end;
    ID_Cancel: EndDialog(Wnd,0);
   end;
  end;
 end;

procedure mexFunction(nlhs:Integer; var plhs:TMatArr;
  nrhs:Integer; const prhs:TMatArr); export;
 var
  retval: Integer;
  DD: TDialogData;
  ParentWnd: HWnd;
  OldState: Bool;
 begin
  asm int 3 end;	{Debug-Möglichkeit}
  if nrhs=4 then begin	{Parameterliste füllen}
   ParentWnd:=hWndMATLABCmd;
   OldState:=EnableWindow(ParentWnd,false);
   EnumWindows(@EnumWindowsProc,LongInt(@ParentWnd));
   DD.Number1:=mxGetScalar(prhs[0]);
   DD.Number2:=mxGetScalar(prhs[1]);
   DD.Checkmark:=mxGetScalar(prhs[2])<>0.0;
   DD.RadioList:=LoWord(Trunc(mxGetScalar(prhs[3])));
   retval:=DialogBoxParam(hInstance,MakeIntResource(100),ParentWnd,
     @DialogProc,LongInt(@DD));
   if retval=1 then begin {Dialog mit OK beendet}
    mxGetPr(prhs[0])^:=DD.Number1; {Parameterliste "leeren"}
    mxGetPr(prhs[1])^:=DD.Number2;
    mxGetPr(prhs[2])^:=Word(DD.Checkmark);
    mxGetPr(prhs[3])^:=DD.RadioList;
   end;
   plhs[0]:=mxCreateFull(1,1,mxREAL);
   mxGetPr(plhs[0])^:=retval;
   EnableWindow(hWndMATLABCmd,not OldState);
  end else mexErrMsgTxt('Argumente-Fehler! (4)');
 end;

exports
 set_entry_point index 2,
 mexFunction 	 index 3,
 mexAtExitFcn	 index 4;

begin
end.
Vorgefundene Kodierung: UTF-80