Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
.JPGs and other controls in a grid or listbox
Message
From
19/06/2003 12:05:13
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
18/06/2003 15:34:55
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00801400
Message ID:
00801803
Views:
19
>Hi All,
>
>I have to create an App that allows our marketing department to display several pictures at a time and edit the description and location of the .jpgs. There are many .jpgs to each sku, so when selecting a sku from the grid on the left side of the form, the control on the right side of the form will display a scrollable and editable list of .jpg, description, file location. So the right side of the form will look something like:
>
>Image Control1
>Description1
>Location1 & File Picker Command Button 1
>
>Image Control2
>Description2
>Location2 & File Picker Command Button 2

>
>etc...
>
>Any suggestions?
>
>Louis

This might help :
oForm = createobject('form1')
oForm.show()
Read events

Define CLASS form1 AS form
  Top = 0
  Left = 0
  Height = 470
  Width = 740
  DoCreate = .T.
  Caption = "HTML sample"
  Name = "Form1"
  HTMLFile='' && Custom prpoperty to hold temp .htm name

* This is IE control - you'd use webbrowser4 from gallery instead
* just because it already has some checks, extra pem. ie: wouldn't need readystate part
* for the sake of keeping code short here I directly use olecontrol itself
  Add OBJECT htmlviewer AS olecontrol WITH ;
    Top = 12, ;
    Left = 12, ;
    Height = 396, ;
    Width = 708, ;
    Visible = .T., ;
    Name = "HTMLViewer", ;
    OleClass = 'Shell.Explorer'

  Add OBJECT text1 AS textbox WITH ;
    Height = 25, ;
    Left = 12, ;
    Top = 432, ;
    Width = 60, ;
    Name = "Text1"

  Add OBJECT text2 AS textbox WITH ;
    Height = 23, ;
    Left = 84, ;
    Top = 432, ;
    Width = 204, ;
    Name = "Text2"

  Add OBJECT text3 AS textbox WITH ;
    Height = 23, ;
    Left = 300, ;
    Top = 432, ;
    Width = 125, ;
    Name = "Text3"

  Add OBJECT text4 AS textbox WITH ;
    Height = 23, ;
    Left = 432, ;
    Top = 432, ;
    Width = 125, ;
    Name = "Text4"

  Procedure Init
    Local lnImages, lnPerrow, lnCurrent
    lnImages = adir(arrImages,'myimages\*.gif')
    *You'd use a table let's simulate it
    Create cursor myImages (ImagePath c(50),FirstName c(12), LastName c(12))
    For ix=1 to lnImages
      Insert into myImages values ;
        ('myImages\'+arrImages[ix,1],'FirstName'+trans(ix),'LastName'+trans(ix))
    Endfor
    *Now we have a test table - create HTML
    lnPerRow = 4 && How many would we show on a line
    lnCurrent = 0 && Do not use recno() thinking it might be ordered on an index
    This.HTMLFile = sys(2015)+'.htm'

    Set textmerge on
    Set textmerge to (this.HTMLFile) noshow
    * Initialize lcHTML
		\<HTML><BODY><TABLE>
    Select myImages
    Scan
      lnCurrent = lnCurrent+1
      If (lnCurrent-1)%lnPerRow=0
        If lnCurrent>1
		\</TR>
        Endif
		\<TR>
      Endif
		\<TD><A href="<<trans(recno())>>"><img border="0" src="<<trim(chrtran(ImagePath,'\','/'))>>"></A></TD>
    Endscan
		\</TR>
		\</TABLE></BODY></HTML>
    Set textmerge to
    Set textmerge off
    lcHTML=FileToStr(this.HTMLFile)
    With ThisForm.htmlviewer
      .Navigate2('file://'+sys(5)+curdir()+this.HTMLFile)
      Do while .ReadyState # 4 && Wait for ready state
      Enddo
    Endwith
  Endproc


  Procedure htmlviewer.BeforeNavigate2
    *** ActiveX Control Event ***
    Lparameters pdisp, url, flags, targetframename, postdata, headers, cancel
    Cancel = .t.  && do not navigate to anywhere
    With thisform && with webbrowser4 also this.oHost is the form itself or container
      .text1.value = justfname(url)
      Go val(justfname(url)) in 'myImages'
      .text2.value = myImages.ImagePath
      .text3.value = myImages.FirstName
      .text4.value = myImages.LastName
    Endwith
  Endproc

  Procedure queryunload
    Clear events
  Endproc
  Procedure destroy
    Erase (this.HTMLFile)
  Endproc
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform