Windows API integration

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Windows API integration

Post by Michael Vogel »

Hi,
I was searching for some equivalents of commands I've often used with GFA Basic, but I didn't find them (maybe I missed something?)

I would be happy, if such things could be implemented with its own commands, so every user could use them in an identically way...

Code: Select all

; Which constant can be used in OpenWindows to create a windows without a titlebar but with a normal border?
OpenWindow(1,20,20,400,400,#PB_Window_Border | #PB_Window_TitleLess,"")
Delay (1000)

; How to hide and display a mouse cursor easily? This would be fine for screen savers, etc.
HideMouse()
ShowMouse()

; Is there also a command for setting a certain mouse cursor symbol? (Arrow, Hourglass, etc.)
DefMouse(#PB_IDC_WAIT)
Jan Vooijs
Enthusiast
Enthusiast
Posts: 196
Joined: Tue Sep 30, 2003 4:32 pm
Location: The Netherlands

Post by Jan Vooijs »

Yeah,

The 'mouse' commands you mention are indeed missing?!?! Will need them very soon in my application..

Fred couls you please add them in PB4, prety please??

And for the windows problem:

Code: Select all

#PB_Window_Thickframe   = $00040000
#PB_Window_Border         = $00800000
#PB_Window_Popup          = $80000000
Life goes to Fast, Enjoy!!

PB 4 is to good to be true, wake up man it is NOT a dream THIS is a reality!!!

AMD Athlon on 1.75G, 1Gb ram, 160Gb HD, NVidia FX5200, NEC ND-3500AG DVD+RW and CD+RW, in a Qbic EO3702A and Win XP Pro SP2 (registered)
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Post by Michael Vogel »

Jan Vooijs wrote:Yeah,

And for the windows problem:

Code: Select all

#PB_Window_Thickframe   = $00040000
#PB_Window_Border         = $00800000
#PB_Window_Popup          = $80000000
Thanks for your help, but I'm still not able to do use it correctly...

Code: Select all

If OpenWindow(0,100,100,492,180,#PB_Window_Border,"")
...
EndIf
...again adds a caption bar at the top of the window. Sometimes a window without any title bar is needed. What did I wrong?

Michael
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Window:

Code: Select all

OpenWindow(1,20,20,400,400, #WS_POPUP | #WS_DLGFRAME,"") 
Hide/show cursor:

Code: Select all

ShowCursor_(0)
ShowCursor_(1)
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Post by Michael Vogel »

Trond wrote:Window:

Code: Select all

OpenWindow(1,20,20,400,400, #WS_POPUP | #WS_DLGFRAME,"") 
Hide/show cursor:

Code: Select all

ShowCursor_(0)
ShowCursor_(1)
Hey ! So easy, when you know it - so hard to find for me...

Do you also know the right command to change a cursor?

I tried SetCursor_(LoadCursor_(0,#IDC_WAIT)), but that does not work...
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Code: Select all

OpenWindow(0, 0, 0, 400, 300, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, "")
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
  EndSelect
  SetCursor_(LoadCursor_(0, #IDC_CROSS))
ForEver
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

Jan Vooijs wrote:Yeah,

The 'mouse' commands you mention are indeed missing?!?! Will need them very soon in my application..

Fred couls you please add them in PB4, prety please??
You are right, this might be implemented in future version for all OS,
shouldn't be too hard for Fred as all OS have this features i think...
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

I've found the ShowCursor API to be totally useless. Never works for me.
I've resorted to just moving the pointer to the bottom-right corner of the
screen, where it is not so visible; but I know this is not an ideal solution.

BTW, I note that the MSDN docs state that the ShowCursor API is related
to DirectShow 9.0 anyway -- so maybe that has something to do with it?
The actual description for it states: The ShowCursor method makes the
cursor visible when the MSWebDVD object is in full-screen mode.

So maybe it's not meant for general hiding/showing of the mouse?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Unless the class cursor is set to null, the cursor is 'refreshed' everytime the mouse is moved. One way around this is to use SetCursor_(0) in your event loop etc.
Last edited by srod on Wed Mar 01, 2006 8:39 pm, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Example:

Code: Select all

OpenWindow(0, 0, 0, 400, 300, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, "")
ShowCursor_(0)
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver
The ShowCursor function displays or hides the cursor.

int ShowCursor(

BOOL bShow // cursor visibility flag
);


Parameters

bShow

Specifies whether the internal display counter is to be incremented or decremented. If bShow is TRUE, the display count is incremented by one. If bShow is FALSE, the display count is decremented by one.



Return Values

The return value specifies the new display counter.

Remarks

This function sets an internal display counter that determines whether the cursor should be displayed. The cursor is displayed only if the display count is greater than or equal to 0. If a mouse is installed, the initial display count is 0. If no mouse is installed, the display count is -1.
Post Reply