Let's get this started

We encourage new members to introduce themselves here. Get to know one another and share your interests.
User avatar
ThomasVenus
Posts: 12
Joined: Mon Nov 02, 2015 1:54 pm
Location: Germany

Let's get this started

Post by ThomasVenus »

Hi Folks,
after a long time of just looking at X# (even as a Fox subscriber since last the last conference) I finally started
to have a close look. :)
This will for sure cost a lot of time but i think it is worth the effort.

Just now I'm stuck with the followin little problem.
In VO these two lines brings up the default browser and shows the image of a ip-camera:
cCommandstring := "http://123.456.789.000:xxx/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=xxx&pwd=xxxx"
ShellExecute(0, psz("open"), psz(cCommandString), NULL_PSZ , ;
NULL_PSZ , ;
SW_SHOWMAXIMIZED )
How can this be done in X#?
The final goal would be to store the image as jpg-file instead of just diplaying it.

Looking foward to a good time with X#

greetings
Thomas
FFF
Posts: 1589
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Let's get this started

Post by FFF »

Thomas,
System.Diagnostics.Process.Start( "C:Program FilesMozilla Firefoxfirefox.exe", "google.com") opens Google.
etc.

Karl
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
Chris
Posts: 4949
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Let's get this started

Post by Chris »

Hi Thomas,

First of all, the exact same code should compile and run fine in X#, by simply referencing the Win32 SDK dll in your app. Secondly, you can use the "more .Net" version of the same thing that Karl provided. And thirdly, you can use one of the dedicated web related classes that are offered in the .Net framework for using http, ftp, mail etc in a very powerful OOP way. Unfortunately I have very little experience with them, somebody else may chip in with more detailed advice using those.

Chris
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
Chris
Posts: 4949
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Let's get this started

Post by Chris »

Hi Thomas,

First of all, the exact same code should compile and run fine in X#, by simply referencing the Win32 SDK dll in your app. Secondly, you can use the "more .Net" version of the same thing that Karl provided. And thirdly, you can use one of the dedicated web related classes that are offered in the .Net framework for using http, ftp, mail etc in a very powerful OOP way. Unfortunately I have very little experience with them, somebody else may chip in with more detailed advice using those.

Chris
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
FFF
Posts: 1589
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Let's get this started

Post by FFF »

Chris,
i copied Thomas' lines in the Start of a newly created VO-MDI app,
like
VAR cCommandstring := "http://123.456.789.000:xxx/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=xxx&pwd=xxxx"
ShellExecute(0,String2Psz("open"), String2Psz(cCommandString), NULL_String , ;
NULL_String , ;
1 )
first got warnings that the PSZ could provide leaks, replaced them with the suggestet String2PSZ, but then got strange error as
error XS0103: The name 'Xs$Return' does not exist in the current context 3,1 Start.prg MdiApp1
Line 3 being the Function Start() one.
??

Have the Win32Library referenced, how would i add the Win32SDK (as it is not listed in the dialog?

Karl
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
SHirsch
Posts: 286
Joined: Tue Jan 30, 2018 8:23 am
Location: Germany

Let's get this started

Post by SHirsch »

Hi Thomas,

For VO this may help (not tested in X# yet):

Code: Select all

oHttp := CHttp{}
oHttp:ConnectRemote("http://123.456.789.000:xxx", sUser, sPsw) 
oHttp:GetFile("cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=xxx&pwd=xxxx", sDestFile, FALSE) 
oHttp:CloseRemote()
In your case 'sUser' and 'sPsw' could be empty. Some error handling should be implemented ( I removed this for better readability).


Stefan
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

Let's get this started

Post by lumberjack »

Hi Thomas,
ThomasVenus wrote:Hi Folks,
In VO these two lines brings up the default browser and shows the image of a ip-camera:
cCommandstring := "http://123.456.789.000:xxx/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=xxx&pwd=xxxx"
ShellExecute(0, psz("open"), psz(cCommandString), NULL_PSZ , ;
NULL_PSZ , ;
SW_SHOWMAXIMIZED )
How can this be done in X#?
The final goal would be to store the image as jpg-file instead of just diplaying it.
Please have a look at System.Net.WebClient class of .net
Think you will find everything there that you need.
Regards,
______________________
Johan Nel
Boshof, South Africa
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

Let's get this started

Post by lumberjack »

Hi Thomas,
Not near my laptop with example of http, but here is hopefully something to get you going. It is reading the directory structure of a ftp site:

Code: Select all

METHOD UpgradeCheck() AS VOID
	LOCAL wc AS WebClient
	LOCAL nc AS NetworkCredential
	LOCAL fwr, fwd AS WebRequest
	LOCAL sr AS StreamReader
	LOCAL enumerator AS IEnumerator
	LOCAL aDirectory, aStr AS STRING[]
	LOCAL aFolders AS Stack<STRING>
	LOCAL s, sName, sFolder, sTmp, sApp, sEnv AS STRING
	LOCAL nIndex AS INT

	nc := NetworkCredential{"eval", "demo"}
	wc := WebClient{}
	wc:Credentials := nc
	wc:BaseAddress := SELF:oIni:GetString("__servers", SELF:cEnvironment)

	TRY
		SELF:aAppFolders := Stack<STRING>{}
		SELF:aFiles := Stack<STRING>{}
		aFolders := Stack<STRING>{}
		sFolder := ""
		SELF:slbAction:Text := "Checking application folder layout..."
		REPEAT
			fwr := WebRequest.Create(wc:BaseAddress + sFolder)
			fwr:Credentials := nc
			fwr:@@Method := WebRequestMethods.Ftp.ListDirectoryDetails
			sr := StreamReader{fwr:GetResponse():GetResponseStream()}
			aDirectory := sr:ReadToEnd():Split((CRLF):ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
HTH,
______________________
Johan Nel
Boshof, South Africa
User avatar
Chris
Posts: 4949
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Let's get this started

Post by Chris »

Hi Karl,
FFF wrote:Chris,
i copied Thomas' lines in the Start of a newly created VO-MDI app,
like
VAR cCommandstring := "http://123.456.789.000:xxx/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=xxx&pwd=xxxx"
ShellExecute(0,String2Psz("open"), String2Psz(cCommandString), NULL_String , ;
NULL_String , ;
1 )
first got warnings that the PSZ could provide leaks, replaced them with the suggestet String2PSZ, but then got strange error as
error XS0103: The name 'Xs$Return' does not exist in the current context 3,1 Start.prg MdiApp1
Line 3 being the Function Start() one.
??

Have the Win32Library referenced, how would i add the Win32SDK (as it is not listed in the dialog?

Karl
Yes, that's what I meant, to reference the Win32Library. About the error, I did not get it in my tests, can you please show the complete code you used?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
FFF
Posts: 1589
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Let's get this started

Post by FFF »

New Vo-Mdi Sample, then:

Code: Select all

#include "VOGUIClasses.vh"

FUNCTION Start( asCmdLine AS STRING[] ) AS INT
	
	LOCAL nExitCode AS INT
	
	LOCAL oMainWindow AS StandardShellWindow
	LOCAL oApp AS App
	
	RDDSetDefault( "DBFCDX" )
	
	nExitCode := 0
	
	oApp := App{}
	oMainWindow := StandardShellWindow{oApp}
	oMainWindow:Show(SHOWCENTERED)                            
VAR	cCommandstring := "http://123.456.789.000:xxx/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=xxx&pwd=xxxx"
ShellExecute(0,String2Psz("open"), String2Psz(cCommandString), NULL_String , ;
NULL_String , ;
1 )  
	oApp:Exec()
		
RETURN nExitCode
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Post Reply