Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generic programming for creating a form that can be embedded on other modal forms to upload images. 4

Status
Not open for further replies.

A Beginner

Programmer
Apr 15, 2017
81
IN
I Want to Create a form programmatically(a generic program) that could be embedded on any other modal form having grid for uploading images.
How to deploy the idea in a very simplistic way?
The visual portion being Cool and light layout.

Thank you
 
A Beginner said:
But before that, in order to visualize the class in it's construction process ie. adding object and viewing the effect, changing property and viewing the effect I will have to define it as form, isn't it?

Well, first I would like an english version of that sentence, but as far as I interpret it you think you must design visual stuff within forms. No, that isn't the case. The form designer is just one special designer for SCX, any other visual class than the form can be the basis of any class you design in a VCX, including forms, so designing a class via class designer, you can design partial forms, single controls and more, the form is just a special case you can design in the class designer. So the class designer and in general OOP class design offer much more capabilities than the form designer.

The only thing is you can't DO a class, you have to instanciate (create) it via CREATEOBJECT(). But whether you do that in code or within the designer is up to you, too. You can add controls at design time or runtime, that also means you can design several classes and as far as containership allows combine them into a next class, which kind of means your final class inherits from several previous classes. Ther is just one parent class in all cases, but that one base class can be form or container and you can then add in anything else. Container can contain container, so you can also nest objects, there also is no limit about this. All the classes you design as possible subforms or form components or pages or containers themselves not being forms can finally be put on a form class, which you either start by a combination of two code lines [tt]oForm = CREATEBOJECT("formclass")[/tt] and [tt]oForm.Show()[/tt] or if you want to be able to DO FORM yourform.scx, you create an empty SCX form you use to put your classes on it, or you base the SCX on a form class you already created as class, which kind of means you only convert the class to become an SCX with its simpler usage. Needing two instead of one line of code is not a big help, though, considering how much time it takes to get to this point, this is not a 50% savings issue. You see there are very many ways, but in OOP design you start from the single simple things and build up the form, not the other way around.

That said you can indeed create a form, put several things on it, then select a section and choose the item "save as class" from the file menu, then picking the option to only save selected elements. This will ask you to which vcx to store a class with which name, and then you have what I also suggested, a class, which mainly will be based on the container and contain the elements you picked. I find it easier to build up from detail to the whole form, though I understand developing a form concept is easier starting with the form level. The form level won't help you create several differently composed forms though, that obviously first needs the single components to put together in different ways to different forms, doesn't it?

Bye, Olaf.

 
Olaf said:
Well, first I would like an english version of that sentence, but as far as I interpret it you think you must design visual stuff within forms.
When I started with define class as form and added a few objects on it, seen nothing visible on running my prg. That's why I had written that post.
Mike's post beginning with "Here's something you can do:...." helped me to design the form first and use its code next.

At the moment I am going to define the class as container, put an image control on it, use some getfile(),lockfile kind of stuffs to grab the image and attach that with the askingrid form.
Can't I design cool looking forms like
DOKTl_xihxwe.jpg

with curved textboxes and smooth and shaded buttons?
Please guide me on that perspective.
 
Can I use this image for showing images on the form and mimic the look and feel like canvas?
accessories-06_fk9w2f.jpg
 
You are kidding me, are you? You're not designing a form by code, are you? Common, use the visual designers.

Bye, Olaf.
 
A-Beginner,
Yes you can use your picture frame image. What you do is put it on the form as in image class, with the picture clause set to that image.
Then put another Image class sized inside the frame lines you want to use. Set its picture property dynamically, and I would suggest make it "Invisible" (this.visible = .F.) if the picture is empty, or create a .bmp or .jpg very small image and make it the default that is "stretched" across the image surface, make it either all white, or all gray to match the background color of your object.
Not a bad idea actually. I usually wind up using shape objects that are square/rectangular to create borders for my image boxes... but this is a neat idea.

As for your Send File form, yes you can do all that in VFP with various properties in the objects. You *could* theoretically use that image as well, and just put text boxes on it with transparent backgrounds as well, if it's going to be that form, and buttons with transparent properties over the places you want those, and it would work too...


Best Regards,
Scott
MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"Everything should be made as simple as possible, and no simpler."[hammer]
 
One thing is worth mentioning here.
I found for multiple selection a link on tek-tips itself.
Olaf said:
You are kidding me, are you? You're not designing a form by code, are you?
[smile2] No no no I am not kidding. I am using first visual form designer and then utilizing its code.
Please tell me is it a harmful approach?
 
Yes it is harmful in many ways:
1. It partially won't run as generated. It is NOT the code that is equivalent to what running the visual form or class is
2. It is only meant for source control, to have text to be able to detect what changed as source version control software is very text oriented only. It doesn't work at all.
3. You have a hard time using such classes, eg you can't simply drag controls you have defined in PRG code onto forms.
4. You'll run into walls if you try to combine visual and PRG classes, inheritance chains should only have one type and compositing from both visual and PRG class also is a nightmare.

PRG code often is posted in forums, but only because it is the simplest form to post code. You sometimes find such forms in faqs, but mainly, as Mike recently also said to you, we concentrate on only posting essential parts of the code.

If you develop in VFP you develop with the visual designers. You'll see that many things are much easier this way. If yo argue only a PRG of the full class can give you an overview of everything, you haven't used Code References, or GoFish and see how easy they list things you search and "beam" you into the corresponding method via doubleclicking on results.

There is a slight downside of the editor only showing you a single method, but it helps focus. And the OOP principle of encapsulation means, if you really need to switch between many methods to extend your code, you do something completely wrong. So actually the way designers work and only let you edit one method at a time, help you create better code.

Bye, Olaf.
 
Scott said:
Yes you can use your picture frame image.
Thank you very much Scott for you taught me how to do that.
In the init event of the form I wrote
Code:
IF EMPTY(Thisform.img2.Picture)
   Thisform.img2.Visible = .F.
ENDIF
When run found that there is only the first image visible.
 
Well, yes, that was the intention of Scott, because if the inner img2.Picture is empty, this will show as an ugly icon of a broken link/image. You only want to show the inner image, if it is set to a picture file, too.

Bye, Olaf.
 
Olaf said:
Yes it is harmful
In one of my previous thread (about Systray notification) you had written in a post that you will help me designing the form with code.
When I try myself by defining a class based on form and adding a few object to it, I see nothing visible. So I feel quite difficult to proceed in that way.

Let me draw the outline-
1. In the askingrid form (I have uploaded the image of the grid and form in one of my previous post)I need to add the image of the product (in add mode of the program)
2. As soon as the image's path is added to the concerned field or the image is appended to the concerned memo field, it will be visible in the image control.
3. In change mode of the program only the available image will be seen with no option to upload.

So please write in what way should I proceed if I start coding the form from scratch.
 
>adding a few object to it, I see nothing visible
When you put a grid on the form, you don't see the grid?

Or what are you saying? It's time you watch a few of the Garfield Hudson tutorial videos you were pointed to, to learn the very basic things on how to use the visual designers.

Right clicking on things gives you context menu and shows you what you can do. Having the property Window open all the time also will show you things of anything you click in a parallel open form or class designer. Double click on a button you put on the form and the code editor will bring you to the click event. Just to give three essential handles on how to work here.

If your first contact with computers was via smartphone touch interface, this now is both desktop and Microsoft Windows. Apple's mice only have one button, but MS also have a right button for right clicking on things and getting more options via a context menu.

Bye, Olaf.

 
All those videos I had watched more than 4-5 months back all the videos in the series up till grid. .... For the sake of continuity and revision I will again watch few of them related.
 
A Beginner said:
In one of my previous thread (about Systray notification) you had written in a post that you will help me designing the form with code.
I assume you mean thread184-1776585, but I don't see where I made the promise in helping you with PRG forms.

When we're at reading back what already was said, notice how I recommended visual classes and forms in thread184-1776488 already.

Can you point out what makes you think I hel]p you with creating PRG classes? I'll surely not support that approach at all.

Bye, Olaf.
 
Olaf said:
I would help, if you'd write in whole sentences here. I don't know what you mean, now?

Olaf said:
but I don't see where I made the promise in helping you with PRG forms.
No, no I never say you made any promise. yet, I say you had encouraged me to write my own class by that encouraging statement of yours.

Olaf said:
....In one of my previous thread (about Systray notification) you had written in a post that you will help me designing the form with code.
This is really a bad statement and I apologize for that and instead I improve the statement like 'You had promoted my confidence to write my own class code.'
Please consider this as my improfessionalism and please don't ignore it, rather mark me wherever you feel like that.
I will be thankful to whosoever does that.

By the way I watched Garfield's video on
was about class and realized that I had completely forgotten the vcx and instead mixed vcx and scx.
 
OK, well, but I encouraged you to do your own class, but not in a PRG, not with code. So try to get a grip on the visual designers.

If you right click on controls within your form or container class you get a context menu item builder. Try that. It'll "interview" you about what you want to do with the control, typically ask what data to bind. This is something you don't get in a PRG.

If you edit a method/event of a class having parent classes, above the code editor you have a combobox to change the object (if you edit some class composed of several objects, eg a form with several controls on it, that means nothing unusual), right to that you can choose procedure (method or event). In a PRG you can simply scroll to that code section, but isn't it nice you get a list of methods and events available to program? The third thing in the header of the visual class code editor is a button "View Parent Code", this is something you can only have in a PRG, if you have all class hierarchy code in one PRG, so the parent class definition also is in there.

Once you have defined a grid or textbox or any control class, open up or create a form class and set the project manager window side by side to the designer window, drill down the libraries to the control class you want in the project manager and drag that onto the form canvas. Also not possible with PRG class definitions.

I could go on with many further advantages of visual design and coding, one very simple advantage is you visually design the visual properties, you can drag controls instead of setting left and top, in short you have a WYSIWYG editing of the form, instead of code.you need to run to see how it looks. It later, when things are more complicated is a big advantage to be able to edit a form this way and not need to start it when it has lots of prerequisites and you only get to it at the end of a longer workflow, for example.

And last not least, well, the visual class itself is an end product, it's nothing you need to turn to PRG code to run it, it is runnable by instanciating it. The PRG code you can generate has the necessary code lines you need in general, o=NEWOBJECT("classname") and o.Show (for forms). That's all you have to program in some PRG or the command window. Besides you want to add your folder of VCXes onto the PATH or SET CLASSLIB to your VCXes and then can simply use NEW/CREATEOBJECT().

Bye, Olaf.
 
jrbbldr said:
To learn some of the basics of VFP, you might want to spend some time looking at the free on-line VFP Tutorial Videos at:

I think quarter a year back I had watched them when I was beginning with VFP.
Last night and today morning I watched few of them related to class and found that I had almost forgotten the concepts and found them pretty useful at the moment. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top