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.

Dark GDK / WindowProc .... msg???? winsock 2

Author
Message
Karbonize
16
Years of Service
User Offline
Joined: 7th Mar 2008
Location: Mexico
Posted: 14th Mar 2008 17:02
Hi, im going to use DARk GDK to my client...

but i needto use ""asynchronous sockets""...

So i need to lisent the state of the WinProc...

like...



How i can get this info...on Dark GDK

I hope u understand my problem...

Thx for alll

Gods....! bah im better
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 14th Mar 2008 18:40
The simplest and fastest way to do that is to create a message only window, and have the sockets attached to that window. That way, you do not need to create a visible window.

As an alternative, you could hook the wndproc of the dbpro window, and only target the socket messages, but I think that is going to be more trouble than the method I just told you about.
Karbonize
16
Years of Service
User Offline
Joined: 7th Mar 2008
Location: Mexico
Posted: 14th Mar 2008 18:43
hmm...

Can any give me a easy example about that...add a new window to Dark GDK apliccation

thx...

Gods....! bah im better
Karbonize
16
Years of Service
User Offline
Joined: 7th Mar 2008
Location: Mexico
Posted: 14th Mar 2008 18:49
well and ...

I need too to know wich is the state of my window-game

if it is mini-size of max-size quit signal....

Dark GDk ddidnt implement that fuctions..?

i mean they create a window.. they mush impleemnt how know the sate of it.

thx

Gods....! bah im better
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 14th Mar 2008 21:27
You can create windows that are just not having a visible form, and hook it so it gets messages from winsock I think. Its a regular CreateWindow API call I think to get it started, set up your window's message handler, point your winsock to it, poll for stuff... whella... remember - you are out of process when you do that!

jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 14th Mar 2008 22:36 Edited at: 14th Mar 2008 22:50
Its a CreateWindowEx call, if you want a message only window, or any of XP's advanced window functions. Sure, I will post you up some fabulous code, and I won't even charge you for it.

You do not poll when you use events. That is the second big advantage to using Asynchronous sockets, with the first being...no blocking.

As far as the state of the application window, you already have the handle to the window, so you can get the state yourself.

In order to use Asynchronous sockets, you must create a window to handle the messages, or hook the message pump of the application, and only handle the messages from the socket events.

Either way, it requires a pretty extensive knowledge of Windows programming, not just some fundamentals.

I have code that registers custom window classes and makes windows of those classes and handles the message pumps, too. It is very extensive code, but it includes a C++ class for non-blocking TCP sockets.

If you want to do that, study window classes, and design one that does what you need. You can download the Platform SDK, which documents all of what I am talking about.
Karbonize
16
Years of Service
User Offline
Joined: 7th Mar 2008
Location: Mexico
Posted: 15th Mar 2008 00:08
im not rushing to advance code what i ll not understand if i dont got good base on basics conceps...

right now im trying to do non-blocking sockets and use it on DARK GDK
but i many ppl say is better to use WSAGETSELECTEVENT to make blocking socket to non-blooking but i duuno winapi just a very very little...

so im lloking for some examples during im reading about winapi...

thx for all...

if u know any good text||tuto||book that can help plz tell me

GG GL HF

Gods....! bah im better
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 15th Mar 2008 00:15
Sounds like jinzai is all over this Karbonize... He has some thick code but he's recommending some source that if you google, locate, download, install... the Microsoft Platform SDK... you'll have a manual... and you just look up each function, and get the JIST of it.. you might be short changing yourself... meaning ... you might see it and be like... OH... SO THAT'S HOW THEY DO IT.... and if not... no harm no foul...

If I was you I'd take a look at his code.

jinzai - mighty nice of you... Good stuff

Karbonize
16
Years of Service
User Offline
Joined: 7th Mar 2008
Location: Mexico
Posted: 15th Mar 2008 00:36
hmmm...

im not good at english...

but lets try...

1.- thx for u posts..

2.- i rlly want to learn as my brain can and more... but lets say i dont know c++ im just programing on it for 1 week..
all time that i found something new ( like a code of function or procedures ) i need to look into many basic conceps...

3.- u are right im a guy who just learn doing soemthing what he gots any text tuto or book give me something to use it but i just got what does when i use it and give me 999 erros...

4.- i wanna al info what u ppl wanna share i know there is many codes what take u work and are like ur work etc...

5.- im kinda alone...i have no teacher and there is many concepts like Thread that took me sometime to can aplly them...

6.- there is alot of info on net... and all ppl make his own version about the same stuff hard to know what is the best for my propouse...

7.- Thx for all is good to know there still ppl like u

cya around..

Gods....! bah im better
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 15th Mar 2008 01:52
The English is not an issue, I understand you completely.

I am hesitating because, like jason says, its alot of code. I already have it written and I don't get paid to write code, so when I said I would not charge you, I was making a joke.

If you have a project that uses GDK, and you will post up the .cpp file that contains the main function, I will edit it to include my code. I will put comments on it to show you how it all works. All that you will need to do is include the proper library, which I will show you how to do. It will be easy, I think.

This will take some time, but you will get what you are looking for faster this way.

I strongly recommend that you get the Platform SDK, because it lists all Windows functions, how to use them, what libraries and include files are needed...it really makes this easy after you learn how to use it.

Yes, asynchronous sockets was not the best choice to make for learning C++, or Windows, but getting it working early is very smart!
Karbonize
16
Years of Service
User Offline
Joined: 7th Mar 2008
Location: Mexico
Posted: 15th Mar 2008 06:09
OK... Lets try...

simple window on DARK GDK



Now a Basic window on WinApi



I need do the window obiusly on Dark GDK example

thx for all...

Gods....! bah im better
Karbonize
16
Years of Service
User Offline
Joined: 7th Mar 2008
Location: Mexico
Posted: 15th Mar 2008 06:35 Edited at: 15th Mar 2008 06:35
here two API functions GetWindowLong and SetWindowLong

"GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long

Const GWL_STYLE = (-16) ' Get Window's Style
Const GWL_EXSTYLE = (-20) ' Get Window's Extended Style
Const GWL_WNDPROC = (-4) ' Get handle to address of window procedure
Const GWL_HINSTANCE = (-6) ' Get handle to Application Instance
Const GWL_HWNDPARENT = (-8) ' Get handle to parent window
Const GWL_ID As Long = (-12) ' Get identifier of the window
Const GWL_USERDATA = (-21) ' Get user data associated with the window.

idk if this is the fuction that u told me...

hmm it say is for forms... idk if i can use them to get the event...

dead-reckoning......Buahahaha
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 15th Mar 2008 06:53
The part about forms is for using VisualBasic, or C#, you are not doing that, so ignore it. Yes, that is how you would hook into the application's message hook. As I already said, that is not the way to do it, in my opinion.

Certainly, if someone has implemented hooking the DB window's message pump and using that to capture events...please post that up. I do not do things that way, however...especially communications.

I register my own window class, create a window with that, and use its message pump to implement asynchronous sockets. That way, I know that I am not interfering with the app's message pump. I use a message only window because it never needs to be painted, and it doesn't appear on the task bar, either.

There are two main reasons why I do things this way. First of all, its communications, and although the application depends on it, it is not a part of the application itself, so it needs a sense of itself independent of the game, or application.

Next, it uses resources that are disconnected from the game, and most of the rest of the Windows subsystem, except for this callback facility that Windows has to implement message handling. When you hook the window procedure of your parent, you are then responsible for deciding what to do with all messages for the application. Ones you don't handle, you must pass on to the original handler. There you have put a bottleneck in there, haven't you?

So, I take the responsibility on totally. It is better in the long run.
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 15th Mar 2008 07:31 Edited at: 15th Mar 2008 08:41
Okay, here is some code for you to try. I have broken it up into pieces, and tried to explain where they go.



Let me know if it needs further explanation.

EDIT: One thing I want to say about this...it is not at all out of process. I understand what is meant by that, but look at the hInst, it is the same all over. It is simply event driven by the sockets, which is what you want. You are absolutely free to call the same functions in your message handler, but I wouldn't go too deeply into that. A message pump needs to remain speedy, and not hog processor time. It is better to just pass data in some sort of message in the background. That keeps the socket and the program separate enough to keep one from interfering with the other.
Karbonize
16
Years of Service
User Offline
Joined: 7th Mar 2008
Location: Mexico
Posted: 15th Mar 2008 17:50 Edited at: 15th Mar 2008 17:51
GOOD MORNIG

I just trying to add ur window to my DArk GDk aplication...

but i got a lot of errors like..this..

1>. error C3646: 'dbSyncOn' : unknown override specifier
1>. error C2556: 'void (__cdecl *DarkGDK(void))(void)' : overloaded function differs only by return type from 'void DarkGDK(void)'
1>. error C2365: 'dbSyncRate' : redefinition; previous definition was 'function'

I dunno how DARK GDK are made.. but i sure about they at one moment they need create a window

and they ll get window`s messages...

how i can overrride that fuction...

Thx for all..

i know here r many programar of VB or DB but DARK GDK ask u for VC++

Know know any tuto how on adapt DARK GDK to Sockets...




dead-reckoning......Buahahaha
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 15th Mar 2008 18:29
If you would post the source file you are using, it would help alot. It sounds like an include file has been included twice, but I can't tell for certain without seeing it myself.

This can happen when there is a main include file, and you have also included one of the files that the main include file references. It is complicated sometimes.

Login to post a reply

Server time is: 2024-09-29 15:28:57
Your offset time is: 2024-09-29 15:28:57