Retail POS

www.pcland.com.pk

Monday 12 May 2014

How to Hide Black RUN window in VFP

Visual Fox pro RUN | ! command runs any external program using cmd.exe. But it shows Black window running in background of called Program by RUN command and it remains open till called program is active.





As alternative of RUN wscript.shell script can be run but it has dependencies for windows scripting to be installed & enabled to run Client/server system.

[Recomended Solution]
I prefer to use myself & recommend Windows API Call shellExecute(), which works as alternative to above both methods. It does not shows any Black window in your developed application to make it UGLY for user dis-appointment.

Why not Shellexec() Alone to use.?


I used windows Sleep() function  & CMD with Shellexec() in my runfile() function.

Trick implement in runfile() function is that Shellexec() calls  'CMD' to run the passed parameter in string variable. Shellexec() executes 'CMD'  as silent application, Finally we get Rid of UGLY Black windows to display on screen.

CMD can run all  windows application as well as DOS internal commands are supported .
Hence we can run all DOS supported commands in runfile() which can not be executed alone in Shellexec().

see bellow image running Notepad.exe with no-background Black window.



Bellow is my function Code which is replacement of all you required to hide Black window.
*********************************************
* Author :     witten by Zia Mughal
* CopyRight :  Pcland Software Inc. Pakistan
* http://www.pcland.com.pk
**********************************
=runfile("notepad.exe", "untitled.txt" )

**********************
FUNCTION runfile
PARAMETERS rfile, lcmdpara
**********************************
DECLARE INTEGER ShellExecute IN shell32.dll ; 
INTEGER hndWin, ; 
STRING cAction, ; 
STRING cFileName, ; 
STRING cParams, ;  
STRING cDir, ; 
INTEGER nShowWin
local lcCMD, lcParas
DECLARE Sleep IN Win32API INTEGER
lcCmd = rfile   && command to Execute 
lcParas = lcmdpara   && Extra parameter to pass your command 
 * --- Execute the command.
****   shellExecute last parameter 0  will hide DOS window
***  If you want to show DOS window change it to value  1 

ShellExecute(0,'open','cmd', '/C'+lcCmd+' '+lcParas, '',0)
sleep(2000)  && delay time to come  back
 *** sleep value  can be reduced according to your need
CLEAR DLLS ShellExecute
* --- Return to caller.
RETURN
ENDFUNC
 ***********************************


 Hi Folks!

This is all what i did, now its upon your will to adopt the way to complete your task!

Regards!

Zia Mughal

Running Applications with full Access on WIndows 7/8

Microsoft Changed it Security with better Security Policy  for Windows 7, Windows 8 & onward Releases.
They introduced  UAC (User Authentication Control), comparatively  is best feature then Xp or Previous OS released by Microsoft. By default on New OS installation it becomes effective.

Many users did not know UAC features & benefits because there already installed/ running applications on XP becomes effected  under UAC control, which needs setting to be done on Windows 7, Windows 8 or later version.

Some of default restricted UAC locations are as follows
Main root C:\ , C:\windows & all sub folders  (including all exe, dll, etc)
c:\Program files\  etc.
in these above areas we can not create/delete  manualy or Programmatically any file  without 'Administrator Rights'

To run effected applications user needs to adjust his applications as per his needs, because default setting for all applications become in tight position.

[RUN as Administrator Settings]

Setting & Running a application as 'Administrator' does not effect the whole UAC (user Authentication Control) of OS. we can use Windows 7/8 compatibility mode for running your applications.

1. Right click on your application Program (Exe,App)  then click ->Properties
2. click on "Compatibility" tab.
3. "Check mark" the option "Run this program as an administrator"  and Click "Apply"





[Backward Compatibility Settings]


Microsoft provided this feature  for those application which were designed for windows XP or All backward OS. To run those Old Applications we need to set this feature for every application we want to RUN on Windows 7, Windows 8.

Setting this feature does not effect all  OS applications behavior as backward. It will assign compatability environment to only application whom you are setting.

1. Right click on your application then click ->Properties

2. click on "Compatibility" tab.

3. "Check mark"  both options and Click "Apply"

  i) "Run this Program in Compatible Mode"
     ->select Windows XP (service Pack 3)  or any other OS you required from list.
 ii) "Run this program as an administrator" This  is optional if you required it.






Cheers!


Hope this will RUN your effected application till Next Release of Windows by Microsoft !


Zia Mughal










Saturday 3 May 2014

How to Enable VFP9 Help under WINDOW 8

VF9 help is written in dv_foxhelp.chm file. When any user Upgrades his operating system from Windows 7 to windows 8 or installs new copy of window 8 directly. Suddenly he experiences that in VFP help stops working.

All this happens due to Microsoft is increasing its UAC & security of its new OS  or might be a guess not confirmed its new policy to make harder day by day related to Old application to retire permanently.

Any how thanks again Microsoft that there was a manual driven  way was left for Programmers/Developer to do, & switch on the blocked Applications to RUN on Windows 8 & 8.1.

Many website site & blogs are full off Question  regarding 'How to enable VFP9 help to run on window 8'.
This driven me to write this post on Blog for all who are in search for this answer.


1. Open your Directory/Folder of VFP9, find file dv_foxhelp.chm  Right click & see Properties figure 1.1.

Figure 1.1


2. See its default properties will be as bellow shown in figure 1.2.

Figure 1.2

 3. Select by click on your windows user from you logged in or if you want to assign it to all 'Authenticated user'.   finally click on EDIT button
You will find only two permission are by default assigned 'Read & execute' , 'Read'  but not effective to execute in VFP,  So Check mark 'Allow' the all controls  which were not assigned  (indicated in picture as RED Arrow)  & Click on "Apply" button.

Figure 1.3

4. After 'Apply' you will be back into dv_foxHelp.chm Properties window. Now you can see 'Green Arrow' indication changes made to properties of dv_foxHelp.chm file.


This was all Story for that, we were facing problem to run VFP9 Help with in remaining Visual foxpro by hitting F1 key.

Hope it will help you & make you easier to enjoy!

Cheers!

Zia Mughal