What I have done till now can be jotted down as follows:
1. Created the project with name AddImage.pjx,
2. Defined NewClass based on BaseClasses.
3. Created a new class AddImage.vcx as NewContainer.
4. Added 'Img1' with an image (to mimic to Canvas) into the Picture property of Img1.
5. Added 'Img2' with no image in it's picture property.
6. In the init of 'Img2' typed code-
Code:
IF EMPTY(This.Picture)
This.Visible = .F.
ENDIF
7. Added a label 'lblPath' with autosize .T., to the container.
8. Added a textbox 'txtPath'
9. Added a command button 'cmdBw' with caption '...'
10. Added 'adddialog' AS _comdlg
11. In the click event of 'cmdBw. created cursor to store the path of image selected.
12. In the click event of 'cmdBw' copied the code mentioned on
with some modification as under
Code:
Procedure cmdbw.Click
Crea Curs FILENAMES (filename C(254))
With This.Parent.adddialog
.ClearFilters() && Clear filters in case in loop
.lAllowMultiSelect = .T. && Enable multiple file selection
.cFileName = [] && Do not set an initial file name
*.cInitialDirectory = [[C:\My Documents]
.cInitialDirectory = [C:\Users\Aspire\Desktop\Don't Delete] && Start folder
.cTitlebarText = [Select multiple files] && Dialog titlebar text
*.aFilterList[1,1] = [Image Files (bmp,gif,jpg)] && First half of filter list
*.aFilterList[1,2] = [*.bmp;*.gif;*.jpg;*.jpeg] && Second half of filter list
.AddFilter([Image Files (bmp,gif,jpg)],[*.bmp;*.gif;*.jpg;*.jpeg])
* Should you want additional filters you can add them with :-
*.AddFilter([MS Office (doc,ppt,rtf,txt,wri,xls)],[*.doc;*.ppt;*.rtf;*.txt;*.wri;*.xls])
.nFileCount = 0 && Reset file count value in case dialog in DO WHILE... loop
.ShowDialog() && Show dialog
If .nFileCount > 0 && File(s) selected
For i = 1 To Alen(.aFileNames,1) && Loop through array created
Insert Into FILENAMES (filename) Values (Addbs(.cFilepath);
+Lower(.aFileNames[1,i])) && Insert path\filename.ext in cursor
Endfor
*Browse Last
Else
Messagebox([You have not made a selection],16,[No files],2000)
Endif
This.Parent.txtpath.Value = FILENAMES.filename
This.Parent.img2.Picture = FILENAMES.filename
This.Parent.img2.Visible = .T.
Endwith
13. To show the path of the image in 'txtPath' and to open the picture as 'Img2' typed following code-
Code:
This.Parent.txtPath.Value = FILENAMES.filename
This.Parent.img2.Picture = FILENAMES.filename
This.Parent.img2.Visible = .T.
14. Created a new form AddImage.Scx in the project itself and added the Addimage.vcx on it.
15. When run the form and select any image, it opens it but of the image's original dimension(large or small)
Please guide me on how to adjust the image's dimension dynamically?