Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Windows API stuff

Author
Message
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 8th Apr 2003 23:39
I am writing a menu plugin which allows users to display proper Windows Menus in their DBP apps. Currently I can get the menus to display fine in the DBP program, with all the various features. However I need to process the WM messages send to the Window in order to find out when a particular menu item is selected.

I can process messages fine, however apparently I need to subclass the application in order to trap the WM messages sent to the Window.

Currently I get the address of my replacement function using GetProcAddress() (the module handle is 38329 or something and the address when I dereference to pointer is -45240924204 which surely can't be right?), then I use SetWindowLong to replace DBP's message processing function.

The Window handle for the DBP app is correct because I am using it to assign the menu to the app's Window.

However, whenever I call the SetWindowLong function, I get an Access Violation error. What MSDN didn't make very clear is whether or not a DLL is allowed to make this change to its parent process or not. Currently I have just copied the basic Window message handling function from MSDN to test it (which just redirects all messages to the original processing function). I think that the replacement function is not the problem though.

Delphi Source:



DBPSource:

Current Project: Retro Compo. Entry.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Apr 2003 00:06
You don't appear to be calling the original WndProc after you subclass - this is an error.

If you read MSDN about SetWindowLong return values, you will see how this should be done.

What OS and is it a Unicode DLL? You may need to read the remarks at the bootom of the same page.
HAL
23
Years of Service
User Offline
Joined: 28th Aug 2002
Location:
Posted: 9th Apr 2003 01:32
i was about to ask a similar question. is this where i'm going wrong?. i've been try to work around the SetWindowLong thing because i don't really understand it and don't know how to implement it, but is it absolutely necessary.
here's my very simple dll, could you tell me if i need to scrap it and work on the SetWindowLong thing ?
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 9th Apr 2003 02:51
"What OS and is it a Unicode DLL? "

Windows XP, but obviously the end DLL has to work on all platforms. Not quite sure what you mean by "unicode DLL" but I think the answer is no.

Current Project: Retro Compo. Entry.
empty
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 9th Apr 2003 05:19
Quote: "
What MSDN didn't make very clear is whether or not a DLL is allowed to make this change to its parent process or not.
"


I don't think you can change it for a different process.
AFAIK it says so in the Win32 SDK reference. It'd be worth testing out if you can change it from within DBpro, though.

Ogres have layers.
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 9th Apr 2003 16:44
oki this has peaked my interest now ... lets see what i can come up with before lunchtime
on msdn right now and it doesn't seem that complex - just a case of registering the right classes from the seems, just like Dx

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 9th Apr 2003 17:19
That would be great thanks Raven

"on msdn right now and it doesn't seem that complex"

Even with my limited experience I find programming at least 5x more complicated than it initially appears. sigh!

Personally I don't really like the design of the Windows API, but at least it is fairly consistant.

Once I figure this out, I should be able to do everything else. Creating / adding components are fairly easy as you just create the apropriate Delphi object then use Windows API to place it.

The only slight worry is that there may be some unintended side effects from replacing the messaging system, but I should be able to deal with that. I suppose one could also add a function to get the ASCII keycode for the currently pressed key instead of the scancode which DBP uses.

Current Project: Retro Compo. Entry.
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 9th Apr 2003 21:01 Edited at: 9th Apr 2003 21:01
oki i'm gonna be working on my own WindowsUI for a little while, cause there's more to be done than just the DLL - and i relised that when i had my DLL working, that there is alot of pointer data needed and structuring. I've only ever used MFC before so this was quite a new experience...

Windows User Interface Tutorial
this is quite a good explaination on howto use the Windows interface within C/C++ ... i'm sure you can convert that to delphi but the code explains better the usage than most of the rest of the site. Use the rest for pure reference

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 10th Apr 2003 00:40
I can convert the code to Delphi, but the program crashes with an access violation error every time grrr... I am getting a proc address which is now much more sensible this time.

Current Project: Retro Compo. Entry.
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 10th Apr 2003 04:33
it does? hmm probably the access of the windows, the tutorial is an old one - remember its for '95 and for Me/XP/2000 you'll want to set some parts to NULL as within the reference, like previous window instance and such.

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
Shady Simpson
23
Years of Service
User Offline
Joined: 15th Mar 2003
Location: United Kingdom
Posted: 20th Apr 2003 18:28
Hi,

I know this post has been long forgotten about, but a windows menu plugin thingymajjigy would help me loads!

Just wonderin if you were finished yet?

Thanx.

Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 21st Apr 2003 03:28
i'm as good as done with mine ... well the actualy creation and such, what i've got to do once i get home is ALOT of bug squishing, writing up a full helpfile for the UINT pointer system, howto use the DarkBasic Pro library sources.
lol - getting it working unfortunately is only half the task.
you know its funny, i've noticed that TATOAD was using some form of Windows UI for his F-Zero demo thingie.
just wonder why he hasn't gone into making one, i'm sure he'd of been done by now.

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
Kale
23
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 21st Apr 2003 05:25
Sorry but, Raven you are full of shit!

What the flame does not consume, consumes the flame.
------------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Home
Shady Simpson
23
Years of Service
User Offline
Joined: 15th Mar 2003
Location: United Kingdom
Posted: 21st Apr 2003 13:00
So raven, Where can I get a hold of it once your finished? or are you not going to make it available?

Thanx.

MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 21st Apr 2003 13:14
I was thinking of doing a UI system, but there are so many people doing it, I decided it wouldn't be worth it...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 21st Apr 2003 14:38
Should be up on my forum in a week or two, depends how long my other projects take me really.
you should make one Toad, i mean you already know about most of what we're working with - i'm jumping form MFC to Windows and its weird, i mean i didn't release exactly how much was automated and enum'd automatically... having only Demo 1.03.0 of dbpro certainly hasn't helped a speed development.

problem hasn't as much been the development in C++ though, but the development in DBpro itself which is driving me insane. Musta made 3 different systems for handling UINT pointers - and none have really worked 100% ... noticed that MSDN is also confusing in where you've gotta go to next find out information, i mean you'll follow one link it'll explain the class you'd create that to find out you have to create something else first, then you find out you have to fill a pointer etc... lol been nuts

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 21st Apr 2003 15:50
Bit late for me to start one now - busy doing my game...
MSDN can be a bit of a pain - would be useful if they did complete examples (and not just small examples that need extra code to be made to work).

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 21st Apr 2003 18:51
yeah... i'm thinking quite carefully about the structure of my manual for this plugin - cause the idea will be to help newbies understand the more complex tasks of pro to be able to use it properly

atleast i've finally decided on a look and setup for my forum, but i don't think that Martyn is gonna like it hahaa
i'll have to check out what more you've done on your game when you get back (^_^) i believe we were estimated a demo over the weekend

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?

Login to post a reply

Server time is: 2026-07-10 21:40:46
Your offset time is: 2026-07-10 21:40:46