Separately for WinXP

Just starting out? Need help? Post your questions and find answers here.
AZJIO
Addict
Addict
Posts: 2143
Joined: Sun May 14, 2017 1:48 am

Separately for WinXP

Post by AZJIO »

I use this code to make the program work on WindowsXP, but I still get an error calling ChangeWindowMessageFilter.

Code: Select all

If OSVersion() > #PB_OS_Windows_Vista
	ChangeWindowMessageFilter_(#WM_DROPFILES, #MSGFLT_ADD)
	ChangeWindowMessageFilter_(#WM_COPYDATA, #MSGFLT_ADD)
	ChangeWindowMessageFilter_(73, #MSGFLT_ADD)
EndIf
If I remove this code, it works on WindowsXP
BarryG
Addict
Addict
Posts: 4129
Joined: Thu Apr 18, 2019 8:17 am

Re: Separately for WinXP

Post by BarryG »

What exactly is the error message, and what is the question?
User avatar
jacdelad
Addict
Addict
Posts: 1993
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Separately for WinXP

Post by jacdelad »

Thank god, I'm not the only one who doesn't understand the question.

Anyway, look here:
https://learn.microsoft.com/en-us/windo ... sagefilter

Minimum is Windows Vista/Server 2008.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
BarryG
Addict
Addict
Posts: 4129
Joined: Thu Apr 18, 2019 8:17 am

Re: Separately for WinXP

Post by BarryG »

Okay, I'm guessing that because ChangeWindowMessageFilter is not available on XP, the code won't compile due to the unavailable API.

So, AZJIO, you might need to try something like below. It's how I used to deal with such errors in the past when an API wasn't supported by an OS.

I give no guarantee that the below code will work.

Code: Select all

Procedure ChangeWindowMessageFilter(param1,param2)
  lib=OpenLibrary(#PB_Any,"user32.dll")
  If lib
    CallFunction(lib,"ChangeWindowMessageFilter",param1,param2)
    CloseLibrary(lib)
  EndIf
EndProcedure

ChangeWindowMessageFilter(#WM_DROPFILES,#MSGFLT_ADD)
AZJIO
Addict
Addict
Posts: 2143
Joined: Sun May 14, 2017 1:48 am

Re: Separately for WinXP

Post by AZJIO »

BarryG wrote: Fri Jun 30, 2023 4:40 am So, AZJIO, you might need to try something like below.
Thanks It works
jacdelad wrote: Fri Jun 30, 2023 3:37 am Anyway, look here:
This information is known to me.

I use this code in 3 programs, two of which can run on WinXP (ContMenuFiles и zRegistration). The function allows you to drag and drop exe-files into the program window when working as an administrator. Without this code, you cannot drag and drop files from a program opened as a user into a program opened as an administrator. Receiver rights must be the same or lower, but not vice versa
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Separately for WinXP

Post by RASHAD »

In that case
MSDN
[Using the ChangeWindowMessageFilter function is not recommended, as it has process-wide scope. Instead, use the ChangeWindowMessageFilterEx function to control access to specific windows as needed. ChangeWindowMessageFilter may not be supported in future versions of Windows.]
Egypt my love
User avatar
NicTheQuick
Addict
Addict
Posts: 1504
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Separately for WinXP

Post by NicTheQuick »

BarryG wrote: Fri Jun 30, 2023 4:40 am

Code: Select all

Procedure ChangeWindowMessageFilter(param1,param2)
  lib=OpenLibrary(#PB_Any,"user32.dll")
  If lib
    CallFunction(lib,"ChangeWindowMessageFilter",param1,param2)
    CloseLibrary(lib)
  EndIf
EndProcedure

ChangeWindowMessageFilter(#WM_DROPFILES,#MSGFLT_ADD)
I think the better way is to use prototypes:

Code: Select all

Prototype ChangeWindowMessageFilter.i(message.i, dwFlag.i)
Global ChangeWindowMessageFilter.ChangeWindowMessageFilter = 0
Define lib_user32.i = OpenLibrary(#PB_Any, "user32.dll")
If lib_user32
	ChangeWindowMessageFilter = GetFunction(lib_user32, "ChangeWindowMessageFilter")
EndIf
Besides of that it is also better to not open the library everytime you want to call that function. Just load it once and you're fine.

Disclaimer: I did not test my code since I don't own Windows. Please correct me if I did something wrong.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Post Reply