Author Topic: TinyPTC Ext  (Read 51194 times)

0 Members and 3 Guests are viewing this topic.

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2751
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: TinyPTC Ext
« Reply #20 on: March 06, 2007 »
Thanks rdc, works fine here, added it into the zip file.

Challenge Trophies Won:

Offline BadMrBox

  • ZX 81
  • *
  • Posts: 22
  • Karma: 0
    • View Profile
    • Ragnarok Games
Re: TinyPTC Ext
« Reply #21 on: March 06, 2007 »
Hey all. Got tempted to test this new version of tinyptc so I decided to finally become a member of this board.
Great stuff rbraz!
Bringer of Apocalypse

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17398
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: TinyPTC Ext
« Reply #22 on: March 06, 2007 »
 :hi: And thanks for your comments in the other FB sites on the gfx demos, it's nice to see you here. If you have any questions about anything at all you find on this site, please do not hesitate at all in asking. I have used Rbraz's library to release lots of demo scene productions, including this one DUTCH COLOURS - POUET which got a .90 average at Pouet which is really good going and shows how good this library is :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline BadMrBox

  • ZX 81
  • *
  • Posts: 22
  • Karma: 0
    • View Profile
    • Ragnarok Games
Re: TinyPTC Ext
« Reply #23 on: March 06, 2007 »
Thanks Shockwave. I'll let you know if there is something I dont figure out here :)
Bringer of Apocalypse

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2751
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: TinyPTC Ext
« Reply #24 on: March 08, 2007 »
 :hi: BadMrBox


Added a new feature to the library -> ptc_allowclose

With ptc_allowclose(0) command you will be able to disable tinyptc internal Escape key check. Use ptc_allowclose(1) to enable it again, just place this command before you open your window (ptc_open)

Here's a little example:

Code: [Select]
'
'
'  "ptc_setdialog" command test
'        by rbraz 2007
'
'
'-------------------------------------
' Includes.
'-------------------------------------
#include once "tinyptc_ext.bi"
#include "windows.bi"

dim shared buffer(640*480) as integer
dim text as string

text =  " ¤´¨) " & chr$(13)
text += " ¸.·´¸.·*´¨) ¸.·*¨)" & chr$(13)
text += "(¸.·´ (¸.·`¤... SHOCKWAVE ^ DBF ^ S!P ...¤" & chr$(13) & chr$(13) & chr$(13)
text += "FullScreen Mode ?"

ptc_setdialog(1,text,0)

ptc_allowclose(0) 'disable tinyptc to close on Escape Key press
'ptc_allowclose(1) 'enable tinyptc to close on Escape Key press

'Open TinyPTC window
If( ptc_open( "ptc_setdialog command test", 640, 480 ) = 0 ) Then
    End -1
End if


'Main Loop
'
' If you use ptc_allowclose(0)
'This app will only terminate if you press "F1" key

while(GetAsyncKeyState(VK_F1)<>-32767)
    ptc_update @buffer(0)
wend

ptc_close()
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17398
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: TinyPTC Ext
« Reply #25 on: March 08, 2007 »
Thanks for the new feature Rbraz :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2751
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: TinyPTC Ext
« Reply #26 on: May 31, 2007 »
*Update*
"ptc_setdialog"  -> Added a new parameter to disable window border as Shockwave suggested.


Example:
Code: [Select]
'
'
'  "Borderless Window" command test
'        by rbraz 2007
'
'
'-------------------------------------
' Includes.
'-------------------------------------
#include "tinyptc_ext.bi"
#include "windows.bi"

dim shared buffer(640*480) as integer

'-------------------------------------------------------------------------------
'1st param. = Enable messagebox (dialog)
'2nd param. = Messagebox text
'3rd param. = Start in fullscreen or windowed mode if 1st param. is zero
'4th param. = Window normal border (0) or borderless (1)
ptc_setdialog(0,"",1,1)
'-------------------------------------------------------------------------------

ptc_allowclose(1) 'enable tinyptc_ext to close on Escape Key press

'Open TinyPTC window
If( ptc_open( "Borderless Window test", 640, 480 ) = 0 ) Then
    End -1
End if

dim i
for i=0 to 640*480
     buffer(i) = &h00334466
next

'Main Loop
while(1)
    ptc_update @buffer(0)
wend

ptc_close()
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17398
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: TinyPTC Ext
« Reply #27 on: May 31, 2007 »
Works nice Rbraz :)

Beautiful!
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: TinyPTC Ext
« Reply #28 on: June 08, 2007 »
I know I took this code out before, but it's been pointed out to me that handling the SC_SCREENSAVE WM_SYSCOMMAND message doesn't work on Vista any more.  Don't know why.

Rbraz, can you please add in the following to the startup and shutdown routines?
Code: [Select]
static BOOL screen_save_active;
static void disable_screensaver(void)
{
SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &screen_save_active, 0);
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0);

DWORD dwReturnValue;
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETSCREENSAVEACTIVE, (LPARAM)"Desktop", SMTO_ABORTIFHUNG, 5000, &dwReturnValue);

SetThreadExecutionState(ES_DISPLAY_REQUIRED|ES_CONTINUOUS);
}

static void enable_screensaver(void)
{
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, screen_save_active, NULL, 0);
DWORD dwReturnValue;
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETSCREENSAVEACTIVE, (LPARAM)"Desktop", SMTO_ABORTIFHUNG, 5000, &dwReturnValue);
}

This version is slightly more friendly than the one that was removed - it tells other apps that we've changed a setting, and restores the setting when we've finished.

Cheers!

Jim
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2751
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: TinyPTC Ext
« Reply #29 on: June 08, 2007 »
Ok Jim, I'll add that function, thanks.
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2751
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: TinyPTC Ext
« Reply #30 on: June 10, 2007 »
@Jim: I'm having troubles to compile it, freebasic refuse to include "SetThreadExecutionState", tried to include kernel32 lib ('$inclib: "kernel32") and #define WIN_INCLUDEALL, whitout success, it give this error:
Quote
Compiler output:
.//libtinyptc_ext.a(ddraw.o): In function `disable_screensaver':
E:/Programming/TinyPTC/Tinyptc_Library/devcpp/ddraw.c:70: undefined reference to `SetThreadExecutionState'

Results:
Compilation failed

System:
FBIde: 0.4.6
fbc:   FreeBASIC Compiler - Version 0.15 for win32 (target:win32)
OS:    Windows XP (build 2600, Service Pack 2)

Btw, I'm using the original source of tinyptc by gaffer, and to disable screensaver it use this:
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, 0, 0);
and to enable again:
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 1, 0, 0);
Have you checked if it's working?
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: TinyPTC Ext
« Reply #31 on: June 11, 2007 »
I'll have a look.  For now, just remove the SetThreadExecutionState line.  You should still get the code to call SendMessageTimeout to notify other applications that you've changed a system setting, and the other code to preserve the existing state of that setting.  Gaffer's code assumes the screensaver is enabled before and after the app has run, which might not be true!

Jim
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2751
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: TinyPTC Ext
« Reply #32 on: June 12, 2007 »
*Updated*

Added Jim code to disable/enable screensaver, compatible with Vista, tested on WinXp sp2 too.
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: TinyPTC Ext
« Reply #33 on: June 12, 2007 »
Thanks!

Jim
Challenge Trophies Won:

Offline WidowMaker [retired]

  • %010101
  • Atari ST
  • ***
  • Posts: 134
  • Karma: 21
  • %010101
    • View Profile
Re: TinyPTC Ext
« Reply #34 on: June 30, 2007 »
Awesome work Rbraz. I use this.


Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: TinyPTC Ext
« Reply #35 on: September 12, 2007 »
Is it possible to add a function that will retrieve the HWND of the window opened by PTC?

Jim
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17398
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: TinyPTC Ext
« Reply #36 on: January 02, 2008 »
Mouse functions?

These work well, I like the ability to be able to monitor the buttons and the position of the mouse, however in many things it would be preferable to have your own mouse pointer.

So with this in mind here is a test application..

(attached).

And the code:

Code: [Select]
'
' Mouse Test
'
    OPTION STATIC
    OPTION EXPLICIT

    #INCLUDE "TINYPTC_EXT.BI"
    #INCLUDE "WINDOWS.BI"
   
    CONST   XRES    =   800
    CONST   YRES    =   600
   
    DIM SHARED AS UINTEGER BUFFER ( XRES * YRES )
   
    PTC_ALLOWCLOSE(0)
    PTC_SETDIALOG(1,"Fullscreen?",0,1)                 
    IF (PTC_OPEN("OSUK",XRES,YRES)=0) THEN
    END-1
    END IF     

    DIM SHARED AS INTEGER MX,MY
   

WHILE(GETASYNCKEYSTATE(VK_ESCAPE)<> -32767)

    MX=PTC_GETMOUSEX()
    MY=PTC_GETMOUSEY()
   
    BUFFER(MX+(MY*XRES)) = &HFFFFFF
    PTC_UPDATE@BUFFER(0)
    ERASE BUFFER
   
WEND
   
    PTC_CLOSE()
    END

Please select fullscreen mode when you run it, then move the mouse around. I plot a dot at mouse x , mouse y

Now press Alt+tab to minimize the application.
Re-instate it and you see that the default mouse pointer is being displayed.

How do you turn off the mouse pointer so this cannot happen please?

Also the default pointer is visible in windowed mode, again it would be nice to be able to turn this off.

Cheers if you can help!
Shockwave ^ Codigos
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: TinyPTC Ext
« Reply #37 on: January 02, 2008 »
Do not know FreeBasic - do you have access to the WinAPI functions ???
If so, you may try ShowCursor(bool) function from user32.dll.
Maybe this helps out!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17398
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: TinyPTC Ext
« Reply #38 on: January 02, 2008 »
Good tip Benny :)
Worked first time.

After including windows.bi

Code: [Select]
dim as integer mouse   
mouse=ShowCursor(0)

Have some good Karma Benny :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: TinyPTC Ext
« Reply #39 on: January 02, 2008 »
Thanks mate - glad that it works !!!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won: