如何在不用Form等单元(包括KOL等控件)的情况下,弹出一个有标题的输入框?(类似EDIT 但有标题)
找了好久都找不到例子 高人指点一下吧,谢谢!delphi7下输入代码program Main;uses
Windows,Messages;Var
s:string;begin
s := '输入框标题'; //在这如何弹出一个以上面为标题的输入框 //然后MessageBox弹出输入的内容
MessageBox(0,PChar(输入的内容),'ok',0);
end.
找了好久都找不到例子 高人指点一下吧,谢谢!delphi7下输入代码program Main;uses
Windows,Messages;Var
s:string;begin
s := '输入框标题'; //在这如何弹出一个以上面为标题的输入框 //然后MessageBox弹出输入的内容
MessageBox(0,PChar(输入的内容),'ok',0);
end.
解决方案 »
- (纠结中...)三层系统,主从表打印,子表排序问题!
- 请教indyTcpserver的问题?
- 無.................................................題
- StringGrid的颜色显示
- 哪位大哥能够用delphi帮忙写个简单程序?
- 100分~!!有关SHELLEXCUTE难度很大的问题!想编写一个调用可执行程序,但扩展名不为EXE,想不让别人不通过我的主程序调用,
- 解释代码(就20多行)给分就,关于流FileStream
- 在用SQL语句查询时怎么让空的字段显示为0??
- 线程安全有什么具体含义?
- 新年好!大家好,为什么我的全局hook只对本进程有效,在别得界面按下按键都hook不到?
- DS捕捉摄像头视频
- 不同格式的TIF文件之间如何进行转换??
Forms,Dialogs,windows;{$R *.res}
var
value:string;
begin
//Application.Initialize;
//Application.Run;
if InputQuery('输入框','请输入内容',value) then
begin
MessageBox(0,pchar(value),pchar('标题'),0);
end;
end.
var Value: string): Boolean;
var
Form: TForm;
Prompt: TLabel;
Edit: TEdit;
DialogUnits: TPoint;
ButtonTop, ButtonWidth, ButtonHeight: Integer;晕哦哥们,你看这里是怎么声明的就知道了吗....
program Project1;uses
Dialogs,windows;{$R *.res}
var
value:string;
begin
if InputQuery('输入框','请输入内容',value) then
begin
MessageBox(0,pchar(value),pchar('标题'),0);
end;
end.
program PMyWindowClass;uses
Windows,
Messages,
SysUtils;type
TMyWindow = class(TObject)
private
{ Private declarations }
WindowClass: WndClass;
hWindow: HWnd;
AMessage: TMsg;
FAppName : String;
FWndProc : TFNWndProc; function WinRegister : Boolean; virtual;
procedure CreateMyWindow;
public
{ Public declarations }
constructor Create;
destructor Destroy; override;
procedure WinCreate; virtual;
procedure MyRun; property ApplicationName : String read FAppName write FAppName;
property WindowProcedure : TFNWndProc read FWndProc write FWndProc;
end;const
AppName = 'MyClassDemo';var
myWindow : TMyWindow;
Text : String = '';
{ TMyWindow }constructor TMyWindow.Create;
beginend;destructor TMyWindow.Destroy;
begin
inherited;
end;procedure TMyWindow.CreateMyWindow;
begin
hWindow := CreateWindow(AppName, '请按键...注:修改自《Inside VCL》',
ws_OverlappedWindow, cw_UseDefault, cw_UseDefault,
400, 60, 0, 0, system.MainInstance, nil); if hWindow <> 0 then begin
ShowWindow(hWindow, CmdShow);
ShowWindow(hWindow, SW_SHOW);
UpdateWindow(hWindow);
end;
end;procedure TMyWindow.WinCreate;
begin
if WinRegister then
begin
CreateMyWindow;
end;
end;function TMyWindow.WinRegister : Boolean;
begin
WindowClass.Style := cs_hRedraw or cs_vRedraw;
WindowClass.lpfnWndProc := FWndProc;
WindowClass.cbClsExtra := 0;
WindowClass.cbWndExtra := 0;
WindowClass.hInstance := system.MainInstance;
WindowClass.hIcon := LoadIcon(0, idi_Application);
WindowClass.hCursor := LoadCursor(0, idc_Arrow);
WindowClass.hbrBackground := GetStockObject(WHITE_BRUSH);
WindowClass.lpszMenuName := nil;
WindowClass.lpszClassName := PChar(FAppName); Result := RegisterClass(WindowClass) <> 0;
end;//
//Window Message Handling Procedure
//
function WindowProc(Window: HWnd; AMessage: UINT; WParam : WPARAM;
LParam: LPARAM): LRESULT; stdcall; export; var
dc : hdc;
ps : TPaintStruct;
r : TRect;begin
WindowProc := 0; case AMessage of
WM_CHAR:
begin
Text := Text + char(Byte(Wparam));
dc := GetDC(Window);
GetClientRect(Window,r);
DrawText(dc,PChar(Text),-1,r, DT_SINGLELINE);
ReleaseDC(Window, dc);
end;
WM_PAINT :
begin
dc := BeginPaint(Window,ps);
GetClientRect(Window,r);
DrawText(dc,PChar(Text),-1,r, DT_SINGLELINE);
EndPaint(Window,ps);
Exit;
end;
wm_Destroy:
begin
PostQuitMessage(0);
Exit;
end;
end; WindowProc := DefWindowProc(Window, AMessage, WParam, LParam);
end;procedure TMyWindow.MyRun;
begin
while GetMessage(AMessage, 0, 0, 0) do begin
TranslateMessage(AMessage);
DispatchMessage(AMessage);
end;
Halt(AMessage.wParam);
end;begin
myWindow := TMyWindow.Create;
myWindow.ApplicationName := AppName;
myWindow.WindowProcedure := TFNWndProc(@WindowProc);
myWindow.WinCreate;
try
myWindow.MyRun;
finally
FreeAndNil(myWindow);
end;
end.