Gracias a todos por responder a este tema que para mi es muy importante bueno con el ejemplo que me dieron quiesiera saber si lo puedo utilizar en una librería o en dll es tratado pero no logro ningun resultado espero q me puedan ayudar xD
Código Delphi
[-]library Project1;
uses
Windows,
Messages,
SysUtils;
var
Msg : TMSG;
LWndClass : TWndClass;
hMainHandle: HWND;
hButton : HWND;
hStatic : HWND;
hEdit : HWND;
hFontText : HWND;
hFontButton: HWND;
procedure ReleaseResources;
begin
DestroyWindow(hButton);
DestroyWindow(hStatic);
DestroyWindow(hEdit);
DeleteObject(hFontText);
DeleteObject(hFontButton);
PostQuitMessage(0);
end;
function WindowProc(hWnd,Msg:Longint; wParam : WPARAM; lParam: LPARAM):Longint; stdcall;
begin
case Msg of
WM_COMMAND: if lParam = hButton then
MessageBox(hMainHandle,'You pressed the button Hello', 'Hello',MB_OK or MB_ICONINFORMATION);
WM_DESTROY: ReleaseResources;
end;
Result:=DefWindowProc(hWnd,Msg,wParam,lParam);
end;
begin
LWndClass.hInstance := hInstance;
with LWndClass do
begin
lpszClassName := 'MyWinApiWnd';
Style := CS_PARENTDC or CS_BYTEALIGNCLIENT;
hIcon := LoadIcon(hInstance,'MAINICON');
lpfnWndProc := @WindowProc;
hbrBackground := COLOR_BTNFACE+1;
hCursor := LoadCursor(0,IDC_ARROW);
end;
RegisterClass(LWndClass);
hMainHandle := CreateWindow(LWndClass.lpszClassName,'Window Title', WS_CAPTION or WS_MINIMIZEBOX or WS_SYSMENU or WS_VISIBLE, (GetSystemMetrics(SM_CXSCREEN) div 2)-190,
(GetSystemMetrics(SM_CYSCREEN) div 2)-170, 386,200,0,0,hInstance,nil);
hFontText := CreateFont(-14,0,0,0,0,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,VARIABLE_PIT CH or FF_SWISS,'Tahoma');
hFontButton := CreateFont(-14,0,0,0,0,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,VARIABLE_PITCH or FF_SWISS,'Tahoma');
hStatic:=CreateWindow('Static','This is static text, like a TLabel',WS_VISIBLE or WS_CHILD or SS_LEFT, 10,10,360,44,hMainHandle,0,hInstance,nil);
SendMessage(hStatic,WM_SETFONT,hFontText,0);
hEdit:=CreateWindowEx(WS_EX_CLIENTEDGE,'Edit','This a Edit like and TEdit', WS_VISIBLE or WS_CHILD or ES_LEFT or ES_AUTOHSCROLL,10,35,360,23,hMainHandle,0,hInstance,nil);
SendMessage(hEdit,WM_SETFONT,hFontText,0);
hButton:=CreateWindow('Button','Hello', WS_VISIBLE or WS_CHILD or BS_PUSHBUTTON or BS_TEXT, 10,130,100,28,hMainHandle,0,hInstance,nil);
SendMessage(hButton,WM_SETFONT,hFontButton,0);
while GetMessage(Msg,0,0,0) do
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end.
procedure DllMain(reason: integer);
begin
case reason of
DLL_PROCESS_ATTACH:
begin
CreateThread(nil, 0, @WindowProc, nil, 0, 0);
end;
DLL_PROCESS_DETACH:
begin
end;
end;
end;
Gracias saludo