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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A couple of EXE problems 2

Status
Not open for further replies.

rojariggs

IS-IT--Management
Feb 24, 2002
27
Hi

I am developing a small application which has been working fine in VFP but I am now trying to build an EXE from it and have a couple of odd things happening that I cannot figure out:

1. The EXE runs without the VFP window and works fine until you try and exit and it closes whatever form you are in but then an empty flickering VFP window opens. The only way to close this window is through Task Manager.

2. The first form is a login form. When you login it should load the main menu but doesn't until you click somewhere (anywhere) on the form.

3. I cannot add an icon to the EXE. It lets me browse to the icon OK and I can preview it but when I click OK it doesn't add the icon. The icon is a BMP (ICO extension) and is 32x32.

I am using VFP6 and any help will be greatly appreciated!

Many thanks

Rog
 
1. It depends what is you shutting down procedure.
You should call a function at the begining of your main program
Code:
 ON SHUTDOWN myShutdown()
And somewhere at the bottom of your main program, create the function
Code:
Function myShutDown
      close all
     release all 
     clear all 
     clear events
     quit
2. You mean the user should have access to the menu even though he is not logged in.
3. Your icon should be a .ico file with tow images in it (32x32 and 16x160

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Hi

Thanks for the reply.

1. I have put in the code you suggested and now have a slightly different issue. The flow in my app should be like this:

main.prg > login.scx > mainmenu.scx

Now, once I have logged in the application just exits and I don't get my mainmenu form.

2. Sorry, mainmenu is a form not a menu and I should've made that clear. On the login form you enter username and pwd then click the login button. This should close the login form and call the mainmenu form but you have to do an extra mouse click (anywhere) after pressing the login button.

3. I'll have a look at this separately as not such a problem right now!

Cheers

Rog
 
Rog,

Instead of this:

main.prg > login.scx > mainmenu.scx

you should be doing this:

main.prg > login.scx > main.prg > mainmenu.scx

In other words, the login form should return control to the main program. The main pogram should then load the menu (or the menu form, it makes no difference). I think if you did that it would help solve your first two problems.

In summary, Main.PRG should look something like this:

Code:
* Initialisation stuff goes here

LOCAL llLoginOK

ON SHUTDOWN MyShutDown()
  && as per Mike Gagnon

DO FORM Login TO llLogInOK
  && Login is a modal form.It returns .T. if the 
  && login is successful

IF llLoginOK
  DO FORM MainMenu
    && This is a modeless form
  READ EVENTS
ENDIF

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Hi Mike(s)

Ok, main.prg > login.scx > main.prg > mainmenu.scx makes sense and I can put that into my main.prg pretty easily. How do I handle other forms? (I have about 20 altogether). Currently they are all called from one another which works a treat within VFP.

Should I have code in main.prg that loads all forms based on variables returned from calling forms?

Cheers

Rog
 
Rog,

I forgot to mention: You will need CLEAR EVENTS in the Destroy event of your main menu form.

Re calling other forms: If you have a main menu form, then it's the menu that should call these other forms. That's the whole point of a menu.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
OK, getting there now. Got the first forms working how they should be and can access all my forms OK now thanks to code based on your snippets above.

What I am trying to do now is have the forms that are called by mainmenu.scx load on top of it so that the mainmenu.scx cannot be seen or accessed until the other form is closed. At the moment the forms are loading in separate windows on top of mainmenu.scx. I have tried setting them to load within mainmenu.scx (ShowWindow = 2) but this does not work as the forms are all the same size. I have played about with WindowType and WindowState and even tried toggling mainmenu.visible to get the desired effect but none of these works smoothly and neatly.

Is there a correct and neat way of achieving this?

Thanks

Rog
 
What I am trying to do now is have the forms that are called by mainmenu.scx load on top of it so that the mainmenu.scx cannot be seen or accessed until the other form is closed.

The first question is: Why do you want to do that?

It would be better if you did allow the user to access the main menu, even while other forms are open. In other words, let the jump between the menu and the other forms at will. That's the way a modern Windows mnodeless system is usually designed.

But, if for some reason you definitely don't want to allow that, you must make the subsidiary windows modal (set WindowType to 1). That way, the user will have to close the subsidiary window before they can access the menu (or any other window).

As for hiding the menu while the subsidiary window is open, again I'd ask why want to do that. You should be able to do it by setting the menu form's Visible to .F., but you way that doesn't give the desired effect. In what way?

I could add that the way you are designing your interface, that is, with a form acting as the menu, is perfectly valid, but is not the usual way of going about things. (How many other Windows applications have you seen where the main menu is a form?).

It's more usual to use a system of pull-down menus or a toolbar (or both) as the main menu. There are many advantages in doing that, and it generally works well.

You can create a pull-down menu in VFP's menu designer, and you can create a toolbar in the class designer.

Just something to think about ...

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Thanks for all your help on this Mike!

What I am trying to achieve is something loosely based on the navigation tabs in Outlook 2007 down the left hand side of the form. I have done this using rectangles and text labels with code calling each form in the click events of these. The rectangles change colour to highlight the current selection.

This looks good and works a treat in VFP dev environment and the users that have tried it really like it because it's quick and easy to navigate while they always know where in the system they are.

It might be that I need to rethink this but it seems a shame to as it works so well outside of runtime.

Cheers

Rog
 
 http://www.riggs-net.com/Images/ssmainmenu.jpg
Rog,

I would think the best way to simulate an Outlook-style navigation bar would be to use a toolbar. It would solve many of the problems you mentioned, and would generally have a better look and feel than one based on a form.

In fact, there are several Outlook-style bars writtin in VFP available for download from various places. I don't have any details to hand, but if you searched around, you might find something you could use as a model.

But it would't be all that difficult to build one yourself.

By the way, did you ever get an anser to your third question: the one about the icon? If not, you might want to start a new thread for it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Hi Mike

I'll have a look into the toolbar thing. I've got the forms coded now so a lot of the donkey work is done.

Oh yeah, and I've sorted the icon problem now. I had too many colours in my icons. Dropped them down to 16 colours and they work a treat!

Thanks for your help Mike!

Cheers

Rog
 
If you want to get around the 16 color icon limitation in VFP6 and use 256 colors instead, Resource Hacker (freeware) can do the job. It's been working for us for years:


We create our VFP6 exe using the original 16 color icon followed by a call to a batch file that swaps our 256 color icon for the original into a copy of the exe. The batch file then checks for errors and if none are found, renames the files accordingly. Batch file contents:

@echo off

cls

"c:\Program Files\ResourceHacker\ResHacker.exe" -addoverwrite MyExe.exe, MyNewExe.exe, My256Icon.ico, ICONGROUP,15000,1033

if errorlevel 1 goto errres

if not exist mynewexe.exe goto errres

erase MyExe.old

rename MyExe.exe MeExe.old

rename MyNewExe.exe MyExe.exe

goto end

:errres

echo. An error occurred inserting icon using ResHacker.

pause>nul

:end

exit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top