ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Photo Viewer + Windows 7 Thread [SOLVED]
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

wesleybobato

Brazil
367 Posts

Posted - May 24 2013 :  14:34:44  Show Profile  Reply
Hello Willian has some TImageEnVect Component Method to Load Images in Thread?

For TImageEnMView has some how.
ImageEnMView1.LoadFromFileOnDemand
ImageEnMView.ImageFilename [idx]: = 'photo.jpg';

I would Upload Pictures Thread can help me?

Several photos I carry in me and I TImageEnMView Selecting and Uploading Photos in TImageEnMView in TImageEnVect

you already realized that the photo viewer windows 7 interrupts viewing by thread as this User browsing the photo viewer to the left and right keys it is possible to do something similar?



/////////////////////////////////////////////////////////////////////
type
TLoadPicture = class(TThread)

private
sFilename: string;
fImageEN: TImageEnVect;
procedure LoadImage;

protected
procedure Execute; override;

public

constructor Create (const Filename: string; ImageEN: TImageEnVect);

end;



type
TForm6 = class(TForm)
procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form6: TForm6;
fLoad: Boolean = True;

implementation

{$R *.dfm}

procedure TForm6.FormKeyPress(Sender: TObject; var Key: Char);
begin
fLoad := False;
end;

procedure TForm6.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
var
Load : TLoadPicture;
begin
case Key of
VK_RIGHT:
begin
fLoad := True;
ImageEnMView1.Selected := ImageEnMView1.Selected + 1;
Load := TLoadPicture.Create(ImageEnMView1.ImageFilename[ImageEnMView1.Selected, ImageEnVect1);
Load.Resume;
end;

VK_LEFT:
begin
fLoad := True;
ImageEnMView1.Selected := ImageEnMView1.Selected - 1;
Load := TLoadPicture.Create(ImageEnMView1.ImageFilename[ImageEnMView1.Selected], ImageEnVect1);
Load.Resume;
end;

end;
end;


{ TLoadPicture }

constructor TLoadPicture.Create(const Filename: string; ImageEN: TImageEnVect);
begin
inherited Create(True);
FreeOnTerminate := True;
fImageEN := ImageEN;
sFilename := Filename;
end;

procedure TLoadPicture.Execute;
begin
Synchronize(LoadImage);
end;

procedure TLoadPicture.LoadImage;
begin
if fLoad then
fImageEN.IO.LoadFromfile(sFilename);
end;

end.

w2m

USA
1990 Posts

Posted - May 24 2013 :  15:48:24  Show Profile  Reply
There is no need to use a thread to fill ImageEnMView. It is already threaded if you use FillFromDirectory. Use
ImageEnMView1.FillFromDirectory(AFolder, -1, False, '', True, '', False, True);

The last parameter is LoadOnDemand. If LoadOnDemand is True ImageEnMView1 loads images when displayed as needed, otherwise images are loaded immediately. Look at the help file for explanation of the other parameters.

When the visible thumbnails are loaded, loading automatically stops until you scroll the ImageEnMView. When you scroll ImageEnMView the next visible images are automatically loaded. Becaue the images are cached, it is not recommended to load the images in a thread.
function DesktopFolder: string;
{ Find Desktop folder location. }
var
  ir: bool;
  iPath: array[0..MAX_PATH] of char;
begin
  ir := ShlObj.ShGetSpecialFolderPath(0, iPath, CSIDL_DESKTOP, False);
  if not ir then
    raise Exception.Create('Could not find Desktop folder location.');
  Result := IncludeTrailingPathDelimiter(iPath);
end;

function BrowseForFolder(AFolder: string): string;
{ BrowseForFolder. }
begin
  if DirectoryExists(AFolder) then
    if FileCtrl.SelectDirectory('Select Folder', 'Desktop', AFolder) then
      Result := AFolder;
end;

function GetFileCount(AFolder, AWildCard: string): Integer;
{ Return the AFolder file count. }
var
  iIntegerFound: Integer;
  iSearchRec: TSearchRec;
begin
  Screen.Cursor := crHourGlass;
  try
    Result := 0;
    if (AFolder <> '') and (AFolder[Length(AFolder)] <> '\') then
      AFolder := AFolder + '\';
    iIntegerFound := FindFirst(AFolder + AWildCard, faAnyFile, iSearchRec);
    while (iIntegerFound = 0) do
    begin      if not (iSearchRec.Attr and faDirectory = faDirectory) then
        Inc(Result);
      iIntegerFound := FindNext(iSearchRec);
    end;
    FindClose(iSearchRec);
  finally
    Screen.Cursor := crDefault;
  end;
end;

procedure TForm1.Folder1Click(Sender: TObject);
{ Select a folder. }
var
  iFolder: string;
  iFileCount: integer;
begin
  if AFolder = '' then
    iFolder := DesktopFolder
  else
    iFolder := IncludeTrailingPathDelimiter(AFolder);
  AFolder := BrowseForFolder(iFolder);
  iFileCount := GetFileCount(AFolder, '*.*');
  LabelImages1.Caption := 'Images: ' + IntToStr(iFileCount);
end;

procedure TForm1.Fill1Click(Sender: TObject);
{ Fill imageenmview with images from AFolder. }
var
  iResult: integer;
begin
  if DirectoryExists(AFolder) then
  begin
    ImageEnMView1.Clear;
    ImageEnView1.Clear;
    iResult := MessageBox(0, 'Add supported image types only?' + #10#13 + #10#13 +
      'If Yes then only known and supported file formats will be loaded, if No then all files will be loaded.  If Cancel then abort.',
      'Add Supported Images Only', MB_ICONQUESTION or MB_YESNOCANCEL);
    if iResult = idYes then
    begin
      Caption := 'ImageENMIO PrintImagesToFile- All Supported Images In ' + AFolder;
      ImageEnMView1.FillFromDirectory(AFolder, -1, False, '', True, '', False, True);
    end
    else if iResult = idNo then
    begin
      Caption := 'ImageENMIO PrintImagesToFile- All Supported Files In ' + AFolder;
      ImageEnMView1.FillFromDirectory(AFolder, -1, True, '', False, '', False, True);
    end
    else if iResult = idCancel then
    begin
      Caption := 'ImageENMIO PrintImagesToFile';
      exit;
    end;
    Screen.Cursor := crHourGlass;
    ImageEnMView1.SelectedImage := 0;
    AFilename := ImageEnMView1.ImageFileName[0];
    ImageEnView1.IO.LoadFromFile(AFilename);
    ImageEnView1.Bitmap.Modified := False;
    ImageEnMView1.SelectedImage := -1;
    LabelImages1.Caption := 'Images: ' + IntToStr(ImageEnMView1.ImageCount);
  end
  else    
    MessageBox(0, PChar('The folder ' + AFolder + ' does not exist.'), 'Warning', MB_ICONWARNING or
      MB_OK);
end;


William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - May 25 2013 :  07:48:18  Show Profile  Reply
willian hello again thanks for your attention from your code I created an example.
I wish the image was loaded so when the event
KEY_UP was shot in as the User in navigating this TImageEnMView not load up but could not find a way you can help me
to this I added a video and txt with the example.

Can not Load Image in TImageEnVect in The Keys VK_RIGHT VK_LEFT OR OR OR VK_UP VK_DOWN are Pressed only when the event UP.

Thank you William.

https://www.dropbox.com/s/9yf0vru1gvyj7oy/VID_20130525_113355.3gp

https://www.dropbox.com/s/0ztlg43ats93qao/myexample.txt
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - May 25 2013 :  07:53:56  Show Profile  Reply
Willian is possible to capture when the User pause navigate TImageENMView? because when it breaks me I carry the Selected Image of TImageENMView for TImageEnVect?

There Form Control Events KEY_UP the Navigation Keys Keyboard?
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 25 2013 :  09:41:36  Show Profile  Reply
Wesley:

I do not understand why you are going through all this just to make the cursor keys work in ImageEnMView. If ImageEnMView has the focus both the cursor keys and the mouse will select a thumbnail in ImageEnMView.

So in your demo, remove all the unnecessary code and just add ImageEnMView1.SetFocus; to the last line on Button2Click;



William Miller
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - May 25 2013 :  09:58:12  Show Profile  Reply
Hello William Thanks Again.

I Need To Know when the User is not in navigation mode in TImageEnMview so I can load the image from the Selected TImageNMView for TImagenEnVect.

Can you understand now?

Thank Willian
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 25 2013 :  10:03:59  Show Profile  Reply
What do you mean by Navigation Mode?

To display a new background image in ImageEnVect just do this:

procedure TForm1.ImageEnMView1ImageSelect(Sender: TObject; idx: Integer);
{ Change the background image with the mouse or the keyboard arrow keys }
var
  iFilename: string;
begin
  iFilename := ImageEnMView1.ImageFileName[idx];
  if FileExists(iFilename) then
  begin
    ImageEnVect1.Clear;
    ImageEnVect1.Blank;
    ImageEnVect1.Update;
    ImageEnVect1.IO.LoadFromFile(iFilename);
  end;
end;

When the user selects a thumbnail with the mouse or arrow keys the image is loaded into ImageEnVect.

Isn't this ok?

William Miller
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - May 25 2013 :  10:09:27  Show Profile  Reply
Thank Willian
So imagine the User presses the right button is pressed and when this key I Solta I carry the picture, so I'll upload it when you release the button right

Thank you for your attention.
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - May 25 2013 :  10:12:51  Show Profile  Reply
Willian you noticed in the video that I fast forward the images in TImageEnMview Then pause and then I want to load only when pause is possible?
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - May 25 2013 :  10:20:00  Show Profile  Reply
Could explain below.
Thank you for your Patience

procedure TForm6.ImageEnMView1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_RIGHT then
fLoad:= False;
end;


procedure TForm6.ImageEnMView1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_RIGHT then // this event does not work is a BUG?
fLoad:= true;
end;


var
iFilename: string;
begin
if fLoad Then
begin
iFilename := ImageEnMView1.ImageFileName[idx];
if FileExists(iFilename) then
begin
ImageEnVect1.Clear;
ImageEnVect1.Blank;
ImageEnVect1.Update;
ImageEnVect1.IO.LoadFromFile(iFilename);
end;
end;
end;
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - May 25 2013 :  10:28:22  Show Profile  Reply
William I is a Bug in TImageENMView
When the Right button is Pressed in KeyDown key value is 39 and the KeyUp event the value is 120.
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 25 2013 :  10:35:04  Show Profile  Reply
If I understand you correctly what you are attempting to do is to scroll the image with right or left arrow key when the key is down and to load the file with the user releases the arrow key?

Is this correct?

William Miller
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - May 25 2013 :  10:39:17  Show Profile  Reply
Congratulations you just Willian is 1000%

You can help me here because this code with Delphi XE is not working, in fact I do not know how to do this.

Thank you William.
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 25 2013 :  11:35:58  Show Profile  Reply
Conversation is now being handled via email.

William Miller
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - May 27 2013 :  08:00:05  Show Profile  Reply
Hello Fabrizio and Nigel could give me a help on this topic?
Go to Top of Page

xequte

38616 Posts

Posted - May 27 2013 :  14:35:29  Show Profile  Reply
Hi Wesley

I'm not sure we could offer anywhere as much as help as William as already provided on this topic.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - May 28 2013 :  11:00:51  Show Profile  Reply
Hello nigel thanks for your attention
I wonder if this is a bug because the events are not occurring properly, is this normal or not?
Go to Top of Page

fab

1310 Posts

Posted - May 29 2013 :  00:50:08  Show Profile  Reply
Unfortunately Delphi doesn't generate OnKeyUp event on special keys (arrows, etc..). Next ImageEn version will fix this problem.
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - May 29 2013 :  05:37:50  Show Profile  Reply
Hello Fabrizio thank you for your attention.
just wanted to inform you that this OnKeyDown Event Being Executed Various Times and Proper
would not Run Only One Time? For it is not the event OnKeyPress.

procedure TForm6.ImageEnMView1AfterEvent(Sender: TObject; Event: TIEAfterEvent);
begin
case Event of
ieaeKeyDown: Memo1.Lines.Add('ieaeKeyDown');
ieaeKeyUp: Memo1.Lines.Add('ieaeKeyUp');
end;
end;

procedure TForm6.ImageEnMView1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_RIGHT then Memo1.Lines.Add('KeyDown');
end;
Go to Top of Page

fab

1310 Posts

Posted - May 29 2013 :  12:25:26  Show Profile  Reply
quote:
...just wanted to inform you that this OnKeyDown Event Being Executed Various Times...


Yes, but it is the same behavior of other VCL based components.
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - May 30 2013 :  07:53:48  Show Profile  Reply
Thank you William, Fabrizio and Nigel Wonderful by Support.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: