SetWindowLong_

Everything else that doesn't fall into one of the other PB categories.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by NIN.

I'd like to write a DLL that changes the properties of a BLitz app window. I have already written DLL's that hide, show, resize, move, minimize, maximize, and do other things to the window.

Will SetWindowLong_() work with a 'hwnd' value gotten by FindWindow_()?

I have been trying to change the window style, without success. The hwnd value is correct, because I can change the title, but I can't change the window style. I am using the PB window itself here, but please remember that this is to be used as a DLL, so I can only work with a 'hwnd' value returned from FindWindow_(). Thanks for your advice:

hwnd=OpenWindow(0,400,400,200,200,#PB_WINDOW_SYSTEMMENU,"TEST")
SetWindowText_( hwnd,"WHOOPS" )
SetWindowLong_(hwnd,#GWL_STYLE,#WS_VSCROLL|#WS_HSCROLL)
Repeat
eventid=WaitWindowEvent()
Until eventid=#PB_EventCloseWindow
CloseWindow(0)
End
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by NIN.

Interestingly, this code produces no change. (The above code kind of freezes up the window).

currentstyle=getwindowlong_(hwnd,#GWL_STYLE)
SetWindowLong_(hwnd,#GWL_STYLE,currentstyle)

So I can only assume that I must not be using the right combination of window styles. Here is a list of the available options, from the API Guide documentation:

Public Const WS_OVERLAPPED = &H0&
Public Const WS_POPUP = &H80000000
Public Const WS_CHILD = &H40000000
Public Const WS_MINIMIZE = &H20000000
Public Const WS_VISIBLE = &H10000000
Public Const WS_DISABLED = &H8000000
Public Const WS_CLIPSIBLINGS = &H4000000
Public Const WS_CLIPCHILDREN = &H2000000
Public Const WS_MAXIMIZE = &H1000000
Public Const WS_CAPTION = &HC00000 ' WS_BORDER Or WS_DLGFRAME
Public Const WS_BORDER = &H800000
Public Const WS_DLGFRAME = &H400000
Public Const WS_VSCROLL = &H200000
Public Const WS_HSCROLL = &H100000
Public Const WS_SYSMENU = &H80000
Public Const WS_THICKFRAME = &H40000
Public Const WS_GROUP = &H20000
Public Const WS_TABSTOP = &H10000
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_TILED = WS_OVERLAPPED
Public Const WS_ICONIC = WS_MINIMIZE
Public Const WS_SIZEBOX = WS_THICKFRAME
Public Const WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX)
Public Const WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW
Public Const WS_POPUPWINDOW = (WS_POPUP Or WS_BORDER Or WS_SYSMENU)
Public Const WS_CHILDWINDOW = (WS_CHILD)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by NIN.

Okay, I am now successfully changing a PB app. However, the routine will not work on another app, in this case, an open folder:

hwnd=findwindow_(0,"source")
setwindowlong_(hwnd,#GWL_STYLE,#WS_SYSMENU|#WS_BORDER|#WS_DLGFRAME)
showWindow_(hwnd,1)
updatewindow_(hwnd)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by NIN.

Here. This shows that I am finding the window, getting the style, but after I set the style, it remains the same:

hwnd=findwindow_(0,"source")
MessageRequester("",Str(getwindowlong_(hwnd,#GWL_STYLE)),0)
setwindowlong_(hwnd,#GWL_STYLE,#WS_SYSMENU|#WS_BORDER|#WS_DLGFRAME)
showWindow_(hwnd,1)
updatewindow_(hwnd)
MessageRequester("",Str(getwindowlong_(hwnd,#GWL_STYLE)),0)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

I'm not sure you can act on window than you don't own... Never tried.

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

Yes, that is right. So the Folder thingy you just tried can't work.
But if you use it from a dll, that is called from the App that created the window, it should work. In this case the dll is executed from the same Process space, so it should be OK.

Timo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by NIN.

You rock, man.
Post Reply