PDA

Click to See Complete Forum and Search --> : Doesn't anybody know how to do this? Don't make me whip out my hate mail...


Phobic
Nov 10th, 1999, 02:35 AM
I'll ask one more time, I've been experimenting with the SetWindowLong API, and I've been able to make it work quite well with my own project's forms, however I've had no success in making it work on other windows...

Here's my code...Private Declare Function SetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Const SWP_NOMOVE = &H2
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4
Private Const SWP_SHOWWINDOW = &H40
Private Const GWL_STYLE = (-16)
Private Const WS_BORDER = &H800000
'--------------------------------------------
Dim XX As Long
XX = GetWindowLong(FindWindow(vbNullString, "Untitled - Notepad"), GWL_STYLE) 'Get Notepad's current window style...
XX = XX Or WS_BORDER 'Modify it to include the BORDER windowstyle (no size)...
BSuccess = SetWindowLongA(FindWindow(vbNullString, "Untitled - Notepad"), GWL_STYLE, XX) 'Set the new windowstyle... !THIS PART DOESN'T WORK!
Call SetWindowPos(FindWindow(vbNullString, "Untitled - Notepad"), 0, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_SHOWWINDOW Or SWP_FRAMECHANGED Or SWP_NOZORDER) 'Refresh the window to display the new style...
MsgBox BSuccess 'Display success of applying windowstyle !RETURNS 0, MEANING NOPE!As I said, it works with my project's forms beautifully, but not on other windows. Can someone gimme a little enlightenment?

[This message has been edited by Phobic (edited 11-10-1999).]

Aaron Young
Nov 10th, 1999, 03:01 AM
SetWindowLong Cannot be used if the Window doesn't belong to the same Process as your Application Thread. But it does seem to work on NT.


------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net

Phobic
Nov 10th, 1999, 11:01 AM
Any ideas on how to get around it...?

Crazy D
Nov 10th, 1999, 02:14 PM
Windows 95/98: The SetWindowLong function may fail if the window specified by the hWnd parameter does not belong to the same process as the calling thread.

Note This function has been superseded by the SetWindowLongPtr function. To write code that is compatible with both 32-bit and 64-bit versions of Windows, use SetWindowLongPtr.

SetWindowLongPtr function fails if the window specified by the hWnd parameter does not belong to the same process as the calling thread.

Hmmmmmmmmm I guess you're having bad luck :-(
I can't think of a workaround... (except for 'use Windooz NT' ....)