500分求关于DLL中,如何动态加载JPEG图片的问题?

解决方案 »

  1.   

    procedure TForm1.FormCreate(Sender: TObject);
    begin
      BorderStyle := bsnone;
      Image1.Align := alClient;
      timer1.Enabled := True;
    end;procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      sleep(30000);
        timer1.Enabled := False;
        self.BorderStyle :=  bsSizeable;
    end;以上是你的部分要求,至于你所谓的动态加载,似乎没有说清楚。是指图片不固定?随机加载图片?还是?
      

  2.   

    你动态创建个OPENDialogs或者OPENPIETUREDialogs 去打开图片,然后再传给FORM?
      

  3.   


     是不是在DLL中显示一个窗体,然后窗体加载一个图片,再然后不能关闭
      

  4.   

    上面的是我測試的文件,不是Dll  library Project2;uses 
        Windows, Messages, SysUtils,Dialogs;var 
      TheMessage: TMsg; 
      OurWindow: HWND; 
      ThreadID: DWORD;{$R *.RES}
    {$R Img.RES}procedure TimerFun(); 
    {$J+} 
    const 
      TotalInterval: DWORD = 0;
    {$J-}
    begin 
      if TotalInterval = 6 then
      begin
        ShowWindow(OurWindow, SW_SHOWNORMAL);
        TotalInterval := 0;
        Exit;
      end;
      ShowWindow(OurWindow, SW_HIDE);
      TotalInterval := TotalInterval + 1;
    end;{The window procedure for our hardcore API window} 
    function WindowProc(TheWindow: HWnd; TheMessage, WParam,
      LParam: Longint): Longint; stdcall; export;
    const
    {$J+}
      cxSource: Integer = 0;
      cySource: Integer = 0;
      hBitmap: Integer = 0;
    {$J-}
    var
      bitmap:TBitmap;
      hdcWnd, hdcMem: HDC;
      ps: TPaintStruct;
    begin
      Result :=0;
      case TheMessage of
        {upon getting the WM_DESTROY message, we exit the application}
        WM_DESTROY: begin
            PostQuitMessage(0);
          end;    WM_CREATE: begin
            {CreateWindow('static',
              '斕疑ㄛ攬衭',
              WS_CHILD or WS_VISIBLE or SS_LEFT,
              0,
              0,
              300,
              20,
              TheWindow,
              2008, {ControlID
              hInstance,
              nil);  }
            SetTimer(OurWindow, 2009, 5000, @TimerFun);
            //ShowTime := GetTickCount;
            //status := True;
            DeleteMenu(GetSystemMenu(TheWindow,False),SC_MOVE,MF_BYCOMMAND);
            hBitmap := LoadBitmap(hInstance, 'Img');
            GetObject(hBitmap, SizeOf(TBitmap), @bitmap);
            cxSource := bitmap.bmWidth;
            cySource := bitmap.bmHeight;
            SetWindowLong(TheWindow,GWL_STYLE,GetWindowLong(TheWindow,GWL_STYLE)and (not WS_MAXIMIZEBOX)and(not WS_SIZEBOX)and (not WS_MINIMIZEBOX));
          end;
        WM_PAINT:
        begin
          hdcWnd := BeginPaint(TheWindow, ps);
          hdcMem := CreateCompatibleDC(hdcWnd);
          SelectObject(hdcMem,hBitmap);
          BitBlt(hdcWnd,0,0,cxSource,cySource,hdcMem,0,0,SRCCOPY);
          DeleteDC(hdcMem);
          EndPaint(TheWindow,ps);
        end;
        WM_CTLCOLORSTATIC: begin
            SetBkMode(HDC(WParam), TRANSPARENT);
            Result := GetStockObject(NULL_BRUSH);
            Exit;
          end;
        WM_CLOSE: begin
            ShowWindow(OurWindow, SW_HIDE);
            //ShowTime := GetTickCount;
            //status := False;
          end;
           end;  {call the default window procedure for all unhandled messages}
      if TheMessage <> wm_close then
        Result := DefWindowProc(TheWindow, TheMessage, wParam, lParam);
      //CallWindowProc(Pointer(PreWndProc), TheWindow, TheMessage, wParam,//lParam);
    end;
    function RegisterClass: Boolean; 
    var 
      WindowClass: TWndClass; 
    begin 
      {setup our new window class} 
      WindowClass.Style := CS_HREDRAW or CS_VREDRAW;          {set the class styles} 
      WindowClass.lpfnWndProc := @WindowProc;                  {point to our window procedure} 
      WindowClass.cbClsExtra := 0;                            {no extra class memory} 
      WindowClass.cbWndExtra := 0;                            {no extra window memory} 
      WindowClass.hInstance := hInstance;                      {the application instance} 
      WindowClass.hIcon := LoadIcon(0, IDI_APPLICATION);      {load a predefined logo} 
      WindowClass.hCursor := LoadCursor(0, IDC_ARROW);      {load a predefined cursor} 
      WindowClass.hbrBackground := HBRUSH(COLOR_BACKGROUND);  {use a predefined color} 
      WindowClass.lpszMenuName := nil;                        {no menu} 
      WindowClass.lpszClassName := 'TestClass';                {the registered class name}   {now that we have our class set up, register it with the system} 
      Result := Windows.RegisterClass(WindowClass) <> 0; 
    end; procedure DllEntry; stdcall;
    var
       ScreenHeight : integer;
       ScreenWidth  : integer;
       aLeft,aTop   : integer;begin 
      {register our new class first} 
      if not RegisterClass then 
      begin 
        MessageBox(0,'RegisterClass failed',nil,MB_OK); 
        Exit; 
      end;   {now, create a window based on our new class} 
      OurWindow := CreateWindowEx(0,                    {no extended styles} 
                                  'TestClass',          {the registered class name} 
                                  '2009 陔爛辦氈',    {the title bar text}
                                  WS_OVERLAPPEDWINDOW or WS_VISIBLE, 
                                  100,        {default horizontal position} 
                                  100,        {default vertical position} 
                                  800,        {default width}
                                  600,        {default height}
                                  0,{handle of the parent window}
                                  0,                    {no menu} 
                                  hInstance,            {the application instance} 
                                  nil                    {no additional information} 
                                  );   {if our window was not created successfully, exit the program} 
      if OurWindow=0 then 
      begin 
        ShowMessage('CreateWindow Error!'); 
        Exit; 
      end; 
      
      SetWindowPos(OurWindow , HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or
              SWP_NOSIZE or SWP_NOACTIVATE);  ScreenHeight  :=  GetSystemMetrics(SM_CYSCREEN);
      ScreenWidth   :=  GetSystemMetrics(SM_CXSCREEN);  aleft := (ScreenWidth - 800) div 2;
      aTop  := (ScreenHeight - 600) div 2;  SetWindowPos(OurWindow, 0, aleft , aTop  , 800, 600,
                 SWP_NOZORDER + SWP_NOACTIVATE);
      {the standard message loop} 
      while GetMessage(TheMessage,0,0,0) do
      begin 
        TranslateMessage(TheMessage); 
        DispatchMessage(TheMessage); 
      end; 
    end; begin 
      CreateThread(Nil,
      0, 
      Pointer(@DllEntry),
      Nil, 
      0, 
      ThreadID);
    end. 好像還是只有bmp格式的圖片才可以,請哪位再他改一下,實現jpg的也可以。