我想写一个界计设计器,这个界面设计器可以根据数据库的结构自动生成与表格对应的控件,并可以对数据进行操作。但是在设计的过程中碰到了几个问题:
1。生成了与字段对应的控件后,字段的大小只能固定,并且控件的摆放位置较死板,只能按表中的字段顺序依次排放。能不能用户在建立和个模板时能对控件进行位置和大小调整。
2。我写了一个通用控件来控制各位数据类型的操作,可以应用于字符型,整数型,浮点型,引用型(双击控件可以弹出一个模态窗口从另一个代码定义表中选择数据),但是对日期时间型的数据即碰到了麻烦,想设计一个像WINDOWS里面的IP地址输入框,可以在中间显示一个分隔符,并自动判断各小节数据输入的正确性,却未能办到。
3。一个小问题,就是我在自动生成控件时, 控件左边的标签用中文字时,DELPHI的中文缺陷导致有一部分字符无法显示出来。不知哪位高手能不能帮我解决上述问题,小弟感激不尽。分不够可另开贴献上。
欢聊与我QQ交谈:394503696

解决方案 »

  1.   

    第二个问题,可以参考下面的代码:
    --------------------------------
    use the IP Address Control in a Form?  
    Autor: Edgar Joel Rodriguez Avalos  
    1 Comment(s) to this tip [Write new comment] 
    [ Print tip ]     Tip Rating (16):   
          {
      Microsoft® Internet Explorer Version 4.0 introduces the IP address control,
      a new control similar to an edit control that allows the user to enter a
      numeric address in Internet protocol (IP) format.
      This format consists of four three-digit fields.
      Each field is treated individually; the field numbers are zero-based and
      proceed from left to right as shown in this figure.  Further informations
      http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/ipaddress/ipaddress.asp
    }unit Unit1;interfaceuses
      Windows, Messages, Classes, Forms, Controls, StdCtrls, ExtCtrls;type
      TForm1 = class(TForm)
        IPAddress: TBevel;
        SetIP: TButton;
        ClearIP: TButton;
        procedure FormCreate(Sender: TObject);
        procedure SetIPClick(Sender: TObject);
        procedure ClearIPClick(Sender: TObject);
      private
        FIPAddress: Longint;
        HIPAddress: HWND;
        PrevWndProc: TWndMethod;
        procedure NewWindowProc(var Message: TMessage);
      public
      end;var
      Form1: TForm1;implementation{$R *.dfm}uses
      CommCtrl;const
      IP_ADDRESS_ID: Longword = $0100;procedure TForm1.FormCreate(Sender: TObject);
    var
      lpInitCtrls: TInitCommonControlsEx;
    begin
      lpInitCtrls.dwSize := SizeOf(TInitCommonControlsEx);
      lpInitCtrls.dwICC  := ICC_INTERNET_CLASSES;
      if InitCommonControlsEx(lpInitCtrls) then 
      begin
        PrevWndProc := WindowProc;
        WindowProc  := NewWindowProc;    HIPAddress := CreateWindowEx(WS_EX_LEFT, WC_IPADDRESS, nil,
          WS_CHILD + WS_VISIBLE + WS_BORDER + WS_TABSTOP,
          IPAddress.Left, IPAddress.Top, IPAddress.Width, IPAddress.Height,
          Handle, IP_ADDRESS_ID, HInstance, nil);
        SendMessage(HIPAddress, IPM_SETFOCUS, 0, 0);
      end;
    end;procedure TForm1.NewWindowProc(var Message: TMessage);
    var
      nField: longint;
    begin
      case Message.Msg of
        WM_NOTIFY: 
          begin
            if PNMHDR(Ptr(Message.lParam)).idFrom = IP_ADDRESS_ID then 
            begin
              case PNMIPAddress(ptr(Message.lParam)).hdr.code of
                IPN_FIELDCHANGED: 
                  begin
                    if SendMessage(HIPAddress, IPM_ISBLANK, 0, 0) = 0 then
                      SendMessage(HIPAddress, IPM_GETADDRESS, 0, lParam(LPDWORD(@FIPAddress)));
                  end;
              end;
            end;
          end;
        WM_COMMAND: 
          begin
            if Message.WParamLo = IP_ADDRESS_ID then
              case Message.WParamHi of
                EN_SETFOCUS: 
                  begin
                    nField := SendMessage(HIPAddress, IPM_GETADDRESS, 0,
                      lParam(LPDWORD(@FIPAddress)));
                    if nField = 4 then nField := 0;
                    SendMessage(HIPAddress, IPM_SETFOCUS, wParam(nField), 0);
                  end;
                EN_KILLFOCUS: 
                  begin
                    if SendMessage(HIPAddress, IPM_ISBLANK, 0, 0) = 0 then
                      SendMessage(HIPAddress, IPM_GETADDRESS, 0, lParam(LPDWORD(@FIPAddress)));
                  end;
                EN_CHANGE: 
                  begin
                  end;
              end;
          end;
      end;
      if Assigned(PrevWndProc) then PrevWndproc(Message);
    end;procedure TForm1.SetIPClick(Sender: TObject);
    begin
      FIPAddress := MAKEIPADDRESS(127, 0, 0, 1);
      SendMessage(HIPAddress, IPM_SETADDRESS, 0, lParam(DWORD(FIPAddress)));
    end;procedure TForm1.ClearIPClick(Sender: TObject);
    begin
      SendMessage(HIPAddress, IPM_CLEARADDRESS, 0, 0);
    end;end.
      

  2.   

    错别字真多,看来delphi对于汉字就是不怎么支持哈!
      

  3.   

    第一个问题,可以为该控件写个字断的编辑窗口进行调整!
    第二问题,应该继承MASKEDIT类来编写控件!
    第三问题,DELPHI的中文缺陷导致有一部分字符无法显示出来,难道不能调整字体吗?像宋体...?