rsm, я перевел твою программу в делфи вот
| Код | const IDD_MAIN = 1001; IDD_CHILD = 1002; IDC_AW_SLIDE = 4003; IDC_AW_BLEND = 4004; IDC_AW_CENTER = 4005; IDC_AW_HOR_POS = 4006; IDC_AW_HOR_NEG = 4007; IDC_AW_VER_POS = 4008; IDC_AW_VER_NEG= 4009; IDC_EXIT = 4011;
IDC_SHWIN = 4001; IDC_INTERV = 4013; IDC_TEXT = 4002;
var Form1: TForm1; hInst:longword; hChildDlg, hShWin:HWND; hBrush:LongWord; hFont:integer; fShow:boolean = TRUE; Params: TCreateParams;
function GetAnimateFlags(hDlg:HWND):DWORD; var dwResult:DWORD; begin
if(IsDlgButtonChecked(hDlg, IDC_AW_SLIDE))<>0 then dwResult :=dwResult or AW_SLIDE;
if(IsDlgButtonChecked(hDlg, IDC_AW_BLEND))<>0 then dwResult :=dwResult or AW_BLEND;
if(IsDlgButtonChecked(hDlg, IDC_AW_CENTER))<>0 then dwResult :=dwResult or AW_CENTER;
if(IsDlgButtonChecked(hDlg, IDC_AW_HOR_POS))<>0 then dwResult :=dwResult or AW_HOR_POSITIVE;
if(IsDlgButtonChecked(hDlg, IDC_AW_HOR_NEG))<>0 then dwResult :=dwResult or AW_HOR_NEGATIVE;
if(IsDlgButtonChecked(hDlg, IDC_AW_VER_POS))<>0 then dwResult :=dwResult or AW_VER_POSITIVE;
if(IsDlgButtonChecked(hDlg, IDC_AW_VER_NEG))<>0 then dwResult :=dwResult or AW_VER_NEGATIVE;
result :=dwResult; end;
function ChildDialogProc( hwndDlg:hwnd; uMsg:uint; WPARAM: wParam; LPARAM: lParam) :boolean; stdcall; begin case (uMsg) of WM_INITDIALOG: begin hBrush:=GetStockObject(NULL_BRUSH); hFont:=CreateFont(20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Verdana'); SendDlgItemMessage(hwndDlg, IDC_TEXT, WM_SETFONT, hFont, 1); result:= TRUE; end; WM_CLOSE: begin DeleteObject(hBrush); DeleteObject(hFont); EndDialog(hwndDlg, 0); exit; end; WM_CTLCOLORSTATIC: begin SetTextColor( wParam, RGB(255, 0, 0)); SetBkMode( wParam, TRANSPARENT); result:= boolean(hBrush); end; end;//case Result:=FALSE;
end;
function MainDialogProc( hwndDlg:hwnd; uMsg:uint; WPARAM: wParam; LPARAM: lParam) :boolean; stdcall; //{ var UINT :LongWord; fTrans:LongBool; begin case uMsg of //
WM_CLOSE: begin EndDialog(hChildDlg, 0); EndDialog(hwndDlg, 0); exit; end; WM_INITDIALOG: begin hShWin:= GetDlgItem(hwndDlg, IDC_SHWIN); hChildDlg := CreateDialog(hInst, MAKEINTRESOURCE(IDD_CHILD), 0, @ChildDialogProc); SetDlgItemInt(hwndDlg, IDC_INTERV, 500, FALSE); SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE); result:= TRUE; end; WM_COMMAND: BEGIN //////// case LOWORD(wParam) of ////
IDC_EXIT: begin SendMessage(hwndDlg, WM_CLOSE, 0, 0); exit; end; IDC_SHWIN: begin uInt := GetDlgItemInt(hwndDlg, IDC_INTERV, fTrans, FALSE); if ( uInt=0) or (fTrans=false) then begin MessageBox(hwndDlg, 'Invalid interval value!', 'Error', MB_ICONERROR); exit; end; if(fShow) then begin SetWindowText(hShWin, '&Hide'); fShow:=FALSE; AnimateWindow(hChildDlg, uInt, GetAnimateflags(hwndDlg) + AW_ACTIVATE); ShowWindow(hChildDlg, SW_SHOW); end else begin SetWindowText(hShWin, '&Show'); fShow:=TRUE; AnimateWindow(hChildDlg, uInt, GetAnimateFlags(hwndDlg) + AW_HIDE); ShowWindow(hChildDlg, SW_HIDE); end; exit; end;//IDC_SHWIN
End;//case LOWORD(wParam) exit; end; // WM_COMMAND end; //case uMsg
result:=FALSE; end;
|
Только у меня возник вопрос. Как ты создал окно? С помощью DIALOGEX ?? А как для Делфи быть? Куда мне внедрить переведенный мною код? Я попробовал создать окно с CreateWindow. Вот
| Код | program CreateWindow;
uses Windows,messages;
{$R *.res}
var WindowClass: WndClassEx; Wnd: HWnd; Msg: TMsg;
function MainWinProc(hWnd : HWND; msg : uInt; wParam : WPARAM; lParam : LPARAM) : LRESULT; stdcall;
begin case msg of WM_Paint : exit; WM_DESTROY : PostQuitMessage(0); end; result := DefWindowProc(hWnd,msg,wParam,lParam);
end;
begin WindowClass.cbSize:=sizeof(WndClassEx); WindowClass.style:=CS_DBLCLKS or CS_OWNDC or CS_HREDRAW or CS_VREDRAW; WindowClass.lpfnWndProc:= @MainWinProc ; WindowClass.cbClsExtra:=0; WindowClass.cbWndExtra:=0; WindowClass.hInstance:=hinstance; WindowClass.hIcon:=LoadIcon(0,IDI_APPLICATION); WindowClass.hCursor:=LoadCursor(0, IDC_ARROW); WindowClass.hbrBackground:=GetStockObject(GRAY_BRUSH); WindowClass.lpszMenuName:=0; WindowClass.lpszClassName:='WindowClass'; WindowClass.hIconSm:=LoadIcon(0,IDI_APPLICATION);
RegisterClassEx(WindowClass); Wnd:= CreateWindowEx(0, 'WindowClass', 'Окно', WS_OVERLAPPEDWINDOW+WS_VISIBLE, 100, 100, 500, 400, 0, 0, HInstance, nil); ShowWindow(Wnd, CmdShow); UpdateWindow(Wnd); while GetMessage(Msg, 0, 0, 0) do begin TranslateMessage(Msg); DispatchMessage(Msg); end; //result:=msg.wParam;
end.
|
КАк мне внедрить твой код в программку для создания окна, что приведена выше.. Короче, хочу чтобы твой пример запускался на делфи. Т.е полностью перевести его... Помоги. |