Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 28th, 2012, 01:52 PM
havsys havsys is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 12 havsys User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 3 sec
Reputation Power: 0
Problem when canceling OpenPictureDialog

Hello,

I have this problem.
When I open "OpenPictureDialog" and click Cancel Button i get this message UNKNOWN PICTURE FILE EXTENSION (.)

Reply With Quote
  #2  
Old October 28th, 2012, 11:34 PM
majlumbo majlumbo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 257 majlumbo User rank is Lance Corporal (50 - 100 Reputation Level)majlumbo User rank is Lance Corporal (50 - 100 Reputation Level)majlumbo User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 Days 9 m 16 sec
Reputation Power: 6
Without posting the code that causes the error, at best we can only guess as to what is happening.

Given that, my guess is that you are not "Executing" the dialog correctly.

Code:
if OpenPictureDialog.Execute then
begin
   //the file selected will be in
   //OpenPictureDialgo.FileName
   //only do the "loadfromfile" if the dialog is executed
   //otherwise the user clicked cancel
end;

Reply With Quote
  #3  
Old October 29th, 2012, 12:53 AM
havsys havsys is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 12 havsys User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 3 sec
Reputation Power: 0
Quote:
Originally Posted by majlumbo
Without posting the code that causes the error, at best we can only guess as to what is happening.

Given that, my guess is that you are not "Executing" the dialog correctly.

Code:
if OpenPictureDialog.Execute then
begin
   //the file selected will be in
   //OpenPictureDialgo.FileName
   //only do the "loadfromfile" if the dialog is executed
   //otherwise the user clicked cancel
end;



Sorry about code.
here it is
Quote:
procedure TFMain.ChooseClick(Sender: TObject);
var
sDir : string;
begin
DBImage1.Height:= 200;
dbImage1.Width:= 175;
OpenPictureDialog1.Filter:= '*.bmp|*.bmp|*.jpg|*.jpg';
OpenPictureDialog1.Execute;
sDir := OpenPictureDialog1.FileName;
DBImage1.Picture.LoadFromFile(sDir);
end;

Reply With Quote
  #4  
Old October 29th, 2012, 08:04 AM
majlumbo majlumbo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 257 majlumbo User rank is Lance Corporal (50 - 100 Reputation Level)majlumbo User rank is Lance Corporal (50 - 100 Reputation Level)majlumbo User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 Days 9 m 16 sec
Reputation Power: 6
You need to test to see if the user actually executed the dialog box (hits the ok button, vs. the cancel button.
Code:
procedure TFMain.ChooseClick(Sender: TObject);
var
  sDir : string;
begin
  DBImage1.Height:= 200;
  dbImage1.Width:= 175;
  OpenPictureDialog1.Filter:= '*.bmp|*.bmp|*.jpg|*.jpg';
  if OpenPictureDialog1.Execute then
  begin
    sDir := OpenPictureDialog1.FileName;
    DBImage1.Picture.LoadFromFile(sDir);
  end;
end; 

Reply With Quote
  #5  
Old October 29th, 2012, 02:46 PM
havsys havsys is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 12 havsys User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 3 sec
Reputation Power: 0
Thank you.

It's Working.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > Problem when canceling OpenPictureDialog

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap