能否得到屏幕绝对坐标? (100分)

  • 主题发起人 主题发起人 braveman77
  • 开始时间 开始时间
B

braveman77

Unregistered / Unconfirmed
GUEST, unregistred user!
请问大家我想利用API得到一个非delphi窗体(比如Word、Excel)中所选定部分(比如选定一句话)的屏幕坐标,能吗?似乎很难呀。<br>
 
GetCursorPos()<br>ClientToScreen()<br>ScreenToClient()<br>用这3个试试
 
具体怎么作呢?
 
其实 jrq 已经给出思路,下面是具体的实现:<br><br>procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,<br>&nbsp; Y: Integer);<br>var<br>&nbsp; p:TPoint;<br>begin<br>&nbsp; GetCursorPos(p);<br>&nbsp; ClientToScreen(p) ;<br>&nbsp; label1.caption:=format('x=%d ,y=%d',[p.x,p.y]);<br>end;<br>
 
GetWindowPos
 
jsxjd 说的够清楚的啦
 
谢谢大家,不过我的问题是如何取得非delphi的窗体内指定部分的坐标,而jsxjd你的方法是<br>在delphi窗体内将窗体坐标转换为绝对坐标。请大家继续关注此问题。
 
那你可以在 form 的 oncreate 中加一条 鼠标跟踪命令。
 
Mouse.CursorPos可以获取到鼠标在屏幕当前位置的坐标。
 
试试这个程序<br>只有一个dpr文件<br>你编译看看<br><br>// Win Inspector by DeK_OiN<br><br><br>program WinInspector;<br><br>uses<br>&nbsp; &nbsp;Windows,<br>&nbsp; &nbsp;Messages, SysUtils;<br><br>{$R *.RES}<br><br>var<br>&nbsp; &nbsp;GroupBox1, Fuente, Handle, About, Instancia,<br>&nbsp; &nbsp; &nbsp; lcPosX, lcPosY, cPosX, cPosY, LabelHandle, eHandle,<br>&nbsp; &nbsp; &nbsp; wNLabel, wName, cWLabel, cWindow, IDLabel, eThreadID: Integer;<br>&nbsp; &nbsp;Clase: TWndClassA;<br>&nbsp; &nbsp;Mensaje: TMsg;<br><br>// Esta procedure ser?llamada cada 1 milisegundo por el Timer que creamos<br>// con SetTimer. Adem醩 de eso, esto es lo que le da una utilidad al prog :)<br><br>procedure Timer;<br>var<br>&nbsp; &nbsp;cPos: TPoint;<br>&nbsp; &nbsp;hWnd: THandle;<br>&nbsp; &nbsp;wText: PChar;<br>&nbsp; &nbsp;WinClass: array[0..80] of Char;<br>&nbsp; &nbsp;stri:string;<br>begin<br>&nbsp; &nbsp;GetCursorPos(cPos); //Capturamos la posici髇 del cursor en la variabe cPos<br>&nbsp; &nbsp;SetWindowText(cPosX, PChar(IntToStr(cPos.X))); //Ponemos el X de la pos. del cursor en el edit,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //recuerda que estamos con la API y no podemos<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //hacer Edit1.Text := X sino que tenemos que<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //llamar a la API SetWindowText ;)<br><br><br><br><br><br>&nbsp; &nbsp;SetWindowText(cPosY, PChar(IntToStr(cPos.Y))); //Ponemos el Y de la pos. del cursor en el edit<br><br><br>&nbsp; &nbsp;SetWindowText(cposx,pchar( &nbsp; inttohex( &nbsp; GetPixel(GetDC(0),cpos.X,cpos.y) , 2) &nbsp; &nbsp;) &nbsp;);<br><br><br><br>//trabajaremos con handle de la ventana que est?debajo del cursor del mouse<br>&nbsp; &nbsp;hWnd := WindowFromPoint(cPos);<br><br>&nbsp; &nbsp;SetWindowText(eHandle, PChar(IntToHex(hWnd, 2))); //Mostramos el handle en el edit, ya pasado a base<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //16 (o sea, hexadecimal)<br><br>&nbsp; &nbsp;GetMem(wText, GetWindowTextLength(hWnd) + 1);<br>&nbsp; &nbsp;GetWindowText(hWnd, wText, GetWindowTextLength(hWnd) + 1); // extraemos el texto de la ventana que est?<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // debajo del cursor<br>&nbsp; &nbsp;SetWindowText(wName, wText); // y lo mostramos en el edit<br><br>&nbsp; &nbsp;SetWindowText(eThreadID, PChar(IntToHex(GetWindowThreadProcessID(hWnd, nil), 8)));<br><br><br>&nbsp; &nbsp;GetClassName(hWnd, WinClass, SizeOf(WinClass)); // obtenemos el class de la ventana y lo metemos en la variable WinClass<br>&nbsp; &nbsp;SetWindowText(cWindow, WinClass); // mostramos el class obtenido en el edit<br><br>end;<br><br>// Procedure para salir nuestro programa sin dejar rastros en la memoria :)<br><br>procedure Salir;<br>begin<br>&nbsp; &nbsp;DeleteObject(Fuente); //liberamos los recursos del sistema asociados a nuesta fuente<br>&nbsp; &nbsp;UnRegisterClass('DeKOiN', Instancia); //removemos el class de la memoria<br>&nbsp; &nbsp;ExitProcess(Instancia); //finalmente terminamos el proceso<br>end;<br><br>procedure MostrarAbout;<br>var<br>&nbsp; &nbsp;Parametros: TMsgBoxParams;<br>begin<br>// Definimos los par醡etros del MessageBoxIndirect<br>&nbsp; &nbsp;with Parametros do<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; cbSize := SizeOf(Parametros);<br>&nbsp; &nbsp; &nbsp; hwndOwner := handle;<br>&nbsp; &nbsp; &nbsp; hInstance := Instancia;<br>&nbsp; &nbsp; &nbsp; lpszText := 'Mini-WinIdentifier by DeK_OiN' + #13#10 +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'Programado en Delphi 5, usando solo la API de Windows, haciendo' + #13 +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'el ejecutable de unos 45 kbs y comprimido con UPX de unos 23kbs :)' + #13 + #13 +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'Por cierto, queda a 45 kbs por que uso las SysUtils xD';<br>&nbsp; &nbsp; &nbsp; lpszCaption := 'Acerca de Mini-WinIdentifer';<br>&nbsp; &nbsp; &nbsp; dwStyle := MB_OK or MB_USERICON;<br>&nbsp; &nbsp; &nbsp; lpszIcon := 'MAINICON';<br>&nbsp; &nbsp; &nbsp; dwContextHelpId := 0;<br>&nbsp; &nbsp; &nbsp; lpfnMsgBoxCallback := nil;<br>&nbsp; &nbsp; &nbsp; dwLanguageId := LANG_NEUTRAL;<br>&nbsp; &nbsp;end;<br>&nbsp; &nbsp;MessageBoxIndirect(Parametros); //Finalmente lo mostramos<br>end;<br><br><br>// WindowProc, procesamos todos los WindowMessages que nos env韆n...<br><br>function WindowProc(hWnd, uMsg, wParam, lParam: Integer): Integer; stdcall;<br>begin<br>// Llamamos a la procedure por defecto de Windows, para tambi閚 procesar<br>// los dem醩 mensajes que nuestra aplicaci髇 reciba. As?garantizamos que<br>// TODOS los mensajes que nos env韊n sean procesados. Haz la prueba, quita<br>// esta l韓ea y ver醩 que ni siquiera el WM_PAINT se procesa :)<br>&nbsp; &nbsp;Result := DefWindowProc(hWnd, uMsg, wParam, lParam);<br><br>//Ahora nos vamos a los mensajes m醩 espec韋icos<br>&nbsp; &nbsp;case uMsg of<br>&nbsp; &nbsp; &nbsp; WM_Destroy: Salir; //Si han presionado la X para salir<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //llamamos a nuestra procedure para<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //liberar los recursos del sistema<br>&nbsp; &nbsp; &nbsp; WM_TIMER: Timer; //Si nos mandan el mensaje WM_TIMER<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //(el cual se mandar?cada 1 milisegundo -<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //el interval del timer que creamos)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //ejecutamos nuestra procedure Timer;<br>&nbsp; &nbsp; &nbsp; WM_COMMAND: //Si nos mandan el WM_COMMAND<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if lparam = About then //vemos si el lParam del mensaje = al<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MostrarAbout; //handle del bot髇 About, y si lo es, es porque<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //閟te fue presionado por lo tanto llamamos a<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //nuestra procedure para mostrar los cr閐itos<br>&nbsp; &nbsp;end; //Terminamos con el CASE<br>end;<br><br>begin<br>&nbsp; &nbsp;Instancia := hInstance; //instancia del programa &nbsp;//本程序的唯一句柄<br><br><br>//la Win32Programmer's Reference :) //建立字体<br>&nbsp; &nbsp;Fuente := CreateFont(<br>&nbsp; &nbsp; &nbsp; -12,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; 400,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; DEFAULT_CHARSET,<br>&nbsp; &nbsp; &nbsp; OUT_DEFAULT_PRECIS,<br>&nbsp; &nbsp; &nbsp; CLIP_DEFAULT_PRECIS,<br>&nbsp; &nbsp; &nbsp; DEFAULT_QUALITY, DEFAULT_PITCH +<br>&nbsp; &nbsp; &nbsp; FF_DONTCARE,<br>&nbsp; &nbsp; &nbsp; 'MS Sans Serif');<br><br>//Definimos las partes del class de la ventana para luego registrarlo...<br>&nbsp; &nbsp;with Clase do<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; Style := CS_CLASSDC or CS_PARENTDC; //estilo<br>&nbsp; &nbsp; &nbsp; lpfnWndProc := @WindowProc; //apunta hacia nuestra funci髇 para procesar mensajes<br>&nbsp; &nbsp; &nbsp; hInstance := Instancia; //instancia de nuestra aplicaci髇<br>&nbsp; &nbsp; &nbsp; hIcon := LoadIcon(hInstance, 'MAINICON'); //el 韈ono<br>&nbsp; &nbsp; &nbsp; hbrBackGround := COLOR_BACKGROUND; //el color<br>&nbsp; &nbsp; &nbsp; lpszClassName := 'DeKOiN'; //el nombre<br>&nbsp; &nbsp; &nbsp; hCursor := LoadCursor(0, IDC_ARROW); //finalmente el cursor<br>&nbsp; &nbsp;end;<br><br>&nbsp; &nbsp;RegisterClass(Clase); //Registramos el class de nuestra ventana<br><br>//********************************************************************<br>//Comenzamos la creacion de la ventana y los controles de nuestro app<br>//********************************************************************<br><br>//Creamos la ventana principal<br>&nbsp; &nbsp;Handle := CreateWindowEx(//Handle := el handle de la ventana principal<br><br>&nbsp; &nbsp; &nbsp; WS_EX_WINDOWEDGE + //los estilos "extra"<br>&nbsp; &nbsp; &nbsp; WS_EX_TOPMOST, //de la ventana<br>&nbsp; &nbsp; &nbsp; 'DeKOiN', //nombre del class ( YA REGISTRADO ) de la ventana<br>&nbsp; &nbsp; &nbsp; 'WinInspector', //titulo de la ventana<br>&nbsp; &nbsp; &nbsp; WS_SYSMENU or //estilos de la ventana [Tiene los botones (Maximizar, Minimizar, Cerrar) en la titlebar]<br>&nbsp; &nbsp; &nbsp; WS_VISIBLE or // [Es visible]<br>&nbsp; &nbsp; &nbsp; WS_MINIMIZEBOX, // [Se puede minimizar]<br>&nbsp; &nbsp; &nbsp; 0, 0, // Queremos que la ventana aparezca en la esquina superior<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // izquierda de la pantalla, por lo tanto le asociamos lo que<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // normalmente ser韆n las propiedades "top" y "left" a 0<br>&nbsp; &nbsp; &nbsp; 179, 227, //dimensiones de la ventana [Ancho,Alto]<br>&nbsp; &nbsp; &nbsp; 0, 0, //mirar Win32 Programmer's reference :P<br>&nbsp; &nbsp; &nbsp; Instancia, // instancia de nuestra aplicaci髇<br>&nbsp; &nbsp; &nbsp; nil //puntero a los datos de creaci髇 de la ventana<br>&nbsp; &nbsp; &nbsp; );<br><br><br>//Creamos el bot髇 de about<br>&nbsp; &nbsp;About := CreateWindow(<br><br>&nbsp; &nbsp; &nbsp; 'Button', //nombre del class<br>&nbsp; &nbsp; &nbsp; 'About', //texto del bot髇<br>&nbsp; &nbsp; &nbsp; WS_VISIBLE or //estilos<br>&nbsp; &nbsp; &nbsp; WS_CHILD, //por detalles mirar Win32 Programmer's Reference<br>&nbsp; &nbsp; &nbsp; 1, 160, // X , Y del control<br>&nbsp; &nbsp; &nbsp; 89, 41, //dimensiones [Width, Height]<br>&nbsp; &nbsp; &nbsp; handle, //handle de nuestra aplicaci髇<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; Instancia, //instancia de nuestra aplicaci髇<br>&nbsp; &nbsp; &nbsp; nil //puntero a los datos de creaci髇 del control<br>&nbsp; &nbsp; &nbsp; );<br><br>//Creamos un "panel" para que el prog tenga un mejor aspecto<br>&nbsp; &nbsp;GroupBox1 := CreateWindowEx(<br><br>&nbsp; &nbsp; &nbsp; WS_EX_STATICEDGE,<br>&nbsp; &nbsp; &nbsp; 'Static',<br>&nbsp; &nbsp; &nbsp; 'Posici髇 del cursor',<br>&nbsp; &nbsp; &nbsp; WS_VISIBLE +<br>&nbsp; &nbsp; &nbsp; WS_DLGFRAME +<br>&nbsp; &nbsp; &nbsp; WS_CHILD,<br>&nbsp; &nbsp; &nbsp; 3, 3,<br>&nbsp; &nbsp; &nbsp; 100, 65,<br>&nbsp; &nbsp; &nbsp; handle,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; Instancia,<br>&nbsp; &nbsp; &nbsp; nil<br>&nbsp; &nbsp; &nbsp; );<br><br>//Creamos un editbox<br>&nbsp; &nbsp;cPosX := CreateWindowEx(<br><br>&nbsp; &nbsp; &nbsp; WS_EX_CLIENTEDGE, //este extended style es para que el edit tenga borde (sino nos queda flat)<br>&nbsp; &nbsp; &nbsp; 'Edit',<br>&nbsp; &nbsp; &nbsp; '', //texto del edit, lo dejamos vacio por ahora :)<br>&nbsp; &nbsp; &nbsp; WS_VISIBLE +<br>&nbsp; &nbsp; &nbsp; WS_CHILD +<br>&nbsp; &nbsp; &nbsp; SS_LEFT, //alineaci髇 IZQUIERDA<br>&nbsp; &nbsp; &nbsp; 23, 19,<br>&nbsp; &nbsp; &nbsp; 74, 21,<br>&nbsp; &nbsp; &nbsp; Handle,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; Instancia,<br>&nbsp; &nbsp; &nbsp; nil<br>&nbsp; &nbsp; &nbsp; );<br><br>//Creamos otro editbox<br>&nbsp; &nbsp;cPosY := CreateWindowEx(<br><br>&nbsp; &nbsp; &nbsp; WS_EX_CLIENTEDGE,<br>&nbsp; &nbsp; &nbsp; 'Edit',<br>&nbsp; &nbsp; &nbsp; '',<br>&nbsp; &nbsp; &nbsp; WS_VISIBLE +<br>&nbsp; &nbsp; &nbsp; WS_CHILD +<br>&nbsp; &nbsp; &nbsp; SS_LEFT,<br>&nbsp; &nbsp; &nbsp; 23, 42,<br>&nbsp; &nbsp; &nbsp; 74, 21,<br>&nbsp; &nbsp; &nbsp; Handle,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; Instancia,<br>&nbsp; &nbsp; &nbsp; nil<br>&nbsp; &nbsp; &nbsp; );<br><br>//Creamos una label<br>&nbsp; &nbsp;lcPosX := CreateWindow(<br><br>&nbsp; &nbsp; &nbsp; 'Static',<br>&nbsp; &nbsp; &nbsp; 'X:',<br>&nbsp; &nbsp; &nbsp; WS_VISIBLE +<br>&nbsp; &nbsp; &nbsp; WS_CHILD +<br>&nbsp; &nbsp; &nbsp; SS_LEFT,<br>&nbsp; &nbsp; &nbsp; 8, 20,<br>&nbsp; &nbsp; &nbsp; 13, 13,<br>&nbsp; &nbsp; &nbsp; Handle,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; Instancia,<br>&nbsp; &nbsp; &nbsp; nil<br>&nbsp; &nbsp; &nbsp; );<br><br>//Creamos otra label<br>&nbsp; &nbsp;lcPosY := CreateWindow(<br><br>&nbsp; &nbsp; &nbsp; 'Static',<br>&nbsp; &nbsp; &nbsp; 'Y:',<br>&nbsp; &nbsp; &nbsp; WS_VISIBLE +<br>&nbsp; &nbsp; &nbsp; WS_CHILD +<br>&nbsp; &nbsp; &nbsp; SS_LEFT,<br>&nbsp; &nbsp; &nbsp; 8, 42,<br>&nbsp; &nbsp; &nbsp; 13, 13,<br>&nbsp; &nbsp; &nbsp; Handle,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; Instancia,<br>&nbsp; &nbsp; &nbsp; nil<br>&nbsp; &nbsp; &nbsp; );<br><br>//Y otra label<br>&nbsp; &nbsp;LabelHandle := CreateWindow(<br><br>&nbsp; &nbsp; &nbsp; 'Static',<br>&nbsp; &nbsp; &nbsp; 'Handle:',<br>&nbsp; &nbsp; &nbsp; WS_VISIBLE +<br>&nbsp; &nbsp; &nbsp; WS_CHILD,<br>&nbsp; &nbsp; &nbsp; 111, 6,<br>&nbsp; &nbsp; &nbsp; 37, 13,<br>&nbsp; &nbsp; &nbsp; Handle,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; Instancia,<br>&nbsp; &nbsp; &nbsp; nil<br>&nbsp; &nbsp; &nbsp; );<br><br>//Otro edit m醩<br>&nbsp; &nbsp;eHandle := CreateWindowEx(<br><br>&nbsp; &nbsp; &nbsp; WS_EX_CLIENTEDGE,<br>&nbsp; &nbsp; &nbsp; 'Edit',<br>&nbsp; &nbsp; &nbsp; '',<br>&nbsp; &nbsp; &nbsp; WS_VISIBLE +<br>&nbsp; &nbsp; &nbsp; WS_CHILD +<br>&nbsp; &nbsp; &nbsp; SS_LEFT,<br>&nbsp; &nbsp; &nbsp; 111, 21,<br>&nbsp; &nbsp; &nbsp; 58, 21,<br>&nbsp; &nbsp; &nbsp; handle,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; Instancia,<br>&nbsp; &nbsp; &nbsp; nil<br>&nbsp; &nbsp; &nbsp; );<br><br>//Label...<br>&nbsp; &nbsp;wNLabel := CreateWindow(<br><br>&nbsp; &nbsp; &nbsp; 'Static',<br>&nbsp; &nbsp; &nbsp; 'Texto de la ventana:',<br>&nbsp; &nbsp; &nbsp; WS_VISIBLE +<br>&nbsp; &nbsp; &nbsp; WS_CHILD,<br>&nbsp; &nbsp; &nbsp; 2, 78,<br>&nbsp; &nbsp; &nbsp; 108, 13,<br>&nbsp; &nbsp; &nbsp; Handle,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; Instancia,<br>&nbsp; &nbsp; &nbsp; nil<br>&nbsp; &nbsp; &nbsp; );<br><br>//Edit...<br>&nbsp; &nbsp;wName := CreateWindowEx(<br><br>&nbsp; &nbsp; &nbsp; WS_EX_CLIENTEDGE,<br>&nbsp; &nbsp; &nbsp; 'Edit',<br>&nbsp; &nbsp; &nbsp; '',<br>&nbsp; &nbsp; &nbsp; WS_VISIBLE +<br>&nbsp; &nbsp; &nbsp; WS_CHILD +<br>&nbsp; &nbsp; &nbsp; SS_LEFT,<br>&nbsp; &nbsp; &nbsp; 2, 93,<br>&nbsp; &nbsp; &nbsp; 167, 21,<br>&nbsp; &nbsp; &nbsp; Handle,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; Instancia,<br>&nbsp; &nbsp; &nbsp; nil<br>&nbsp; &nbsp; &nbsp; );<br><br>//Label...<br>&nbsp; &nbsp;cWLabel := CreateWindow(<br><br>&nbsp; &nbsp; &nbsp; 'Static',<br>&nbsp; &nbsp; &nbsp; 'Clase de la ventana:',<br>&nbsp; &nbsp; &nbsp; WS_VISIBLE +<br>&nbsp; &nbsp; &nbsp; WS_CHILD +<br>&nbsp; &nbsp; &nbsp; SS_LEFT,<br>&nbsp; &nbsp; &nbsp; 2, 118,<br>&nbsp; &nbsp; &nbsp; 97, 13,<br>&nbsp; &nbsp; &nbsp; Handle,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; Instancia,<br>&nbsp; &nbsp; &nbsp; nil<br>&nbsp; &nbsp; &nbsp; );<br><br>//Edit...<br>&nbsp; &nbsp;cWindow := CreateWindowEx(<br><br>&nbsp; &nbsp; &nbsp; WS_EX_CLIENTEDGE,<br>&nbsp; &nbsp; &nbsp; 'Edit',<br>&nbsp; &nbsp; &nbsp; '',<br>&nbsp; &nbsp; &nbsp; WS_VISIBLE +<br>&nbsp; &nbsp; &nbsp; WS_CHILD +<br>&nbsp; &nbsp; &nbsp; SS_LEFT,<br>&nbsp; &nbsp; &nbsp; 2, 133,<br>&nbsp; &nbsp; &nbsp; 167, 21,<br>&nbsp; &nbsp; &nbsp; Handle,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; Instancia,<br>&nbsp; &nbsp; &nbsp; nil<br>&nbsp; &nbsp; &nbsp; );<br><br>//Label...<br>&nbsp; &nbsp;IDLabel := CreateWindow(<br><br>&nbsp; &nbsp; &nbsp; 'Static',<br>&nbsp; &nbsp; &nbsp; 'ID del thread:',<br>&nbsp; &nbsp; &nbsp; WS_VISIBLE +<br>&nbsp; &nbsp; &nbsp; WS_CHILD +<br>&nbsp; &nbsp; &nbsp; SS_LEFT,<br>&nbsp; &nbsp; &nbsp; 106, 160,<br>&nbsp; &nbsp; &nbsp; 72, 13,<br>&nbsp; &nbsp; &nbsp; Handle,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; Instancia,<br>&nbsp; &nbsp; &nbsp; nil<br>&nbsp; &nbsp; &nbsp; );<br><br>//Al fin!!, este es el 鷏timo control que creamos!!!!!!! - un edit<br>&nbsp; &nbsp;eThreadID := CreateWindowEx(<br>&nbsp; &nbsp; &nbsp; WS_EX_CLIENTEDGE,<br>&nbsp; &nbsp; &nbsp; 'Edit',<br>&nbsp; &nbsp; &nbsp; '',<br>&nbsp; &nbsp; &nbsp; WS_VISIBLE +<br>&nbsp; &nbsp; &nbsp; WS_CHILD +<br>&nbsp; &nbsp; &nbsp; SS_LEFT,<br>&nbsp; &nbsp; &nbsp; 112, 176,<br>&nbsp; &nbsp; &nbsp; 57, 21,<br>&nbsp; &nbsp; &nbsp; Handle,<br>&nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; Instancia,<br>&nbsp; &nbsp; &nbsp; nil<br>&nbsp; &nbsp; &nbsp; );<br><br>//********************************************************************<br><br>// Mandamos el mensaje WM_SETFONT para ponerle la fuente a los<br>// controles que acabamos de crear. Si tienes dudas sobre la API<br>// SendMessage o el mensaje WM_SETFONT consulta la Win32 Programmer's<br>// Reference<br><br>&nbsp; &nbsp;SendMessage(Handle, WM_SETFONT, Fuente, Handle); &nbsp; &nbsp; &nbsp; &nbsp; //字体设置<br>&nbsp; &nbsp;SendMessage(About, WM_SETFONT, Fuente, About);<br>&nbsp; &nbsp;SendMessage(GroupBox1, WM_SETFONT, Fuente, GroupBox1);<br>&nbsp; &nbsp;SendMessage(cPosX, WM_SETFONT, Fuente, cPosX);<br>&nbsp; &nbsp;SendMessage(cPosY, WM_SETFONT, Fuente, cPosY);<br>&nbsp; &nbsp;SendMessage(lcPosX, WM_SETFONT, Fuente, lcPosX);<br>&nbsp; &nbsp;SendMessage(lcPosY, WM_SETFONT, Fuente, lcPosY);<br>&nbsp; &nbsp;SendMessage(LabelHandle, WM_SETFONT, Fuente, LabelHandle);<br>&nbsp; &nbsp;SendMessage(eHandle, WM_SETFONT, Fuente, eHandle);<br>&nbsp; &nbsp;SendMessage(wNLabel, WM_SETFONT, Fuente, wNLabel);<br>&nbsp; &nbsp;SendMessage(wName, WM_SETFONT, Fuente, wName);<br>&nbsp; &nbsp;SendMessage(cWLabel, WM_SETFONT, Fuente, cWLabel);<br>&nbsp; &nbsp;SendMessage(cWindow, WM_SETFONT, Fuente, cWindow);<br>&nbsp; &nbsp;SendMessage(IDLabel, WM_SETFONT, Fuente, IDLabel);<br>&nbsp; &nbsp;SendMessage(eThreadID, WM_SETFONT, Fuente, eThreadID);<br><br>// Creamos un timer con el int閞valo de 1 milisegundo<br>&nbsp; &nbsp;SetTimer(handle, 0, 1, nil); //timer参数设置<br><br>// Bucle para recibir y procesar los mensajes de Windows que le llegan<br>// a nuestro programa<br>&nbsp; &nbsp;while (GetMessage(Mensaje, Handle, 0, 0)) do<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; TranslateMessage(Mensaje); //Convertimos cualquier mensaje del teclado a WM_CHAR<br>&nbsp; &nbsp; &nbsp; DispatchMessage(Mensaje); // Le pasamos el mensaje que nos envian a la funci髇<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // WindowProc para que 閟te sea procesado<br>&nbsp; &nbsp;end;<br><br>end.<br><br>
 
后退
顶部