国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

最小的程序

2019-11-18 18:50:33
字體:
來源:轉載
供稿:網友

PRogram testwindow;

uses
  Windows,
  Messages;

var
  WinClass: TWndClassA;
  Inst, Handle, Button1, Label1, Edit1: Integer;
  Msg: TMsg;
  hFont: Integer;

{ Checks if typed passWord is 'Amigreen' and shows Message }
procedure CheckPassword;
var
  Textlength: Integer;
  Text: PChar;
begin
  TextLength := GetWindowTextLength(Edit1);
  if TextLength = 8 then
  begin
    GetMem(Text, TextLength + 1);
    GetWindowText(Edit1, Text, TextLength + 1);
    if Text = 'Amigreen' then
    begin
      MessageBoxA(Handle, 'Password is correct.', 'Password check', MB_OK);
      FreeMem(Text, TextLength + 1);
      Exit;
    end;
  end;
  MessageBoxA(Handle, 'Password is incorrect.', 'Password check', MB_OK);
end;

{ Custom WindowProc function }
function WindowProc(hWnd, uMsg, wParam, lParam: Integer): Integer; stdcall;
begin
  Result := DefWindowProc(hWnd, uMsg, wParam, lParam);
  { Checks for messages }
  if (lParam = Button1) and (uMsg = WM_COMMAND) then
    CheckPassword;
  if uMsg = WM_DESTROY then
    Halt;
end;

begin
  { ** Register Custom WndClass ** }
  Inst := hInstance;
  with WinClass do
  begin
    style              := CS_CLASSDC or CS_PARENTDC;
    lpfnWndProc        := @WindowProc;
    hInstance          := Inst;
    hbrBackground      := color_btnface + 1;
    lpszClassname      := 'AG_TESTWINDOW';
    hCursor            := LoadCursor(0, IDC_ARROW);
  end; { with }
  RegisterClass(WinClass);

  { ** Create Main Window ** }
  Handle := CreateWindowEx(WS_EX_WINDOWEDGE, 'AG_TESTWINDOW', 'Amigreen TestWindow 1.00',
                           WS_VISIBLE or WS_SIZEBOX or WS_CAPTION or WS_SYSMENU,
                           363, 278, 305, 65, 0, 0, Inst, nil);
  { ** Create a button ** }
  Button1 := CreateWindow('Button', 'OK', WS_VISIBLE or WS_CHILD or BS_PUSHLIKE or BS_TEXT,
                           216, 8, 75, 25, handle, 0, Inst, nil);
  { ** Create a label (static) ** }
  Label1 := Createwindow('Static', ', WS_VISIBLE or WS_CHILD or SS_LEFT,
               8, 12, 76, 13, Handle, 0, Inst, nil);

  { ** Create an edit field ** }
  Edit1 := CreateWindowEx(WS_EX_CLIENTEDGE, 'Edit', ', WS_CHILD or WS_VISIBLE or
                          WS_BORDER or ES_PASSWORD, 88, 8, 121, 21, Handle, 0, Inst, nil);

  { ** Create Font Handle ** }
  hFont := CreateFont(-11, 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET,
                      OUT_DEFAULT_PRECIS, CLip_DEFAULT_PRECIS, DEFAULT_QUALITY,
                      DEFAULT_PITCH or FF_DONTCARE, 'MS Sans Serif');

  { Change fonts }
  if hFont <> 0 then
  begin
    SendMessage(Button1, WM_SETFONT, hFont, 0);
    SendMessage(Label1, WM_SETFONT, hFont, 0);
    SendMessage(Edit1, WM_SETFONT, hFont, 0);
  end;
  { Change label (static) text }
  SetWindowText(Label1, 'Enter password:');
  { Set the focus to the edit control }
  SetFocus(Edit1);

  UpdateWindow(Handle);

  { ** Message Loop ** }
  while(GetMessage(Msg, Handle, 0, 0)) do
  begin
    TranslateMessage(msg);
    DispatchMessage(msg);
  end; { with }
end.


上一篇:COM與DCOM的區別與聯系

下一篇:與文件相關Api函數列表

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
學習交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 新兴县| 邮箱| 屏东市| 扬中市| 志丹县| 南漳县| 鄱阳县| 阿尔山市| 沁水县| 古丈县| 黑水县| 西藏| 玉门市| 新干县| 西昌市| 林口县| 定州市| 安福县| 通渭县| 察雅县| 景洪市| 顺义区| 叙永县| 百色市| 庆阳市| 安仁县| 潜山县| 石台县| 普格县| 惠来县| 镇宁| 教育| 乐昌市| 宁城县| 栾城县| 无极县| 永德县| 曲沃县| 铅山县| 绥阳县| 且末县|