Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
6
Erster Beitrag:
vor 4 Jahren, 10 Monaten
Letzter Beitrag:
vor 4 Jahren, 10 Monaten
Beteiligte Autoren:
Fabrice Harari, Viggo Poulsen, Andre Labuschagne

WB and Screen Resolution

Startbeitrag von Andre Labuschagne am 11.10.2013 06:28

Hi All

The docs say that WB browser code supports the return of SysXRes() and SysYRes(). I have placed the code in the onload code section but it is returning zeroes. Any ideas? Does it actually work?

Cheers
Andre

Antworten:

Hi Andre

I havent tried it, but something strange is happening. In the help for SysXRes is stated that it is used in the example project WWPocket. This project I cannot find in WB18 but I found it in WB17 (where SysXRes seems to be introduced).
In this project, SysXres is not used. Instead they use this method in Global Server procedures:

PROCEDURE bPocketResolution()
// returns true if the width of the screen is less than 240

// Test mode
IF InTestMode() THEN RESULT False

// Pocket PC test in server code
sString is string on 256
sResolution is string

// Interrogate the environment variables
CallDLL32("KERNEL32","GetEnvironmentVariableA", "HTTP_USER_AGENT", &sString, 256)

// Capture the resolution
sResolution = ExtractString(sString,5,";")
sResolution = NoSpace(sResolution)
sResolution = Replace(sResolution,")","")

// Screen Width
sResolution = ExtractString(sResolution,1,"x")

// Page to display for the 240x320 resolution
IF Val(sResolution) > 0 AND Val(sResolution)

von Viggo Poulsen - am 11.10.2013 09:31
Hi Andre

unfortunately, it depends of the browser and its version and is therefore not reliable... I use some snippets of JS code to get the info

Best regards

von Fabrice Harari - am 11.10.2013 14:42
Hi

Viggo - thanks for that info.

Fabrice - I realized that is actually working. In the browser code it returns the correct resolution. The problem I now have is passing this to global variables in server code so that I can use it in server code in a button control. I cannot get it passed to the server variables. Tried using AjaxExcute procedure. This is all that I am left with - how to get the values passed to global page vars.

Cheers
Andre

von Andre Labuschagne - am 11.10.2013 22:27
Hi Andre

You can do it like this:
Put the value in a field on the screen. Hide it.
Make a hidden button BTN_BtoS
From browser code: ExecuteProcess(BTN_BtoS,trtClick)
In the buttons servercode you can now read the field content.

The ExecuteProcess is special, because if called from Browser code it can execute both Browser and Server code.

Best regards
Viggo Poulsen

von Viggo Poulsen - am 12.10.2013 08:40
Hi André

you can of course send the values both by ajaxexecute or by the system described by Viggo...

However, I amy be wrong, but reading between the lines of what you are telling us, I'm wondering if your problem is not in the ORDER of the different treatments... It looks to me like you are trying to use the browser SIZE in the SERVER INIT CODE...

If I'm right, it will just not work because processes are occuring in that order:
- 1 - SERVER init code (on the server, therefore)
- 2 - BROWSER onload (on the customer machine, therefore)... Which is where ANY way to get the browser size can be used

So clearly, in 1, there is no way to get the information that will become available ONLY when the browser window has in fact been initialized. Before that, your web site lives ony as a URL in the address bar of the browser and as a process on your server...

So if for whatever reason you REALLY need to get the browser size in the server init code, you will need to load TWO pages one after the other... The first one with by example a "loading..." text will use the browser onload code to send the browser size to the server, and you'll THEN be able to use this information to load the second (REAL) page.

Of course, this will work only as long as the user doesn't resize its browser (in that case, you have more work to do)

Best regards

von Fabrice Harari - am 12.10.2013 12:57
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.